Random Module
Random graph generators for stochastic network models.
Functions and values
| Function or value |
Description
|
||
|
Barabási-Albert model: creates scale-free networks via preferential attachment. Generates a random graph with a power-law degree distribution (scale-free). New nodes preferentially attach to existing high-degree nodes ("rich get richer"). Time Complexity: O(n * m * average_degree)
Parameters
Example
Properties
Use Cases
val ba: obj
|
||
|
Erdős-Rényi G(n, m) model: exactly m edges are added uniformly at random. Unlike G(n, p) which includes each edge independently with probability p, G(n, m) guarantees exactly m edges in the resulting graph. Time Complexity: O(m) expected
Parameters
Example
Properties
Use Cases
val graph: obj
|
||
|
Erdős-Rényi G(n, p) model: each edge exists with probability p. Generates a random graph where each possible edge is included independently with probability p. For undirected graphs, each unordered pair is considered once. Time Complexity: O(n²)
Parameters
Example
Properties
Use Cases
val sparse: obj
val dense: obj
|
||
|
Generates a uniformly random tree on n nodes. Creates a tree by starting with node 0 and repeatedly connecting new nodes to random nodes already in the tree. This produces a uniform distribution over all labeled trees. Time Complexity: O(n²) expected
Example
Properties
Use Cases
val tree: obj
|
||
|
Watts-Strogatz model: small-world network (ring lattice + rewiring). Generates a graph with both high clustering (like regular lattices) and short path lengths (like random graphs). Starts with a ring lattice and rewires edges with probability p. Time Complexity: O(n * k)
Parameters
Example
Properties
Use Cases
val sw: obj
|