@@ -88,9 +88,7 @@ void testGraphWithMixedBridgesAndCycles() {
8888 // 6
8989 // Cycle: 0-1-2-3-0 (no bridges within)
9090 // Bridges: 2-4, 4-5, 5-6
91- List <List <Integer >> adj = buildGraph (7 , new int [][] {
92- {0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 }, {2 , 4 }, {4 , 5 }, {5 , 6 }
93- });
91+ List <List <Integer >> adj = buildGraph (7 , new int [][] {{0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 }, {2 , 4 }, {4 , 5 }, {5 , 6 }});
9492 List <int []> bridges = TarjanBridges .findBridges (7 , adj );
9593 sortBridges (bridges );
9694 assertEquals (3 , bridges .size ());
@@ -106,9 +104,7 @@ void testGraphWithMixedBridgesAndCycles() {
106104 void testDisconnectedGraphWithBridges () {
107105 // Component 1: 0-1 (bridge)
108106 // Component 2: 2-3-4-2 (cycle, no bridges)
109- List <List <Integer >> adj = buildGraph (5 , new int [][] {
110- {0 , 1 }, {2 , 3 }, {3 , 4 }, {4 , 2 }
111- });
107+ List <List <Integer >> adj = buildGraph (5 , new int [][] {{0 , 1 }, {2 , 3 }, {3 , 4 }, {4 , 2 }});
112108 List <int []> bridges = TarjanBridges .findBridges (5 , adj );
113109 assertEquals (1 , bridges .size ());
114110 assertEquals (0 , bridges .get (0 )[0 ]);
@@ -165,9 +161,7 @@ void testComplexGraphWithMultipleCyclesAndBridges() {
165161 // Cycle A: 0-1-2-0
166162 // Cycle B: 3-4-5-3
167163 // Bridge: 2-3
168- List <List <Integer >> adj = buildGraph (6 , new int [][] {
169- {0 , 1 }, {1 , 2 }, {2 , 0 }, {3 , 4 }, {4 , 5 }, {5 , 3 }, {2 , 3 }
170- });
164+ List <List <Integer >> adj = buildGraph (6 , new int [][] {{0 , 1 }, {1 , 2 }, {2 , 0 }, {3 , 4 }, {4 , 5 }, {5 , 3 }, {2 , 3 }});
171165 List <int []> bridges = TarjanBridges .findBridges (6 , adj );
172166 assertEquals (1 , bridges .size ());
173167 assertEquals (2 , bridges .get (0 )[0 ]);
@@ -193,9 +187,7 @@ void testMismatchedAdjacencyListSizeThrowsException() {
193187 @ Test
194188 void testStarGraphAllEdgesAreBridges () {
195189 // Star graph: center vertex 0 connected to 1, 2, 3, 4
196- List <List <Integer >> adj = buildGraph (5 , new int [][] {
197- {0 , 1 }, {0 , 2 }, {0 , 3 }, {0 , 4 }
198- });
190+ List <List <Integer >> adj = buildGraph (5 , new int [][] {{0 , 1 }, {0 , 2 }, {0 , 3 }, {0 , 4 }});
199191 List <int []> bridges = TarjanBridges .findBridges (5 , adj );
200192 assertEquals (4 , bridges .size ());
201193 }
@@ -206,11 +198,7 @@ void testBridgeBetweenTwoCycles() {
206198 // Square 1: 0-1-2-3-0
207199 // Square 2: 4-5-6-7-4
208200 // Bridge: 3-4
209- List <List <Integer >> adj = buildGraph (8 , new int [][] {
210- {0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 },
211- {4 , 5 }, {5 , 6 }, {6 , 7 }, {7 , 4 },
212- {3 , 4 }
213- });
201+ List <List <Integer >> adj = buildGraph (8 , new int [][] {{0 , 1 }, {1 , 2 }, {2 , 3 }, {3 , 0 }, {4 , 5 }, {5 , 6 }, {6 , 7 }, {7 , 4 }, {3 , 4 }});
214202 List <int []> bridges = TarjanBridges .findBridges (8 , adj );
215203 assertEquals (1 , bridges .size ());
216204 assertEquals (3 , bridges .get (0 )[0 ]);
0 commit comments