从邻接矩阵我必须得到两个节点之间的路径的顶点不关心权重
不确定如何做得好。
/// <param name="start"></param>
/// <param name="end"></param>
/// <returns>Returns the path in vertice</returns>
/// <Complexity>O(n)</Complexity>
public string[] GetPath(string start, string end)
{
int startPosition = 0; //start position
int endPosition = 0; //end position
for (int i = 0; i < Vertices.Length; i++)
{
if(Vertices[i] == start)
{
startPosition = i;
}
if (Vertices[i] == end)
{
endPosition = i;
}
}
string[] path = new string[0];
for (int j = 0; j < Vertices.Length; j++)
{
if (j >= startPosition && j <= endPosition) {
}
}
return path;
}
和最短路径
public string[] GetShortestPath(string start, string end)
{
//In this one must return the vertex of shortest path between the nodes but checking the weight
}
希望你能帮助我。