Search code examples
optimizationgraphcomplexity-theorypath-finding

Finding minimal paths that cover all edges at least once in directed graphs with cycles


I have a graph that's finite, directed, and strongly connected. I'd like to find paths of minimal length through this graph that visit every edge at least once.

Is there an isomorphism between this problem and any "standard" problem such as Travelling Salesman or finding Eulerian Paths in undirected graphs?


Solution

  • This is a well known problem, called the Route inspection problem, (also often called the "Chinese Postman Problem" in the literature) which in the general case finds a minimum length closed walk on an undirected graph that visits every edge at least once. This can be done in polynomial time; your specific problem asks for a strongly connected directed graph solution that does not need to return to its starting point (i.e. an open walk).

    There are a few papers describing algorithms for the directed, closed walk problem based on reductions from Eulerian Tours, or from Minimum-cost flow problems, which result in O(|V|^3) solutions. This paper on the directed Chinese postman problem gives full Java code for both the open and closed walk version, and gives the basic idea for how they modified the closed walk program for the open walk variant:

    Imagine that the optimal open solution starts at vertex u and finishes at v. The open solution can be obtained from a closed solution, found by introducing a new ‘virtual’ arc (v,u), provided the cost associated with this arc is so high that it is used only once in the closed tour

    The paper does not mention the runtime of the algorithm beyond it being polynomial; however the closed walk version is O(n^3), and the open version is O(n^5). A lot of the complexity comes from how general the algorithm is: it can handle multiple edges and real numbered weights (including some negative edges), so more specific problems can be solved more efficiently. The start of the paper also gives a link to the author's website with a Mathematica implementation.