Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
connected_double_edge_swap¶

connected_double_edge_swap
(G, nswap=1)[source]¶ Attempt nswap doubleedge swaps in the graph G.
A doubleedge swap removes two randomly chosen edges uv and xy and creates the new edges ux and vy:
uv u v becomes   xy x y
If either the edge ux or vy already exist no swap is performed so the actual count of swapped edges is always <= nswap
Parameters: G : graph
An undirected graph
nswap : integer (optional, default=1)
Number of doubleedge swaps to perform
Returns: G : int
The number of successful swaps
Notes
The initial graph G must be connected, and the resulting graph is connected. The graph G is modified in place.
References
[R278] C. Gkantsidis and M. Mihail and E. Zegura, The Markov chain simulation method for generating connected power law random graphs, 2003. http://citeseer.ist.psu.edu/gkantsidis03markov.html