Return a random pseudograph with the given degree sequence.
- deg_sequence: degree sequence, a list of integers with each entry
corresponding to the degree of a node (need not be sorted). A non-graphical degree sequence (i.e. one not realizable by some simple graph) will raise an Exception.
seed: seed for random number generator (default=None)
>>> from networkx.utils import powerlaw_sequence
>>> z=nx.create_degree_sequence(100,powerlaw_sequence)
>>> G=nx.configuration_model(z)
The pseudograph G is a networkx.MultiGraph that allows multiple (parallel) edges between nodes and self-loops (edges from a node to itself).
To remove parallel edges:
>>> G=nx.Graph(G)
Steps:
- Check if deg_sequence is a valid degree sequence.
- Create N nodes with stubs for attaching edges
- Randomly select two available stubs and connect them with an edge.
As described by Newman [newman-2003-structure].
Nodes are labeled 1,.., len(deg_sequence), corresponding to their position in deg_sequence.
This process can lead to duplicate edges and loops, and therefore returns a pseudograph type. You can remove the self-loops and parallel edges (see above) with the likely result of not getting the exat degree sequence specified. This “finite-size effect” decreases as the size of the graph increases.
References:
[newman-2003-structure] M.E.J. Newman, “The structure and function of complex networks”, SIAM REVIEW 45-2, pp 167-256, 2003.