Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Eulerian path
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Hierholzer's algorithm === [[Carl Hierholzer|Hierholzer]]'s 1873 paper provides a different method for finding Euler cycles that is more efficient than Fleury's algorithm: *Choose any starting vertex ''v'', and follow a trail of edges from that vertex until returning to ''v''. It is not possible to get stuck at any vertex other than ''v'', because the even degree of all vertices ensures that, when the trail enters another vertex ''w'' there must be an unused edge leaving ''w''. The tour formed in this way is a closed tour, but may not cover all the vertices and edges of the initial graph. *As long as there exists a vertex ''u'' that belongs to the current tour but that has adjacent edges not part of the tour, start another trail from ''u'', following unused edges until returning to ''u'', and join the tour formed in this way to the previous tour. *Since we assume the original graph is [[connected graph|connected]], repeating the previous step will exhaust all edges of the graph. By using a data structure such as a [[doubly linked list]] to maintain the set of unused edges incident to each vertex, to maintain the list of vertices on the current tour that have unused edges, and to maintain the tour itself, the individual operations of the algorithm (finding unused edges exiting each vertex, finding a new starting vertex for a tour, and connecting two tours that share a vertex) may be performed in constant time each, so the overall algorithm takes [[linear time]], <math>O(|E|)</math>.<ref>{{citation|title=Eulerian Graphs and Related Topics: Part 1, Volume 2|volume=50|series=Annals of Discrete Mathematics|first=Herbert|last=Fleischner|publisher=Elsevier|year=1991|isbn=978-0-444-89110-5|contribution=X.1 Algorithms for Eulerian Trails|pages=[https://archive.org/details/euleriangraphsre0001flei/page/ X.1β13]|url=https://archive.org/details/euleriangraphsre0001flei/page/}}.</ref> This algorithm may also be implemented with a [[Double-ended queue|deque]]. Because it is only possible to get stuck when the deque represents a closed tour, one should rotate the deque by removing edges from the tail and adding them to the head until unstuck, and then continue until all edges are accounted for. This also takes linear time, as the number of rotations performed is never larger than <math>|E|</math> (intuitively, any "bad" edges are moved to the head, while fresh edges are added to the tail) {{Hamiltonian_platonic_graphs.svg}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)