(G, source)
| 110 | |
| 111 | |
| 112 | def _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 | |
| 134 | def _multigraph_eulerian_circuit(G, source): |
no test coverage detected
searching dependent graphs…