degree_sequence_tree#
- degree_sequence_tree(deg_sequence, create_using=None)[source]#
Return a tree with the given degree sequence.
Two conditions must be met for a degree sequence to be valid for a tree:
The number of nodes must be one more than the number of edges.
The degree sequence must be trivial or have only strictly positive node degrees.
- Parameters:
- degree_sequenceiterable
Iterable of node degrees.
- create_usingNetworkX graph constructor, optional (default=nx.Graph)
Graph type to create. If graph instance, then cleared before populated.
- Returns:
- networkx.Graph
A tree with the given degree sequence.
- Raises:
- NetworkXError
If the degree sequence is not valid for a tree.
If
create_using
is directed.
See also