// Reading Methods public void FillInNetwork(string outFile, Sorting S, BackgroundWorker bgw, List <string> cutEdges) // iterates through data and fills in edge loadings accordingly { List <FinalLine> data = S.GetRecordsList(); FinalLine newRec = new FinalLine(); FinalLine oldRec = new FinalLine(); PathClass path; // just used as alias oldRec = data.First(); RouteFinding rf = new RouteFinding(NodeNumber); rf.SetupFresh(oldRec.StartStn); path = rf.Retrace(oldRec.EndStn); SetupPath(path); //debugging variables List <string> droppedStations = new List <string>(); string dropName; // end debugging variables foreach (var record in data) { newRec.CopyFrom(record); if (newRec.StartStn != oldRec.StartStn) // need to repeat dijkstra forward and backwards { OriginChange(newRec, bgw); // report progress rf.SetupFresh(newRec.StartStn); // redefines origin and performs dijkstra forwards path = rf.Retrace(newRec.EndStn); // gets path between origin and destination SetupPath(path); // alters RecLocs for fast access to desired records } else if (newRec.EndStn != oldRec.EndStn) // need only repeat dijkstra backwards { path = rf.Retrace(newRec.EndStn); // gets path SetupPath(path); // alters RecLocs } if (RecLocs.Any()) { IncrementAccordingly(newRec.StartTime, newRec.EndTime); // increment desired records } else // debugging purposes only { dropName = Backend.StationDiction.GetValue(newRec.EndStn); if (!droppedStations.Contains(dropName)) { droppedStations.Add(dropName); } DroppedRecords++; } oldRec.CopyFrom(newRec); } WriteFile(outFile, cutEdges); SetMaximumLoading(); }
public RouteFindingTests() { // makes necessary api requests dictionaries = InitialiseMetroNetwork(); sd = (StationDictionary)dictionaries[0]; ld = (LineDictionary)dictionaries[1]; rf = new RouteFinding(sd.N); }