Dear all,

I have a txt file of the following format that describes the relationships
between a network of a certain number of nodes.

{4, 2, 3}
{3, 4, 1}
{4, 2, 1}
{2, 1, 3}
{2, 3}
{}
{2, 5, 1}
{3, 5, 4}
{3, 4}
{2, 5, 3}

For example the first line {4, 2, 3} implies that there is a connection
between Node 1 and Node 4, a connection between Node 1 and Node 2 and a
connection between Node 1 and Node 3. The second line {3, 4, 1} implies that
there is a connection between Node 2 and Node 3 as well as Node 4 and Node
1. Note that some of the nodes can be isolated (i.e., not have any
connections to any other node) which is then indicated by {}. Also note that
the elements in each row are not necessarily ordered (i.e., {4, 2, 3}
instead of {2, 3, 4}). I would like to (a) read the txt file into R and (b)
convert it to an adjacency matrix. For example the adjacency matrix
corresponding to the aforementioned example is as follows:

0 1 1 1 0 0 0 0 0 0
1 0 1 1 0 0 0 0 0 0
1 1 0 1 0 0 0 0 0 0
1 1 1 0 0 0 0 0 0 0
0 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
1 1 0 0 1 0 0 0 0 0
0 0 1 1 1 0 0 0 0 0
0 0 1 1 0 0 0 0 0 0
0 1 1 0 1 0 0 0 0 0

Is there any convenient way of doing this?

Thanks,

Michael

	[[alternative HTML version deleted]]

