圖由節點與有向邊構成,每條邊具權值 (代價)。最短路徑算法目標:找出從節點 A 到節點 B 的累積權值最小路徑。參考《C++ 算法——圖算法》。
public class Edge
{
public string StartNodeID; // 起點節點 ID
public string EndNodeID; // 終點節點 ID
public double Weight; // 權值/代價
}
public class Node
{
private string _id;
private ArrayList _edgeList; // 出邊集合
public Node(string id)
{
_id = id;
_edgeList = new ArrayList();
}
public string ID => _id;
public ArrayList EdgeList => _edgeList;
}
EdgeList),支援鄰接表結構,便於演算法遍歷鄰居。後續將引入 PassedPath、PlanCourse、RoutePlanner 完成 Dijkstra 演算法實現。