private Route getminRoute(PForest F, int sid, int eid, Point p1, Point p2) { Dictionary <Route, double> path_dis = new Dictionary <Route, double>(); double min_len = 99999999; Route min_path = null; //List<Route> routes = new List<Route>(); //int f = 0; //double v_limit = 0; //double time_interval = 0; //double road_vlimit = 0; //TimeSpan ts = new TimeSpan(); if (sid == eid) { //Route p = new Route(); //p.Add(sid); min_path = new Route(); min_path.Add(sid); } else { Tree <Node> tr = F.FindTree(sid); TreeNode <Node> curNode = null; if (tr != null && tr.Index.ContainsKey(eid)) { foreach (TreeNode <Node> n in tr.Index[eid]) { //road_vlimit = 0; Route pp = new Route(); curNode = n; while (curNode != null) { pp.Add(curNode.Data.Sid); curNode = curNode.Parent; } pp.Reverse(); #region clean paths //ts = p2.T.Subtract(p1.T).Duration(); //time_interval = Convert.ToDouble(ts.TotalSeconds); //v_limit = pp.getLength(g, p1, p2) / time_interval; //foreach (int id in pp) //{ // if (g.getEdgeAttribute(id).ATTRIBUTE[0] == -1) // road_vlimit += 13; // else // road_vlimit += g.getEdgeAttribute(id).ATTRIBUTE[5]; //} #endregion //routes.Add(pp); path_dis.Add(pp, pp.getLength(m_graph, p1, p2)); } } else { return(null); } } var dicSort = from objDic in path_dis orderby objDic.Value select objDic; foreach (KeyValuePair <Route, double> k_v in dicSort) { if (k_v.Value < min_len) { min_len = k_v.Value; min_path = k_v.Key; } } return(min_path); }
public Mapmatching(Graph g, PForest f) { m_graph = g; this.F = f; }