NetworkX

Previous topic

union

Next topic

pareto_sequence

create_degree_sequence

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

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, create_degree_sequence
>>> seq=create_degree_sequence(10,uniform_sequence)