NetworkX

Previous topic

networkx.create_degree_sequence

Next topic

networkx.connected_double_edge_swap

Quick search

networkx.double_edge_swap

double_edge_swap(G, nswap=1)

Attempt nswap double-edge swaps on the graph G.

Return count of successful swaps. 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

Does not enforce any connectivity constraints.