
Last chance! 50% off unlimited learning
Sale ends in
degree.sequence.game
does.degree.sequence.game(out.deg, in.deg = NULL,
method = c("simple", "vl", "simple.no.multiple"), ...)
in.deg
.NULL
and an undirected graph is created. The in.deg
argument to it.
The algorithm relies on first creating an initial (possibly
unconnected) simple undirected graph with the given degree sequence
(if this is possible at all). Then some rewiring is done to make the
graph connected. Finally a Monte-Carlo algorithm is used to randomize
the graph. The
erdos.renyi.game
, barabasi.game
,
simplify
to get rid of the multiple and/or loops edges.## The simple generator
g <- degree.sequence.game(rep(2,100))
degree(g)
is.simple(g) # sometimes TRUE, but can be FALSE
g2 <- degree.sequence.game(1:10, 10:1)
degree(g2, mode="out")
degree(g2, mode="in")
## The vl generator
g3 <- degree.sequence.game(rep(2,100), method="vl")
degree(g3)
is.simple(g3) # always TRUE
## Exponential degree distribution
## Note, that we correct the degree sequence if its sum is odd
degs <- sample(1:100, 100, replace=TRUE, prob=exp(-0.5*(1:100)))
if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
g4 <- degree.sequence.game(degs, method="vl")
all(degree(g4) == degs)
## Power-law degree distribution
## Note, that we correct the degree sequence if its sum is odd
degs <- sample(1:100, 100, replace=TRUE, prob=(1:100)^-2)
if (sum(degs) %% 2 != 0) { degs[1] <- degs[1] + 1 }
g5 <- degree.sequence.game(degs, method="vl")
all(degree(g5) == degs)
Run the code above in your browser using DataLab