Need a structure supporting the following:
- add new value for O (logN)
- find out the minimum element for O (1)
- remove the minimum element for O (logN)
- change the value of the item for O (logN)
In addition to the standard heap, we will store the array valueToIndex [v] = index, in which for each vertex v, a pointer / index per element is stored in the heap, where the time value for this vertex is stored.
When you want to change the value at some vertex:
- get the link to the element in the heap using the valueToIndex array
- change the value
- because for dekstra value can only decrease, it is necessary to push up this element by recursion (no more logN lifts)
Also, in all standard heap functions, when changing the location of elements, it is necessary to update the values of the valueToIndex [] array.
If you implement a bunch of non-arrays, then you need to keep a reference to the ancestor.
If some moment is not clear, then sign for more.