August 2018
Beginner
334 pages
10h 19m
English
We called the BuildPath function, but we haven't implemented it yet. It is important to note that this function is called by almost every other path-finding algorithm in this chapter; that's why it's not part of the main recipe.
This is the code for the BuildPath method:
private List<Vertex> BuildPath(int srcId, int dstId, ref int[] prevList)
{
List<Vertex> path = new List<Vertex>();
int prev = dstId;
do
{
path.Add(vertices[prev]);
prev = prevList[prev];
} while (prev != srcId);
return path;
}
Read now
Unlock full access