Skip to content

Commit 541cc16

Browse files
committed
Fix Checkstyle in GomoryHuTreeTest: remove inner assignments, add braces, split declarations
1 parent 66fdd21 commit 541cc16

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/test/java/com/thealgorithms/graph/GomoryHuTreeTest.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ void singleNode() {
2929
void triangleGraph() {
3030
// 0-1:3, 1-2:2, 0-2:4
3131
int[][] cap = new int[3][3];
32-
cap[0][1] = cap[1][0] = 3;
33-
cap[1][2] = cap[2][1] = 2;
34-
cap[0][2] = cap[2][0] = 4;
32+
cap[0][1] = 3;
33+
cap[1][0] = 3;
34+
cap[1][2] = 2;
35+
cap[2][1] = 2;
36+
cap[0][2] = 4;
37+
cap[2][0] = 4;
3538

3639
int[][] tree = GomoryHuTree.buildTree(cap);
3740
// validate all pairs via path-min-edge equals maxflow
@@ -56,11 +59,14 @@ private static int[][] randSymmetricMatrix(int n, int lo, int hi, Random rng) {
5659
for (int i = 0; i < n; i++) {
5760
for (int j = i + 1; j < n; j++) {
5861
int w = rng.nextInt(hi - lo + 1) + lo;
59-
a[i][j] = a[j][i] = w;
62+
a[i][j] = w;
63+
a[j][i] = w;
6064
}
6165
}
6266
// zero diagonal
63-
for (int i = 0; i < n; i++) a[i][i] = 0;
67+
for (int i = 0; i < n; i++) {
68+
a[i][i] = 0;
69+
}
6470
return a;
6571
}
6672

@@ -71,7 +77,9 @@ private static void validateAllPairs(int[][] cap, int[][] tree) {
7177

7278
// build adjacency list of tree without generic array creation
7379
List<List<int[]>> g = new ArrayList<>();
74-
for (int i = 0; i < n; i++) g.add(new ArrayList<>());
80+
for (int i = 0; i < n; i++) {
81+
g.add(new ArrayList<>());
82+
}
7583
for (int v = 1; v < n; v++) {
7684
int u = parent[v];
7785
int w = weight[v];
@@ -99,9 +107,12 @@ private static int minEdgeOnPath(List<List<int[]>> g, int s, int t) {
99107
parent[s] = s;
100108
while (!q.isEmpty()) {
101109
int u = q.poll();
102-
if (u == t) break;
110+
if (u == t) {
111+
break;
112+
}
103113
for (int[] e : g.get(u)) {
104-
int v = e[0], w = e[1];
114+
int v = e[0];
115+
int w = e[1];
105116
if (parent[v] == -1) {
106117
parent[v] = u;
107118
edgeW[v] = w;

0 commit comments

Comments
 (0)