nimnet/algorithms/swaps

Degree-preserving edge swaps and walk counting for nimnet

Procs

proc connectedDoubleEdgeSwap[N](g: var Graph[N]; nswap: int = 1; seed: int = 0)
Perform double edge swaps while maintaining connectivity.
proc doubleEdgeSwap[N](g: var Graph[N]; nswap: int = 1; maxTries: int = 100;
                       seed: int = 0)
Perform nswap random double edge swaps that preserve degree sequence. A double edge swap: (u,v) and (x,y) → (u,x) and (v,y) (or (u,y) and (v,x)).
proc numberOfWalks[N](g: Graph[N]; length: int): Table[(N, N), int]
Count the number of walks of a given length between all pairs of nodes. Uses matrix exponentiation: (A^k)_{ij} = number of walks of length k from i to j.