NetworkX

Previous topic

networkx.double_edge_swap

Next topic

networkx.li_smax_graph

Quick search

networkx.connected_double_edge_swap

connected_double_edge_swap(G, nswap=1)

Attempt nswap double-edge swaps on the graph G.

Returns count of successful swaps. Enforces connectivity. The graph G is modified in place.

A double-edge swap removes two randomly choseen 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

The initial graph G must be connected and the resulting graph is connected.

Reference:

@misc{gkantsidis-03-markov,
 author = "C. Gkantsidis and M. Mihail and E. Zegura",
 title = "The Markov chain simulation method for generating connected
          power law random graphs",
 year = "2003",
 url = "http://citeseer.ist.psu.edu/gkantsidis03markov.html"
}