This documents the development version of NetworkX. Documentation for the current release can be found here.
connected_double_edge_swap(G, nswap=1, _window_threshold=3, seed=None)¶
Attempts the specified number of double-edge swaps in the graph
A double-edge swap removes two randomly chosen edges
(x, y)and creates the new edges
u--v u v becomes | | x--y x y
(v, y)already exist, then no swap is performed so the actual number of swapped edges is always at most
An undirected graph
- nswapinteger (optional, default=1)
Number of double-edge swaps to perform
The window size below which connectedness of the graph will be checked after each swap.
The “window” in this function is a dynamically updated integer that represents the number of swap attempts to make before checking if the graph remains connected. It is an optimization used to decrease the running time of the algorithm in exchange for increased complexity of implementation.
If the window size is below this threshold, then the algorithm checks after each swap if the graph remains connected by checking if there is a path joining the two nodes whose edge was just removed. If the window size is above this threshold, then the algorithm performs do all the swaps in the window and only then check if the graph is still connected.
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
The number of successful swaps
If the input graph is not connected, or if the graph has fewer than four nodes.
The initial graph
Gmust be connected, and the resulting graph is connected. The graph
Gis modified in place.
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