0
votes

I have the following weighted edge list for a bipartite (two mode) graph where A and B are two node types and W is the weight of the edge... (there are only 6 nodes in g)

g <- read.table(text="

 A  B   W

 1  55  3
 2  55  5
 3  99  6 ",header=TRUE)

I want to draw this graph in igraph. However loading the graph in from this format is not simple. I was working with tnet which has a nice export to igraph function which I usually use:

tnet_igraph(sample, type="weighted one-mode tnet")

This fails when we have a weighted bipartite graph like g above. Is there a straightforward way to get data from the format of g into igraph?

Other options are very welcome if people prefer something different to igraph for drawing bipartite graphs.

1

1 Answers

2
votes

There is a function called graph.data.frame in igraph which seems to load the table just fine for me:

> g
  A  B W
1 1 55 3
2 2 55 5
3 3 99 6
> g <- graph.data.frame(g)
> vcount(g)
[1] 5
> ecount(g)
[1] 3
> E(g)$W
[1] 3 5 6