Shortest path with a fixed number of edges

后端 未结 5 1298
陌清茗
陌清茗 2021-02-03 16:28

Find the shortest path through a graph in efficient time, with the additional constraint that the path must contain exactly n nodes.

We have a directed, weighte

5条回答
  •  攒了一身酷
    2021-02-03 16:59

    Interesting problem. Did you discuss using a heuristic graph search (such as A*), adding a penalty for going over or under the node count? This may or may not be admissible, but if it did work, it may be more efficient than keeping a list of all the potential paths.

    In fact, you may be able to use backtracking to limit the amount of memory being used for the Dijkstra variation you discussed.

提交回复
热议问题