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


connected_double_edge_swap(G, nswap=1)[source]

Attempt nswap double-edge swaps in the graph G.

A double-edge swap removes two randomly chosen edges u-v and x-y and creates the new edges u-x and v-y:

u--v            u  v
       becomes  |  |
x--y            x  y

If either the edge u-x or v-y 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 double-edge swaps to perform

Returns :

G : int

The number of successful swaps


The initial graph G must be connected, and the resulting graph is connected. The graph G is modified in place.


[R272]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