阅读二分图和一个模式投影

时间:2013-12-16 13:14:02

标签: r igraph

如何阅读二分图? 我尝试了以下代码,但是当我尝试制作OMP时,它说

Error in bipartite.projection(g, types = NULL) : 
  Not a bipartite graph, supply `types' argument

这是代码:

edgelist = read.csv("g1.csv",header=FALSE,sep=",")
g  = graph.edgelist(as.matrix(edgelist),directed=FALSE)
proj <- bipartite.projection(g,types=NULL)
g2= proj[[1]]
myplot(g2)
  

g1.csv 1,5 1,4 2,4 3,5

1 个答案:

答案 0 :(得分:3)

来自文档:

 Bipartite graphs have a ‘type’ vertex attribute in igraph, this is
 boolean and ‘FALSE’ for the vertices of the first kind and ‘TRUE’
 for vertices of the second kind.

所以请添加一个type顶点属性,用于定义哪个顶点位于哪个组中。