mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-31 00:37:15 +08:00
refactor: change packages (#5430)
* refactor: change package * refactor: fix name --------- Co-authored-by: alxkm <alx@alx.com>
This commit is contained in:
@ -1,94 +0,0 @@
|
||||
package com.thealgorithms.dynamicprogramming;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class FordFulkersonTest {
|
||||
@Test
|
||||
public void testMaxFlow() {
|
||||
int vertexCount = 6;
|
||||
int[][] capacity = new int[vertexCount][vertexCount];
|
||||
int[][] flow = new int[vertexCount][vertexCount];
|
||||
|
||||
// Setting up the capacity graph
|
||||
capacity[0][1] = 12;
|
||||
capacity[0][3] = 13;
|
||||
capacity[1][2] = 10;
|
||||
capacity[2][3] = 13;
|
||||
capacity[2][4] = 3;
|
||||
capacity[2][5] = 15;
|
||||
capacity[3][2] = 7;
|
||||
capacity[3][4] = 15;
|
||||
capacity[4][5] = 17;
|
||||
|
||||
int maxFlow = FordFulkerson.networkFlow(vertexCount, capacity, flow, 0, 5);
|
||||
assertEquals(23, maxFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoFlow() {
|
||||
int vertexCount = 6;
|
||||
int[][] capacity = new int[vertexCount][vertexCount];
|
||||
int[][] flow = new int[vertexCount][vertexCount];
|
||||
|
||||
// No connections between source and sink
|
||||
capacity[0][1] = 10;
|
||||
capacity[2][3] = 10;
|
||||
|
||||
int maxFlow = FordFulkerson.networkFlow(vertexCount, capacity, flow, 1, 4);
|
||||
assertEquals(0, maxFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSinglePath() {
|
||||
int vertexCount = 6;
|
||||
int[][] capacity = new int[vertexCount][vertexCount];
|
||||
int[][] flow = new int[vertexCount][vertexCount];
|
||||
|
||||
// Setting up a single path from source to sink
|
||||
capacity[0][1] = 5;
|
||||
capacity[1][2] = 5;
|
||||
capacity[2][3] = 5;
|
||||
capacity[3][4] = 5;
|
||||
capacity[4][5] = 5;
|
||||
|
||||
int maxFlow = FordFulkerson.networkFlow(vertexCount, capacity, flow, 0, 5);
|
||||
assertEquals(5, maxFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParallelPaths() {
|
||||
int vertexCount = 4;
|
||||
int[][] capacity = new int[vertexCount][vertexCount];
|
||||
int[][] flow = new int[vertexCount][vertexCount];
|
||||
|
||||
// Setting up parallel paths from source to sink
|
||||
capacity[0][1] = 10;
|
||||
capacity[0][2] = 10;
|
||||
capacity[1][3] = 10;
|
||||
capacity[2][3] = 10;
|
||||
|
||||
int maxFlow = FordFulkerson.networkFlow(vertexCount, capacity, flow, 0, 3);
|
||||
assertEquals(20, maxFlow);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexNetwork() {
|
||||
int vertexCount = 5;
|
||||
int[][] capacity = new int[vertexCount][vertexCount];
|
||||
int[][] flow = new int[vertexCount][vertexCount];
|
||||
|
||||
// Complex network
|
||||
capacity[0][1] = 10;
|
||||
capacity[0][2] = 10;
|
||||
capacity[1][3] = 4;
|
||||
capacity[1][4] = 8;
|
||||
capacity[2][4] = 9;
|
||||
capacity[3][2] = 6;
|
||||
capacity[3][4] = 10;
|
||||
|
||||
int maxFlow = FordFulkerson.networkFlow(vertexCount, capacity, flow, 0, 4);
|
||||
assertEquals(19, maxFlow);
|
||||
}
|
||||
}
|
@ -5,10 +5,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
public class ShortestCommonSuperSequenceLengthTest {
|
||||
public class ShortestCommonSupersequenceLengthTest {
|
||||
@ParameterizedTest
|
||||
@CsvSource({"AGGTAB, GXTXAYB, 9", "ABC, ABC, 3", "ABC, DEF, 6", "'', ABC, 3", "ABCD, AB, 4", "ABC, BCD, 4", "A, B, 2"})
|
||||
void testShortestSuperSequence(String input1, String input2, int expected) {
|
||||
assertEquals(expected, ShortestCommonSuperSequenceLength.shortestSuperSequence(input1, input2));
|
||||
void testShortestSupersequence(String input1, String input2, int expected) {
|
||||
assertEquals(expected, ShortestCommonSupersequenceLength.shortestSuperSequence(input1, input2));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user