'How do I create a random bipartite graph with fixed degree sequence?
I would like generate a random bipartite graph with a fixed degree sequence in igraph or other r package. I am familiar with how to generate a random graph with a fixed degree sequence and how to generate random bipartite graph in igraph--but I cannot sort out how to generate a random bipartite graph with a fixed degree sequence (as described by Newman, Watts and Strogatz (2002)).
Solution 1:[1]
We can use sample_degseq
by defining out.degree
and in.degree
(borrowing data from the answer by @Szabolcs)
sample_degseq(c(deg1, 0 * deg2), c(0 * deg1, deg2)) %>%
set_vertex_attr(name = "type", value = degree(., mode = "out") > 0) %>%
plot(layout = layout_as_bipartite)
which produces a graph like below
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |