cycle_basis(G, root=None)
A basis for cycles of a network is a minimal collection of cycles such that any cycle in the network can be written as a sum of cycles in the basis. Here summation of cycles is defined as "exclusive or" of the edges. Cycle bases are useful, e.g. when deriving equations for electric circuits using Kirchhoff's Laws.
This is adapted from algorithm CACM 491 .
Returns a list of cycles which form a basis for cycles of G.
>>> G = nx.Graph()See :
... nx.add_cycle(G, [0, 1, 2, 3])
... nx.add_cycle(G, [0, 3, 4, 5])
... print(nx.cycle_basis(G, 0)) [[3, 4, 5, 0], [1, 2, 3, 0]]
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.cycles.minimum_cycle_basis
networkx.algorithms.cycles.recursive_simple_cycles
networkx.algorithms.cycles.cycle_basis
networkx.algorithms.cycles.simple_cycles
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them