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

double_edge_swap
(G, nswap=1, max_tries=100)[source]¶ Swap two edges in the graph while keeping the node degrees fixed.
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 and another attempt is made to find a suitable edge pair.
Parameters:  G (graph) – An undirected graph
 nswap (integer (optional, default=1)) – Number of doubleedge swaps to perform
 max_tries (integer (optional)) – Maximum number of attempts to swap edges
Returns: G – The graph after double edge swaps.
Return type: graph
Notes
Does not enforce any connectivity constraints.
The graph G is modified in place.