Cycle basis and simple cycle algorithms.
Procs
proc cycleBasis[N](g: Graph[N]): seq[seq[N]]
- Return a list of cycles forming a basis for the cycle space. Each non-tree edge in a BFS spanning tree defines one fundamental cycle.
proc minimumCycleBasis[N](g: Graph[N]): seq[seq[N]]
- Return a minimum weight cycle basis of the graph. Uses Horton's algorithm: for each edge, find shortest path between endpoints excluding the edge, producing a candidate cycle. Then selects linearly independent cycles by Gaussian elimination over GF(2) (using edge incidence vectors).
proc simpleCyclesDirected[N](g: DiGraph[N]): seq[seq[N]]
- Return all simple cycles in a directed graph using Johnson's algorithm. Warning: can be exponential in the number of cycles.