2013-12-16 15 views
1

如何阅读二部图? 我尝试下面的代码,但是当我试图让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

回答

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顶点属性,该属性定义哪些顶点位于哪个组中。