简体   繁体   English

将二分图加载到igraph

[英]load bipartite graph into igraph

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 ) 我有一个二分(双模)图的加权边列表,其中AB是两个节点类型, W是边的权重...( g中只有6个节点)

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 . 我想在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功能,我通常使用:

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

This fails when we have a weighted bipartite graph like g above. 当我们有一个如上面的g加权二分图时,这就失败了。 Is there a straightforward way to get data from the format of g into igraph ? 有没有一种简单的方法可以将数据从g格式转换为igraph

Other options are very welcome if people prefer something different to igraph for drawing bipartite graphs. 如果人们喜欢与绘制二分图的igraph不同的东西,那么其他选项也是非常受欢迎的。

There is a function called graph.data.frame in igraph which seems to load the table just fine for me: igraph有一个名为graph.data.frameigraph ,它似乎可以加载表格对我来说很好:

> 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM