简体   繁体   中英

The shortest combination of paths that starts and ends with a single node and covers all points in an undirected graph

I need an algorithm(k, s) where

  • k is the number of paths
  • s is the starting and ending node

and given n number of nodes in an undirected graph in which all nodes are linked to each other, returns k paths to traverse all nodes of which the sum of distances covered by the k paths is the shortest.

Eg Given n = 10 , algorithm(2,5) might give me an array of two arrays such that the sum of the distances covered by the two paths are the shortest and that all nodes are traversed.

[[5,1,2,3,10,5],[5,4,6,7,8,9,5]]

Djikstra's algorithm finds the shortest path from one node to another, but not the shortest combination of k paths.

Yen's algorithm finds k number of shortest paths from one node to another, but not the shortest combination of k paths.

What algorithm can help me find the shortest combination of k paths that starts and end with node s such that all n nodes are covered?

What you are describing above, is the classical Traveling Sales Man problem, many optimization techniques. One such is Ant Colony Optimization .

There are many libraries that implement ACO, you could find one for Ruby, as it stands, there are no easy solutions to Traveling Salesman Problem with classical (mathematical) approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM