wrahool
wrahool

Reputation: 1141

Bipartite projection not working in igraph

I am trying to get the projections of a bi-partite graph using igraph. My bi-partite network has 9523 edges, 8313 are of type FALSE and 1210 of type TRUE - as the following two outputs confirm.

> length(V(bp_network))
[1] 9523
> table(V(bp_network)$type)

FALSE  TRUE 
 8313  1210 

However, when I try to project them using

pr_networks = bipartite_projection(bp_network, multiplicity = TRUE)

I get the following error:

Error in bipartite_projection(bp_network, multiplicity = TRUE) : 
  At structure_generators.c:86 : Invalid (negative) vertex id, Invalid vertex id

I have tried changing the type of the vertices to characters from boolean.

> table(V(bp_network)$type)

   A    B 
1210 8313 

Now the same code gives another error:

Error in bipartite_projection(bp_network, multiplicity = TRUE) : 
  `NA' is not allowed in vertex types
In addition: Warning message:
In bipartite_projection(bp_network, multiplicity = TRUE) :
  vertex types converted to logical

What might be going on?

EDIT: The network is created from a data frame with two columns of Twitter usernames, each row corresponding to a follow relationship.

> names(elite_following_df)
[1] "user"      "following"    
> nrow(elite_following_df)
[1] 267442
> bp_network = graph_from_edgelist(as.matrix(elite_following_df), directed = FALSE)
> V(bp_network)$type = ifelse(V(bp_network)$name %in% elite_following_df$following, TRUE, FALSE)
> length(E(bp_network))
[1] 267442

Upvotes: 0

Views: 823

Answers (1)

wrahool
wrahool

Reputation: 1141

The problem was that one of the edges was violating the bipartite property. In other words, one of the nodes that was meant to be type FALSE had an edge with another FALSE node. Leaving this answer instead of deleting the question just in case someone encounters the same error.

Upvotes: 3

Related Questions