public void AddConnection(IDirectedGraphConnection Connection) { Connections.Add(Connection); }
//internal abstract float CalculateCost(IEnumerable<IDirectedGraphConnection> connections); internal abstract float CalculateCost(float currentCost, IDirectedGraphConnection connection);
private SearchInfo BranchTo(SearchInfo current, IDirectedGraphConnection connection) { //var connections = current.Connections.Concat(new List<IDirectedGraphConnection>() { connection }); return new SearchInfo() { TargetId = connection.TargetId, //Connections = connections, Cost = CalculateCost(current.Cost, connection), NumConnections = current.NumConnections + 1 }; }
//internal override float CalculateCost(IEnumerable<IDirectedGraphConnection> connections) //{ // // Sum up the total travel time and mean headways // float totalTime = (from conn in connections select (conn as LocConnection).HalfHeadway + (conn as LocConnection).Cost).Sum(); // // Reduce the largest headway on the trip... this is a bonus for planning your trip to catch a specific bus/train. // const float maxHeadwaySavingsPortion = 0.0f;// 0.6f; // float maxHeadwayBonus = maxHeadwaySavingsPortion * (connections.Count() > 0 ? (from conn in connections select (conn as LocConnection).HalfHeadway).Max() : 0.0f); // return totalTime - maxHeadwayBonus; //} //internal override IDirectedGraphConnection CombineConnections(IEnumerable<IDirectedGraphConnection> connections, IGraphNode target) //{ // return new LocConnection() // { // Cost = CalculateCost(connections), // HalfHeadway = 0.0f, // Desc = string.Join(",", (from conn in connections select string.Format("{0} {1}", (conn as LocConnection).Desc, (conn as LocConnection).Cost)).ToArray()), // TargetId = target.GraphNodeId // }; //} internal override float CalculateCost(float currentCost, IDirectedGraphConnection connection) { return currentCost + (connection as LocConnection).Cost + (connection as LocConnection).HalfHeadway; }