算法:通过m个不同节点的最短路径

Algorithm: shortest path that passes through m different nodes

假设我有一个带 n 个顶点的加权图,并且给出了起点。最短路径定义为权重总和最小的路径。

如何找出通过m个不同顶点的最短路径? (每个顶点可以被访问一次或多次,即访问过的顶点集合中恰好有m个顶点,但每个顶点可能被访问过多次。)

请注意,给出了数字 m,但没有给出具体的 m 个顶点。 (这m个顶点是算法选出来的)

这是一个 NP-Hard 问题吗?

我们可以减少 Hamiltonian Path Problem (HPP) to your problem: a Hamiltonian Path is a path in a directed unweighted graph that visits each vertex exactly once. To solve an instance of HPP, convert the graph into a weighted graph with weight 1 on every edge, set m to be |V| and solve your problem. This is a polynomial-time reduction,所以你的问题是 NP-hard,因为 HPP 是 NP-complete。

它也是 NP 完全的,因为它显然属于 NP。因此,从您的问题到任何其他 NP 完全问题,也存在多项式时间减少。解决旅行商问题的算法可能最适合您:请参阅此处 details and examples