Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Euler Path

12 views
Skip to first unread message

Popping mad

unread,
Feb 9, 2017, 11:30:09 PM2/9/17
to


Has anyone ever seen any standard code for a Euler Path?

Öö Tiib

unread,
Feb 10, 2017, 2:33:15 AM2/10/17
to
On Friday, 10 February 2017 06:30:09 UTC+2, Popping mad wrote:
> Has anyone ever seen any standard code for a Euler Path?

I have copy-pasted me such pseudo-code from somewhere:

compute_euler(G, path, is_circuit)
s := V[g][0] initialize the start vertex
if (is_circuit)
for each vertex u in V[G]
if (is_odd(u))
s := u choose an odd vertex if computing a path
break
end if
end for
end if
for each edge e in E[G] initialize edge colors
color[e] := WHITE
end for
tmp_vertex := null
PUSH(s, stack) push start vertex to stack
while (SIZE(stack) != 0)
u := TOP(stack)
edge_available := false
for each edge e in out_edges[u] search for an unused incident edge
if (color[e] == WHITE)
edge_available := true
color[e] := BLACK
neighbor := target(e)
PUSH(neighbor, stack) push the edge's target vertex to the stack
break
end if
end for
if (NOT(edge_available) if edge was unavailable, backtrack and add
if (tmp_vertex != null) to final path
edge := edge(tmp_vertex, u, G)
ADD(edge, path)
end if
tmp_vertex := u
POP(stack)
end if
end while
end
0 new messages