Add EdgeCost with AddVerticesAndEdge?

Topics: algorithm, graph
Jan 2, 2012 at 11:44 PM

I have a list of highway links, I am interested in applying a shortest path algorithm.

Each link has a start node and end node, and a distance.

I build the graph as follows:

   foreach (RoadLink link in listRoadLink)
                           graph.AddVerticesAndEdge(new Edge<int> (link.StartNodeIdentifier,link.EndNodeIdentifier));                      

My question is how to identify the added edge, so that I can later add the distance as an edge cost in a dictionary, e.g. if I have:

    Dictionary<Edge<int>, double> edgeCost2 = new Dictionary<Edge<int>, double>(graph.EdgeCount);

The problem is that iterating on the edges

    foreach (var e in graph.Edges)

does not give me the same order of edges as when I entered originally, which is the point at which I know the distance for the edge being added.


Thank you.


R, Males

Cincinnati, Ohio, USA