double-ended Dijkstra