M.M
M.M

Reputation: 1373

read bipartite graphs and one mode projection

How can I read a bipartite graph? I tried the following code, but when I tried to make OMP, it says

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

here is the code :

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

Upvotes: 2

Views: 1425

Answers (1)

Gabor Csardi
Gabor Csardi

Reputation: 10825

From the docs:

 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.

So please add a type vertex attribute, that defines which vertices are in which group.

Upvotes: 5

Related Questions