Generate a random graph with the given joint degree and triangle degree sequence.
This uses a configuration model-like approach to generate a random pseudograph (graph with parallel edges and self loops) by randomly assigning edges to match the given indepdenent edge and triangle degree sequence.
Parameters : | joint_degree_sequence : list of integer pairs
create_using : graph, optional (default MultiGraph)
seed : hashable object, optional
|
---|---|
Returns : | G : MultiGraph
|
Raises : | NetworkXError :
|
Notes
As described by Miller [R226] (see also Newman [R227] for an equivalent description).
A non-graphical degree sequence (not realizable by some simple graph) is allowed since this function returns graphs with self loops and parallel edges. An exception is raised if the independent degree sequence does not have an even sum or the triangle degree sequence sum is not divisible by 3.
This configuration model-like construction process can lead to duplicate edges and loops. You can remove the self-loops and parallel edges (see below) which will likely result in a graph that doesn’t have the exact degree sequence specified. This “finite-size effect” decreases as the size of the graph increases.
References
[R226] | (1, 2) J. C. Miller “Percolation and Epidemics on Random Clustered Graphs.” Physical Review E, Rapid Communication (to appear). |
[R227] | (1, 2) M.E.J. Newman, “Random clustered networks”. Physical Review Letters (to appear). |
Examples
>>> deg_tri=[[1,0],[1,0],[1,0],[2,0],[1,0],[2,1],[0,1],[0,1]]
>>> G = nx.random_clustered_graph(deg_tri)
To remove parallel edges:
>>> G=nx.Graph(G)
To remove self loops:
>>> G.remove_edges_from(G.selfloop_edges())