Implement O(n^2) Dijkstra in ST