Shortest path (fewest nodes) for unweighted graph

后端 未结 5 945
猫巷女王i
猫巷女王i 2020-12-07 19:34

I\'m trying build a method which returns the shortest path from one node to another in an unweighted graph. I considered the use of Dijkstra\'s but this seems a bit overkil

5条回答
  •  情话喂你
    2020-12-07 20:18

    Every time through your loop, you call

    directions.Add(current);
    

    Instead, you should move that to a place where you really know you want that entry.

提交回复
热议问题