This documents the development version of NetworkX. Documentation for the current release can be found here.
random_lobster(n, p1, p2, seed=None)¶
Returns a random lobster graph.
A lobster is a tree that reduces to a caterpillar when pruning all leaf nodes. A caterpillar is a tree that reduces to a path graph when pruning all leaf nodes; setting
p2to zero produces a caterpillar.
This implementation iterates on the probabilities
p2to add edges at levels 1 and 2, respectively. Graphs are therefore constructed iteratively with uniform randomness at each level rather than being selected uniformly at random from the set of all possible lobsters.
The expected number of nodes in the backbone
Probability of adding an edge to the backbone
Probability of adding an edge one level beyond backbone
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
p2parameters are >= 1 because the while loops would never finish.