Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def eulerian_circuit(graph):
- trail = []
- for edge in graph:
- graph.sort()
- a,b = edge
- if not trail:
- trail.append(a)
- trail.append(b)
- graph.remove((a,b))
- print(graph)
- if a == trail[-1]:
- trail.append(b)
- graph.remove((a,b))
- print(graph)
- if not graph:
- return trail
- eulerian_circuit(graph)
- return trail,graph
- eulerian_circuit([('a','b'), ('b','c'), ('a','f'), ('b','d'), ('d','f'), ('b','e'), ('e','g'), ('c','g'), ('f','g'), ('f','h'), ('g','h')])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement