Trait-based random generationSource:
Generation of random graphs based on different vertex types.
sample_pref( nodes, types, type.dist = rep(1, types), fixed.sizes = FALSE, pref.matrix = matrix(1, types, types), directed = FALSE, loops = FALSE ) pref(...) sample_asym_pref( nodes, types, type.dist.matrix = matrix(1, types, types), pref.matrix = matrix(1, types, types), loops = FALSE ) asym_pref(...)
The number of vertices in the graphs.
The number of different vertex types.
The distribution of the vertex types, a numeric vector of length ‘types’ containing non-negative numbers. The vector will be normed to obtain probabilities.
Fix the number of vertices with a given vertex type label. The
type.distargument gives the group sizes (i.e. number of vertices with the different labels) in this case.
A square matrix giving the preferences of the vertex types. The matrix has ‘types’ rows and columns. When generating an undirected graph, it must be symmetric.
Logical constant, whether to create a directed graph.
Logical constant, whether self-loops are allowed in the graph.
Passed to the constructor,
The joint distribution of the in- and out-vertex types.
Both models generate random graphs with given vertex types. For
sample_pref() the probability that two vertices will be connected
depends on their type and is given by the ‘pref.matrix’ argument.
This matrix should be symmetric to make sense but this is not checked. The
distribution of the different vertex types is given by the
sample_asym_pref() each vertex has an in-type and an
out-type and a directed graph is created. The probability that a directed
edge is realized from a vertex with a given out-type to a vertex with a
given in-type is given in the ‘pref.matrix’ argument, which can be
asymmetric. The joint distribution for the in- and out-types is given in the
The types of the generated vertices can be retrieved from the
type vertex attribute for
sample_pref() and from the
outtype vertex attribute for
Random graph models (games)