Skip to content

Commit 85422f4

Browse files
committed
leetcode
1 parent bef98ba commit 85422f4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Ch_4_4/_DijstraAllPairsSP.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package Ch_4_4;
2+
3+
/**
4+
* Created by HuGuodong on 5/16/20.
5+
*/
6+
public class _DijstraAllPairsSP {
7+
8+
private _DijkstraSP[] all;
9+
10+
public _DijstraAllPairsSP(_EdgeWeightedDigraph G) {
11+
all = new _DijkstraSP[G.V()];
12+
for (int v = 0; v < G.V(); v++) {
13+
all[v] = new _DijkstraSP(G, v);
14+
}
15+
}
16+
17+
public Iterable<_DirectedEdge> path(int s, int t) {
18+
return all[s].pathTo(t);
19+
}
20+
21+
public double dist(int s, int t) {
22+
return all[s].distTo(t);
23+
}
24+
}

0 commit comments

Comments
 (0)