Skip to content

Commit c2cf995

Browse files
committed
Lint code using google java linter
1 parent 90afad2 commit c2cf995

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

src/java/FloydWarshall.java

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
/*
2-
* Floyd-Warshall algorithm in Java
3-
* All pairs shortest path algorithm
4-
* Time Complexity: O(n³)
5-
* Space Complexity: O(n²)
2+
* Floyd-Warshall algorithm in Java
3+
* All pairs shortest path algorithm
4+
* Time Complexity: O(n³)
5+
* Space Complexity: O(n²)
66
*/
77

88
public class FloydWarshall {
99

10-
public static void showMatrix(long[][] matriz, int nroVertices) {
11-
for (int i = 0; i < nroVertices; i++) {
12-
for (int j = 0; j < nroVertices; j++) {
13-
if (matriz[i][j] < 10) {
14-
System.out.print(" " + matriz[i][j] + " ");
15-
} else {
16-
System.out.print(matriz[i][j] + " ");
17-
}
18-
}
19-
System.out.println();
10+
public static void showMatrix(long[][] matriz, int nroVertices) {
11+
for (int i = 0; i < nroVertices; i++) {
12+
for (int j = 0; j < nroVertices; j++) {
13+
if (matriz[i][j] < 10) {
14+
System.out.print(" " + matriz[i][j] + " ");
15+
} else {
16+
System.out.print(matriz[i][j] + " ");
2017
}
21-
System.out.println();
18+
}
19+
System.out.println();
2220
}
21+
System.out.println();
22+
}
2323

24-
public static void main(String[] args) {
25-
int nroVertices = 5;
26-
long[][] matriz = {
27-
{ 0, 2, 10, 5, 7 },
28-
{ 2, 0, 3, 3, 1 },
29-
{ 10, 3, 0, 1, 2 },
30-
{ 5, 3, 1, 0, Long.MAX_VALUE },
31-
{ 7, 1, 2, 2, 0 }
32-
};
24+
public static void main(String[] args) {
25+
int nroVertices = 5;
26+
long[][] matriz = {
27+
{0, 2, 10, 5, 7},
28+
{2, 0, 3, 3, 1},
29+
{10, 3, 0, 1, 2},
30+
{5, 3, 1, 0, Long.MAX_VALUE},
31+
{7, 1, 2, 2, 0}
32+
};
3333

34-
// Display the original matrix
35-
System.out.println("Original matrix:");
36-
showMatrix(matriz, nroVertices);
34+
// Display the original matrix
35+
System.out.println("Original matrix:");
36+
showMatrix(matriz, nroVertices);
3737

38-
floydWarshall(matriz, nroVertices);
38+
floydWarshall(matriz, nroVertices);
3939

40-
// Display the updated matrix
41-
System.out.println("Updated matrix:");
42-
showMatrix(matriz, nroVertices);
40+
// Display the updated matrix
41+
System.out.println("Updated matrix:");
42+
showMatrix(matriz, nroVertices);
4343

44-
// Show all shortest paths
45-
System.out.println();
46-
for (int i = 0; i < nroVertices; i++) {
47-
for (int x = 0; x < nroVertices; x++) {
48-
System.out.println("Shortest distance from " + i + " to " + x + " = " + matriz[x][i] + ".");
49-
}
50-
}
51-
System.out.println();
44+
// Show all shortest paths
45+
System.out.println();
46+
for (int i = 0; i < nroVertices; i++) {
47+
for (int x = 0; x < nroVertices; x++) {
48+
System.out.println("Shortest distance from " + i + " to " + x + " = " + matriz[x][i] + ".");
49+
}
5250
}
51+
System.out.println();
52+
}
5353

54-
public static void floydWarshall(long[][] matriz, int n) {
55-
for (int x = 0; x < n; x++) { // Intermediary vertex
56-
for (int y = 0; y < n; y++) { // Origin vertex
57-
for (int z = 0; z < n; z++) { // Destination vertex
58-
if (matriz[y][z] > (matriz[y][x] + matriz[x][z])) {
59-
matriz[y][z] = matriz[y][x] + matriz[x][z];
60-
}
61-
}
62-
}
54+
public static void floydWarshall(long[][] matriz, int n) {
55+
for (int x = 0; x < n; x++) { // Intermediary vertex
56+
for (int y = 0; y < n; y++) { // Origin vertex
57+
for (int z = 0; z < n; z++) { // Destination vertex
58+
if (matriz[y][z] > (matriz[y][x] + matriz[x][z])) {
59+
matriz[y][z] = matriz[y][x] + matriz[x][z];
60+
}
6361
}
62+
}
6463
}
65-
}
64+
}
65+
}

0 commit comments

Comments
 (0)