I'm working on finding an Euler circuit for an indoor geographical 2D grid. when abstracting the grid as a an undirected graph, all nodes in the graph are connected (i.e, there is a path between every node in the graph). The graph could be huge (more than 100,000) nodes. The requirements are simple :

1- The generated path has to pass by every edge in the graph in both directions.

2- I need to minimize the number of times any edge appears in the generated path, such that the Optimal solution is a path that would include each edge ONLY once for each direction.

First Approach

I abstracted the problem as an undirected graph, for which I have to find an Euler circuit in one direction. I did so for simplicity. If I was able to produce a path that would include every edge in one direction, I could simply reverse that path and hence meet the requirement of generating a path that covers the edges of the graph in both directions. Since I was looking for an optimal solution (minimizing the number of edges after including them at-least once), I planned the following steps:

1- 10 percent of the nodes had an odd degree (about 10,000 nodes!), therefore, I had to employ a matching algorithm to find the shortest mutually disjoint paths between pairs of odd nodes such that the sum of the distance between pairs is minimized. In other words, using a variation of blossom algorithm http://web.eecs.umich.edu/~pettie/matching/Edmonds-Johnson-chinese-postman.pdf

2- After adding the artificial edges between odd pairs, the nodes of the graph are all of even degree. Find the Euler circuit for the graph.

3- Include a reverse version of the generated path to the final solution.

Issues with first approach

Understanding and Implementing J.Edmond's algorithm (blossom algorithm) is a tedious task. More importantly, the solution is still not optimal (several edges are covered more than once due to pairing of odd nodes).

Second Approach

1- Abstracting the grid as a directed graph, simply by doubling the edges of each node of the graph (i.e, one edge from node A->B and the other B->A). Hence, guaranteeing that all nodes are of even degree, such that the number of incoming edges of every node is equal to the number of outgoing edges.

2- Finding an Euler Circuit for the directed graph. The optimal solution (which is an Euler circuit that exists) is in this case double the summation of all edges.

My question is simple. Before I get too excited, are there any shortcomings to the second approach ?. Does the second approach (directed graph) meet the requirements of an Euler circuit ?

  • $\begingroup$ I'm confused by what your question is. A Euler circuit by definition visits each edge exactly once. I don't understand what you mean by "minimizing the number of times the edge appears in the solution"; if you're trying to construct a Euler circuit, by definition this number is minimized. There are standard algorithms to generate an Euler circuit, and they run in linear time, so they should be very efficient. Also it's known that an undirected graph with odd-degree verticies does not contain an Euler circuit. $\endgroup$ – D.W. Apr 24 '17 at 19:36
  • $\begingroup$ Are you sure you're looking for an Euler circuit? Perhaps you're looking for something that is similar to a Euler circuit but not identical? $\endgroup$ – D.W. Apr 24 '17 at 19:37
  • $\begingroup$ I understand that by definition an Euler Circuit passes by each edge only once. However, in an undirected graph with ODD degree nodes, matching algorithms are required to pair these nodes. If the matching algorithm results in non-disjoint paths, then the solution is not optimal. $\endgroup$ – Anas Mahmoud Apr 24 '17 at 20:31
  • $\begingroup$ "Also it's known that an undirected graph with odd-degree verticies does not contain an Euler circuit." This is complemented by matching algorithms like "blossom algorithm" to add artificial edges between odd nodes which results in a Eulerian graph. For reference check J.Edmonds algorithm (Blossom algorithm) web.eecs.umich.edu/~pettie/matching/… $\endgroup$ – Anas Mahmoud Apr 24 '17 at 20:34
  • $\begingroup$ In an undirected graph with odd-degree nodes, there is no Euler circuit. You don't get "add edges". It sounds like you haven't fully described the problem. Perhaps you are allowing us to add extra edges, so the goal is not to find a Euler circuit in the graph $G$ provided as input but to find a Euler circuit in some graph $G'$ (which we can construct by starting with $G$ and adding some edges of our choice), maybe? If so, you haven't mentioned this degree of freedom. Please edit to clarify what what exactly the task is. What are the inputs? What are the desired outputs? $\endgroup$ – D.W. Apr 24 '17 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.