refactor: change packages (#5430)

* refactor: change package

* refactor: fix name

---------

Co-authored-by: alxkm <alx@alx.com>
This commit is contained in:
Alex Klymenko
2024-08-30 11:58:24 +02:00
committed by GitHub
parent f8ff6af893
commit b0de93b3ce
10 changed files with 13 additions and 13 deletions

View File

@ -1,57 +0,0 @@
package com.thealgorithms.dynamicprogramming;
import java.util.LinkedList;
import java.util.Queue;
public final class FordFulkerson {
private static final int INF = Integer.MAX_VALUE;
private FordFulkerson() {
}
public static int networkFlow(int vertexCount, int[][] capacity, int[][] flow, int source, int sink) {
int totalFlow = 0;
while (true) {
int[] parent = new int[vertexCount];
boolean[] visited = new boolean[vertexCount];
Queue<Integer> queue = new LinkedList<>();
queue.add(source);
visited[source] = true;
parent[source] = -1;
while (!queue.isEmpty() && !visited[sink]) {
int current = queue.poll();
for (int next = 0; next < vertexCount; next++) {
if (!visited[next] && capacity[current][next] - flow[current][next] > 0) {
queue.add(next);
visited[next] = true;
parent[next] = current;
}
}
}
if (!visited[sink]) {
break; // No more augmenting paths
}
int pathFlow = INF;
for (int v = sink; v != source; v = parent[v]) {
int u = parent[v];
pathFlow = Math.min(pathFlow, capacity[u][v] - flow[u][v]);
}
for (int v = sink; v != source; v = parent[v]) {
int u = parent[v];
flow[u][v] += pathFlow;
flow[v][u] -= pathFlow;
}
totalFlow += pathFlow;
}
return totalFlow;
}
}

View File

@ -5,8 +5,8 @@ package com.thealgorithms.dynamicprogramming;
* supersequence of two given strings. The shortest supersequence is the smallest string
* that contains both given strings as subsequences.
*/
final class ShortestCommonSuperSequenceLength {
private ShortestCommonSuperSequenceLength() {
final class ShortestCommonSupersequenceLength {
private ShortestCommonSupersequenceLength() {
}
/**