Almost broken my head while trying to find algorithm that finds fastest route in graph that pass through ALL graph vertices from start vertex (with no need to return to start edge).
I have checked all the main algorithms for graphs and similar problems on stackoverflow.
Almost all TSP examples I googled was for complete graphs.
TSPLIB not looks like can solve my problem.
Sorry if I missed something.
Input graph (check images):
• Weighted
• Undirected
• Planar
• No hamiltonian path
• No negative edges
• Size: up to 100 vertices (but usually 50-70)
Edge length almost the same in graph, so we can say that this is an unweighted graph and take 1 as a length of edge.
Should solve with "dead end" cases:
Real input graphs looks like this (start from vertex 0):
Big graph:
Expected result:
• Shortest path (a set of vertices indices) through all the edges from start edge.
• No need to return to start edge at the end
Got only one idea:
1) Check all possible combinations of path, measure the distance and find the path with smallest distance.
1a) Use Depth-First Search or Breadth-First Search
1b) If while iterating the current vertex have more than one edge - make a separate combinations for all of them (try all possible ways).
1c) In my case there are a lot of “dead end” in graph, so algorithm should find the way (the fastest ofc) from there and iterate through already passed vertices and not get stuck.
2) Reconstruct the path
Maybe I should use Minimum Spanning Trees algorithm here too…
Or maybe for faster calculation I should split my graph to multiple smallest that are linked only with single edge (like 49-52, 40-41 on screenshot)
Any help will be appreciated.
Prefer C# examples (libs) but I can port code from any language.