0

I need to create a path in an indoor map having all the connections (steps, hops) like AB, BC, BA, CB, .... Suppose I have to go from A to I how will be the algorithm? P.S. I'm developing in C# but any pseudo code or link to other resources is appreciated .

enter image description here

adrianoBP
  • 187
  • 6
  • 19

1 Answers1

1

Use Breadth-First-Search (BFS) to construct a tree starting from A.

When you reach the node I, traverse the tree back up to the root (A) by repeatedly going up the parent node i.e. I -> H -> G -> F -> C -> B -> A.

As you do, you can retrieve the strings HI, GH, FG, CF, BC, AB, which you can then list backwards for your final solution.

wookie919
  • 3,054
  • 24
  • 32