Find shortest path from Vertex u to v passing through a vertex w?
问题 In a directed graph with non-negative edge weights I can easily find shortest path from u to v using dijkstra's. But is there any simple tweak to Dijkstra's so that I can find shortest path from u to v through a given vertex w. Or any other algorithm suggestions? 回答1: Find the shortest path from u to w, then the shortest path from w to v. 回答2: Find shortest path from u to w Find shortest path from w to v Then u->w->v is the shortest path. You can do it by running Dijkstra for two times, but