I have an edgelist for a two mode network, similar to this:
person Event
Amy football_game
Sam picnic
Bob art_show
I want to p
In igraph a bipartite network is one that has a type
vertex attribute. This attribute must be logical and must the TRUE
for one of the node types and FALSE
for the others. So to create a bipartite network from your edge list, you simply create a regular graph and then add the type
vertex attribute:
edgelist <- read.table(text="Person Event
Amy football
Bob picnic
Sam artshow",
header=TRUE)
igraph <- graph.data.frame(edgelist)
V(igraph)$type <- V(igraph)$name %in% edgelist[,1]
igraph
# IGRAPH DN-B 6 3 --
# + attr: name (v/c), type (v/x)
The 'B' letter tells you that this is a bipartite graph. You can create the unipartite projections of this network via:
bipartite.projection(igraph)
# $proj1
# IGRAPH UN-B 3 0 --
# + attr: name (v/c), type (v/x)
#
# $proj2
# IGRAPH UN-B 3 0 --
# + attr: name (v/c), type (v/x)
This will return a list of two graphs. If you think that the projection might be too big, you can first call the bipartite.projection.size
function, this will give you the number of vertices and edges in both projections. The memory requirement for an igraph graph is (4m+2n)*8+O(1) bytes, where 'n' is the number of vertices and 'm' is the number of edges.