MCPcopy
hub / github.com/networkx/networkx / _simplegraph_eulerian_circuit

Function _simplegraph_eulerian_circuit

networkx/algorithms/euler.py:112–131  ·  view source on GitHub ↗
(G, source)

Source from the content-addressed store, hash-verified

110
111
112def _simplegraph_eulerian_circuit(G, source):
113 if G.is_directed():
114 degree = G.out_degree
115 edges = G.out_edges
116 else:
117 degree = G.degree
118 edges = G.edges
119 vertex_stack = [source]
120 last_vertex = None
121 while vertex_stack:
122 current_vertex = vertex_stack[-1]
123 if degree(current_vertex) == 0:
124 if last_vertex is not None:
125 yield (last_vertex, current_vertex)
126 last_vertex = current_vertex
127 vertex_stack.pop()
128 else:
129 _, next_vertex = arbitrary_element(edges(current_vertex))
130 vertex_stack.append(next_vertex)
131 G.remove_edge(current_vertex, next_vertex)
132
133
134def _multigraph_eulerian_circuit(G, source):

Callers 2

eulerian_circuitFunction · 0.85
eulerian_pathFunction · 0.85

Calls 7

degreeFunction · 0.85
arbitrary_elementFunction · 0.85
edgesFunction · 0.85
appendMethod · 0.80
is_directedMethod · 0.45
popMethod · 0.45
remove_edgeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…