NetworkX

Previous topic

networkx.generators.degree_seq.is_valid_degree_sequence

Next topic

networkx.generators.degree_seq.double_edge_swap

networkx.generators.degree_seq.create_degree_sequence

create_degree_sequence(n, sfunction=None, max_tries=50, **kwds)

Attempt to create a valid degree sequence of length n using specified function sfunction(n,**kwds).

Parameters:

n : int

Length of degree sequence = number of nodes

sfunction: function :

Function which returns a list of n real or integer values. Called as “sfunction(n,**kwds)”.

max_tries: int :

Max number of attempts at creating valid degree sequence.

Notes

Repeatedly create a degree sequence by calling sfunction(n,**kwds) until achieving a valid degree sequence. If unsuccessful after max_tries attempts, raise an exception.

For examples of sfunctions that return sequences of random numbers, see networkx.Utils.

Examples

>>> from networkx.utils import uniform_sequence
>>> seq=nx.create_degree_sequence(10,uniform_sequence)