To specify a Chung-Lu graph, you must specify
the degree-heterogeneity parameters (via n
or theta
).
We provide reasonable defaults to enable rapid exploration
or you can invest the effort
for more control over the model parameters. We strongly recommend
setting the expected_degree
or expected_density
argument
to avoid large memory allocations associated with
sampling large, dense graphs.
chung_lu(
n = NULL,
theta = NULL,
...,
sort_nodes = TRUE,
poisson_edges = TRUE,
allow_self_loops = TRUE,
force_identifiability = FALSE
)
An undirected_chung_lu
S3 object, a subclass of dcsbm()
.
(degree heterogeneity) The number of nodes in the graph.
Use when you don't want to specify the degree-heterogeneity
parameters theta
by hand. When n
is specified, theta
is randomly generated from a LogNormal(2, 1)
distribution.
This is subject to change, and may not be reproducible.
n
defaults to NULL
. You must specify either n
or theta
, but not both.
(degree heterogeneity) A numeric vector
explicitly specifying the degree heterogeneity
parameters. This implicitly determines the number of nodes
in the resulting graph, i.e. it will have length(theta)
nodes.
Must be positive. Setting to a vector of ones recovers
an erdos renyi graph.
Defaults to NULL
. You must specify either n
or theta
,
but not both.
Arguments passed on to undirected_factor_model
expected_degree
If specified, the desired expected degree
of the graph. Specifying expected_degree
simply rescales S
to achieve this. Defaults to NULL
. Do not specify both
expected_degree
and expected_density
at the same time.
expected_density
If specified, the desired expected density
of the graph. Specifying expected_density
simply rescales S
to achieve this. Defaults to NULL
. Do not specify both
expected_degree
and expected_density
at the same time.
Logical indicating whether or not to sort the nodes
so that they are grouped by block and by theta
. Useful for plotting.
Defaults to TRUE
.
Logical indicating whether or not
multiple edges are allowed to form between a pair of
nodes. Defaults to TRUE
. When FALSE
, sampling proceeds
as usual, and duplicate edges are removed afterwards. Further,
when FALSE
, we assume that S
specifies a desired between-factor
connection probability, and back-transform this S
to the
appropriate Poisson intensity parameter to approximate Bernoulli
factor connection probabilities. See Section 2.3 of Rohe et al. (2017)
for some additional details.
Logical indicating whether or not
nodes should be allowed to form edges with themselves.
Defaults to TRUE
. When FALSE
, sampling proceeds allowing
self-loops, and these are then removed after the fact.
Logical indicating whether or not to
normalize theta
such that it sums to one within each block. Defaults
to FALSE
, since this behavior can be surprise when theta
is set
to a vector of all ones to recover the DC-SBM case.
Other undirected graphs:
dcsbm()
,
erdos_renyi()
,
mmsbm()
,
overlapping_sbm()
,
planted_partition()
,
sbm()
set.seed(27)
cl <- chung_lu(n = 1000, expected_density = 0.01)
cl
theta <- round(stats::rlnorm(100, 2))
cl2 <- chung_lu(
theta = theta,
expected_degree = 5
)
cl2
edgelist <- sample_edgelist(cl)
edgelist
Run the code above in your browser using DataLab