Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't come up with an eficcient way to, given a graph, find a path that crosses all edges, only once per each edge, and end in the same vertex that it started.

Can anyone point me in the right direction? I've been looking to do it using strongly-connected components (SCC), but even in a SCC, I can't guarantee, that I can cross all edges, and only once per each one. I can't remember, but I think there is a "standard" algorithm, that finds a path that crosses all edges once.

share|cite|improve this question
What you seek is called an Eulerian cycle, and the concept was popularized by the seven bridges of Königsberg problem. – Henning Makholm Feb 26 '12 at 21:51
Sounds like this: Eulerian path – draks ... Feb 26 '12 at 21:52
@HenningMakholm: If you have an answer, please answer, rather than commenting. For some reasons why:…. Note: this is just a request! – Aryabhata Feb 26 '12 at 21:53
@Aryabhata: Sure, just went to check whether there was a preëxisting duplicate before starting to type a long answer. But your links will do just as well, I think. – Henning Makholm Feb 26 '12 at 21:59

Seems like you are looking for an Euler Circuit, which has standard algorithms. For instance, see Hierholzer's algorithm.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.