eulerian_circuit(G, source=None, keys=False)
An Eulerian circuit is a closed walk that includes each edge of a graph exactly once.
This is a linear time implementation of an algorithm adapted from .
For general information about Euler tours, see .
A graph, either directed or undirected.
Starting node for circuit.
If False, edges generated by this function will be of the form (u, v)
. Otherwise, edges will be of the form (u, v, k)
. This option is ignored unless G
is a multigraph.
If the graph is not Eulerian.
An iterator over edges in the Eulerian circuit.
Returns an iterator over the edges of an Eulerian circuit in G
.
>>> G = nx.complete_graph(3) >>> list(nx.eulerian_circuit(G)) [(0, 2), (2, 1), (1, 0)] >>> list(nx.eulerian_circuit(G, source=1)) [(1, 2), (2, 0), (0, 1)]
See :>>> [u for u, v in nx.eulerian_circuit(G)] [0, 2, 1]
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.euler.eulerize
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