random_powerlaw_tree_sequence#
- random_powerlaw_tree_sequence(n, gamma=3, seed=None, tries=100)[source]#
Returns a degree sequence for a tree with a power law distribution.
- Parameters:
- nint,
The number of nodes.
- gammafloat
Exponent of the power law.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
- triesint
Number of attempts to adjust the sequence to make it a tree.
- Raises:
- NetworkXError
If no valid sequence is found within the maximum number of attempts.
Notes
A trial power law degree sequence is chosen and then elements are swapped with new elements from a power law distribution until the sequence makes a tree (by checking, for example, that the number of edges is one smaller than the number of nodes).