1

i want to ask if there is any way to generate the shortest path from node A to node B without generating the shortest paths to all the other nodes (stop when node B is in the examined set) with A-star in QuickGraph.

I want to plug QuickGraph into a game and thus generating all the paths is not allowed from the time limitations the environment imposes.

Any other suggestions to solve my problem in C# are welcome

Thanks in advance, Xtapodi

Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
Xtapodi
  • 277
  • 4
  • 9

2 Answers2

2

How we can get full path instead of distance?

Houshang.Karami
  • 291
  • 1
  • 3
  • 11
2

Quickgraph 3.3 has a built-in implementation of A* :

QuickGraph.Algorithms.ShortestPath.AStarShortestPathAlgorithm<TVertex,TEdge>

which version of quickgraph are you using ?

digEmAll
  • 56,430
  • 9
  • 115
  • 140
  • I have version 3.6 but i don't see how to set target node? Maybe i could do it by handling events, but this is possible for Dijkstra. Am I missing something? – watbywbarif Dec 22 '11 at 15:45
  • @watbywbarif: If your `A*` algorithm instance is, say, `astar`, just call `astar.Compute(startNode);` and then call `var distance = astar.Distances[destNode];` to get the distance between `startNode` and `destNode` – digEmAll Dec 22 '11 at 17:23
  • but this will calculate distance to all nodes in graph, from this question it seams that I can start algorithm to calculate until it reaches targetNode and then stop. – watbywbarif Dec 23 '11 at 08:29
  • @watbywbarif: I answered to you here --> http://stackoverflow.com/a/8617637/316644 – digEmAll Dec 23 '11 at 15:21