Given an undirected weighted graph $G = (V, \{E,F\})$, how to find the shortest walk that passes through all edges $e \in E$ exactly once?
I'd like to know if there is a general approach to this problem. However, additional constraint may be added for my specific scenario.
The graph $G_0 = (V, E)$ initially has only edges that must be crossed, but it's disconnected:
- Each connected component is formed by 2 vertices and 1 edge.
- Each vertex $v$ is the endpoint of exactly one edge $\in E$. This means that any two edges $e_i, e_j \in E$ don't have a vertex $v$ in common.
- The cost of each edge $e \in E$ is $0$.
- The number of edges in $E$ is at most 1000, usually between 10 and 100.
Then other edges $f \in F$ are added with to link any two vertices (except the one already linked by $e$), so $G = (V, \{E,F\})$.
- The cost of each edge $f \in F$ is $> 0$
Related questions
I found a few related questions, but they doesn't seem to help:
- Shortest path from that passes through a set of edges once: edges $e \in E$ must be visited exactly once, not at most once.
- Shortest directed path connecting given subset of vertices, Minimum path between two vertices passing through a given set exactly once, Find the shortest path in a graph which visits certain nodes : the constraint is on edges, not on the vertices.
Not working solutions
I tried a few approaches so far, but I'm unable to make them work properly. E.g.:
- Convert $G$ to its line graph $L$. I can't figure out how to assign a proper weight to edges in $L$
- If I can find a proper way to construct $L$, adding a dummy vertex $s$ on $L$ allows to solve this with TSP. Then I'll know the order of the edges $e$, but not the direction.
- I really don't want to use brute-force. It may become impractical very soon.
Almost-Working solutions for the specific case
Since by construction every walk will be of the form: $e_1, f_1, e_2, ... f_n, e_n$:
Compute the weight of the path for each permutation of edges in $E$. The edge $f$ between two edges $e$ will be the mininmum weight one. Pick up the minimum weight path. This solution is brute-force, so not really practical for a large number of edges in E.
Start from an edge $e$. Follow the min-cost edge $f$ starting from the end-vertex in $e$. Repeat until all edges in $E$ are reached. This solution is not guaranteed to find the shortest path.