Skip to content

Commit 839e34b

Browse files
committed
Fix: Checkstyle violations in Dinic and tests
1 parent ef75cc4 commit 839e34b

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/main/java/com/thealgorithms/graph/Dinic.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @see <a href="https://en.wikipedia.org/wiki/Dinic%27s_algorithm">Wikipedia: Dinic's algorithm</a>
2222
*/
2323
public final class Dinic {
24-
private Dinic() {}
24+
private Dinic() { }
2525

2626
/**
2727
* Computes the maximum flow from source to sink using Dinic's algorithm.
@@ -101,17 +101,19 @@ private static int dfsBlocking(
101101
}
102102
final int n = residual.length;
103103
for (int v = next[u]; v < n; v++, next[u] = v) {
104-
if (residual[u][v] <= 0)
105-
continue;
106-
if (level[v] != level[u] + 1)
107-
continue;
108-
int pushed = dfsBlocking(residual, level, next, v, sink, Math.min(f, residual[u][v]));
109-
if (pushed > 0) {
110-
residual[u][v] -= pushed;
111-
residual[v][u] += pushed;
112-
return pushed;
113-
}
114-
}
115-
return 0;
104+
if (residual[u][v] <= 0) {
105+
continue;
106+
}
107+
if (level[v] != level[u] + 1) {
108+
continue;
109+
}
110+
int pushed = dfsBlocking(residual, level, next, v, sink, Math.min(f, residual[u][v]));
111+
if (pushed > 0) {
112+
residual[u][v] -= pushed;
113+
residual[v][u] += pushed;
114+
return pushed;
115+
}
116+
}
117+
return 0;
116118
}
117119
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ void parityWithEdmondsKarp() {
5353
}
5454
}
5555
}
56-
int s = 0, t = n - 1;
56+
int s = 0;
57+
int t = n - 1;
5758
int f1 = Dinic.maxFlow(copyMatrix(cap), s, t);
5859
int f2 = EdmondsKarp.maxFlow(cap, s, t);
5960
assertEquals(f2, f1);

0 commit comments

Comments
 (0)