Using NetworkX
to determine cycles
in a graph it seems something is incorrect in the resulting list:
Setup
import networkx as nx
egs = [
[1, 2],
[2, 3],
[2, 4],
[2, 5],
[5, 6],
[5, 7],
[3, 8],
[3, 7],
[4, 9],
[4, 8],
[1, 9],
[1, 6]];
g = nx.Graph(egs)
cyc = nx.cycle_basis(g)
Results:
>>> cyc
[[2, 5, 6, 1], [2, 3, 7, 5], [9, 4, 8, 3, 7, 5, 6, 1], [2, 4, 8, 3]]
[9, 4, 8, 3, 7, 5, 6, 1]
is incorrect.
Am I missing a point or this is a bug in NetworkX
?