Dijkstra Algorithm - Could not run sketch

When you call the get() method of an ArrayList, you are asking the computer to return the element (Node1 object) at an index (location). ArrayLists are 0-indexed, so nodes1.get(109) tries to return the non-existent 110th element, hence the IndexOutOfBoundsException.

One thought is to add() your Node1 objects in order and let their indices serve as id’s. Another is to check out HashMaps in the Processing reference.

2 Likes