Skip to content

Commit 0341a16

Browse files
committed
format AllPairShortestPath
1 parent 268f2f9 commit 0341a16

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Algorithms/AllPairShortestPath.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,18 @@ public A(boolean stdIO)throws FileNotFoundException{
4141
out = new PrintWriter(outputStream);
4242
}
4343

44+
final int MAX_N = 100;
45+
long cost[][] = new long[MAX_N + 1][MAX_N + 1];
46+
long w[][] = new long[MAX_N + 1][MAX_N + 1];
47+
48+
4449
void run()throws Exception{
4550
int n = i();
4651
int ans = 0;
4752

4853
out.write(""+ans+"\n");
4954

5055
}
51-
52-
final int MAX_N = 100;
53-
long cost[][] = new long[MAX_N + 1][MAX_N + 1];
54-
long w[][] = new long[MAX_N + 1][MAX_N + 1];
5556

5657

5758
void clear(){
@@ -71,14 +72,13 @@ void allPairShortestPath(int n){
7172
}
7273
// order matters: k->i->j
7374
for(int k = 1; k <= n; k++){
74-
for (int i = 1; i <= n; i++){
75-
for (int j = 1; j <= n; j++){
76-
77-
if(cost[i][k] + cost[k][j] < cost[i][j]){
78-
cost[i][j] = cost[i][k] + cost[k][j];
79-
}
80-
}
75+
for (int i = 1; i <= n; i++){
76+
for (int j = 1; j <= n; j++){
77+
if(cost[i][k] + cost[k][j] < cost[i][j]){
78+
cost[i][j] = cost[i][k] + cost[k][j];
79+
}
8180
}
81+
}
8282
}
8383
}
8484

0 commit comments

Comments
 (0)