reviewed dijkstra and some others algorithm