@@ -25,7 +25,10 @@ void setUp() {
2525 @ Test
2626 void testSimpleGraph () {
2727 Map <Integer , List <DijkstraPriorityQueue .Edge >> graph = new HashMap <>();
28- graph .put (0 , List .of (new DijkstraPriorityQueue .Edge (1 , 7 ), new DijkstraPriorityQueue .Edge (2 , 9 )));
28+ graph .put (
29+ 0 ,
30+ List .of (
31+ new DijkstraPriorityQueue .Edge (1 , 7 ), new DijkstraPriorityQueue .Edge (2 , 9 )));
2932 graph .put (1 , List .of (new DijkstraPriorityQueue .Edge (2 , 10 )));
3033 graph .put (2 , new ArrayList <>());
3134
@@ -36,10 +39,19 @@ void testSimpleGraph() {
3639
3740 @ Test
3841 void testShorterPathFoundLater () {
39- // This ensures the 'if (dist[u] + edge.weight < dist[edge.target])' logic is fully tested
42+ // This ensures the 'if (dist[u] + edge.weight < dist[edge.target])' logic
43+ // is fully tested
4044 Map <Integer , List <DijkstraPriorityQueue .Edge >> graph = new HashMap <>();
41- graph .put (0 , List .of (new DijkstraPriorityQueue .Edge (1 , 10 ), new DijkstraPriorityQueue .Edge (2 , 2 )));
42- graph .put (2 , List .of (new DijkstraPriorityQueue .Edge (1 , 3 ))); // Path 0->2->1 is shorter (5) than 0->1 (10)
45+ graph .put (
46+ 0 ,
47+ List .of (
48+ new DijkstraPriorityQueue .Edge (1 , 10 ),
49+ new DijkstraPriorityQueue .Edge (2 , 2 )));
50+ graph .put (
51+ 2 ,
52+ List .of (
53+ new DijkstraPriorityQueue .Edge (1 , 3 ))); // Path 0->2->1 is shorter (5)
54+ // than 0->1 (10)
4355
4456 int [] result = dijkstra .runDijkstra (0 , graph , 3 );
4557 int [] expected = {0 , 5 , 2 };
@@ -51,7 +63,10 @@ void testStalePriorityQueueEntry() {
5163 // This forces 'if (d > dist[u]) continue;' to execute
5264 Map <Integer , List <DijkstraPriorityQueue .Edge >> graph = new HashMap <>();
5365 // Two edges to the same target: the PQ will have two entries for node 1
54- graph .put (0 , List .of (new DijkstraPriorityQueue .Edge (1 , 10 ), new DijkstraPriorityQueue .Edge (1 , 2 )));
66+ graph .put (
67+ 0 ,
68+ List .of (
69+ new DijkstraPriorityQueue .Edge (1 , 10 ), new DijkstraPriorityQueue .Edge (1 , 2 )));
5570
5671 int [] result = dijkstra .runDijkstra (0 , graph , 2 );
5772 int [] expected = {0 , 2 };
0 commit comments