Блог пользователя Tatsugiri

Автор Tatsugiri, история, 2 года назад, По-английски

Given an undirected graph with positive cost number on each edge, I need to calculate shortest path from p1 to pn node visiting a certain node pk(pk is not a start or end node).

The main problem is in restriction that the solution path should not visit any node more than once. Because of that, there may be no solution at all.

Is there any polynomial-time algorithm to solve the problem, or can it be proven np-hard?

  • Проголосовать: нравится
  • +18
  • Проголосовать: не нравится

»
2 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

DFS? Find all the paths passing through $$$p_k$$$ and ending at $$$p_n$$$ and get the minimum cost/weight of all paths.

»
2 года назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

just two dijkstras: d(1,k)+d(k,n) ?

»
2 года назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Seems like it can be solved with mincostflow approach, there are two units which go from source to start and end vertices and two units can be transfered from vertex pk to target, you need to find min cost max flow while the cost of transfering one unit between vertices is 1, except source and target vertices. (Sorry for bad english)