function findEulerPath(graph, start):
stack = [start]
path = []
while stack is not empty:
v = stack.top()
if v has unused edges:
u = any neighbor with unused edge
mark edge (v, u) as used
stack.push(u)
else:
path.append(stack.pop())
return path.reversed()
For undirected graphs, mark both directions when using an edge.
Time: since each edge is visited exactly once. Space: for the stack and path.
Space complexity is for the data structures used.