I'm implementing Dijkstra's algorithm in Java. I need help in creating an arraylist of stacks that will be used to store the predecessors table, which means that for every element's shortest path, the predecessors taken to get there would be in the stack.
Here's the code I have
I'm unable to add the the stack to prev arraylist. The error is
The method add(E) in the type ArrayList<E> is not applicable for the arguments (predec<E>)
I have implemented a TreeMap, with the mainNodes arraylist storing all the elements in the map.