doc(dijkstra): explain why we use an ArrayList

This commit is contained in:
Paul Alnet 2024-04-26 17:35:37 +02:00
parent e5be8087f9
commit 5dfd14f3f2

View file

@ -36,6 +36,8 @@ public class DijkstraAlgorithm extends ShortestPathAlgorithm {
// Init Dijkstra // Init Dijkstra
for (Node node : graph.getNodes()) { for (Node node : graph.getNodes()) {
// Luckily they are ordered by id.
// ArrayList.set only works if the value is already initialized (because why Java?)
labels.add(new Label(node)); labels.add(new Label(node));
} }