networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaises
random_lobster(n, p1, p2, seed=None)

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 :None:None:`p2` to zero produces a caterpillar.

This implementation iterates on the probabilities :None:None:`p1` and :None:None:`p2` to 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.

Parameters

n : int

The expected number of nodes in the backbone

p1 : float

Probability of adding an edge to the backbone

p2 : float

Probability of adding an edge one level beyond backbone

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

Raises

NetworkXError

If :None:None:`p1` or :None:None:`p2` parameters are >= 1 because the while loops would never finish.

Returns a random lobster graph.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/generators/random_graphs.py#1037
type: <class 'function'>
Commit: