prototype of edge-based dijkstra