Skip to content

Commit 05ca8e3

Browse files
committed
Update MultistageGraph.java & MultistageGraphTest.java
1 parent fef9816 commit 05ca8e3

File tree

2 files changed

+30
-32
lines changed

2 files changed

+30
-32
lines changed

src/main/java/com/thealgorithms/datastructures/graphs/MultistageGraph.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
import java.util.List;
55

66
public final class MultistageGraph {
7-
7+
88
private MultistageGraph() {
9-
109
}
11-
private int k; // number of partitions (k > 2)
10+
private int k; // number of partitions (k > 2)
1211

1312
// Adjacency list to store edges between different stages
1413
public List<List<Integer>> adjacencyList;

src/test/java/com/thealgorithms/datastructures/graphs/MultistageGraphTest.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,46 @@
77
import java.io.PrintStream;
88
import java.util.Arrays;
99
import java.util.List;
10-
1110
import org.junit.jupiter.api.Test;
1211

1312
public class MultistageGraphTest {
1413

15-
@Test
16-
public void testAddEdge_invalidFromStage() {
17-
MultistageGraph graph = new MultistageGraph(3);
14+
@Test
15+
public void testAddEdge_invalidFromStage() {
16+
MultistageGraph graph = new MultistageGraph(3);
1817

19-
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(0, 2));
20-
}
18+
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(0, 2));
19+
}
2120

22-
@Test
23-
public void testAddEdge_invalidToStage() {
24-
MultistageGraph graph = new MultistageGraph(3);
21+
@Test
22+
public void testAddEdge_invalidToStage() {
23+
MultistageGraph graph = new MultistageGraph(3);
2524

26-
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(1, 4));
27-
}
25+
assertThrows(IllegalArgumentException.class, () -> graph.addEdge(1, 4));
26+
}
2827

29-
@Test
30-
public void testAddEdge_edgeAlreadyExists() {
31-
MultistageGraph graph = new MultistageGraph(3);
28+
@Test
29+
public void testAddEdge_edgeAlreadyExists() {
30+
MultistageGraph graph = new MultistageGraph(3);
3231

33-
graph.addEdge(1, 2);
34-
graph.addEdge(1, 2); // Attempt to add the same edge again
32+
graph.addEdge(1, 2);
33+
graph.addEdge(1, 2); // Attempt to add the same edge again
3534

36-
List<Integer> expectedAdjacentStages = Arrays.asList(2);
37-
assertEquals(expectedAdjacentStages, graph.adjacencyList.get(0));
38-
}
35+
List<Integer> expectedAdjacentStages = Arrays.asList(2);
36+
assertEquals(expectedAdjacentStages, graph.adjacencyList.get(0));
37+
}
3938

40-
@Test
41-
public void testAddEdge_printsSuccessMessage() {
42-
MultistageGraph graph = new MultistageGraph(3);
39+
@Test
40+
public void testAddEdge_printsSuccessMessage() {
41+
MultistageGraph graph = new MultistageGraph(3);
4342

44-
// Capture the standard output stream
45-
ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
46-
System.setOut(new PrintStream(outputStreamCaptor));
43+
// Capture the standard output stream
44+
ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream();
45+
System.setOut(new PrintStream(outputStreamCaptor));
4746

48-
graph.addEdge(1, 2);
47+
graph.addEdge(1, 2);
4948

50-
String expectedOutput = "Added edge between stage 1 and stage 2\r\n";
51-
assertEquals(expectedOutput, outputStreamCaptor.toString());
52-
}
49+
String expectedOutput = "Added edge between stage 1 and stage 2\r\n";
50+
assertEquals(expectedOutput, outputStreamCaptor.toString());
51+
}
5352
}

0 commit comments

Comments
 (0)