public StopConnection Create( RouteStop routeStop, Departure departure, StopVertex currentVertex, RouteStop nextRouteStop, StopVertex nextVertex, DateTime connectionStartDay, bool betweenTwoDays) { var endDay = connectionStartDay; if (betweenTwoDays) { endDay = endDay.AddDays(1); } return(new StopConnection() { Line = routeStop.Line, StartDateTime = connectionStartDay + departure.DepartureTime, SourceStop = currentVertex, EndDateTime = endDay + nextRouteStop .Departures .Where(p => p.RunIndex == departure.RunIndex) .First() .DepartureTime, DestinationStop = nextVertex, }); }
public StopVertex MarkVertexAsVisited(StopVertex stopVertex) { stopVertex.IsVisited = true; foreach (var similarStopVertex in stopVertex.SimilarStopVertices) { similarStopVertex.IsVisited = true; } return(stopVertex); }
public IEnumerable <StopConnection> GetConnectionsFromSimilarVertices(StopVertex stopVertex, IEnumerable <StopVertex> similarStopVertices) { var allStopConnections = new List <StopConnection>(); allStopConnections.AddRange(stopVertex.StopConnections); foreach (var similarVertex in stopVertex.SimilarStopVertices) { allStopConnections.AddRange(similarVertex.StopConnections); } return(allStopConnections); }
private bool ShouldSearchingContinue(SearchInput search, StopVertex currentVertex) { bool isCurrentVertexDestinationStop = currentVertex != null && currentVertex.Stop.Id == search.DestinationStop.Id; if (isCurrentVertexDestinationStop == true) { return(false); } foreach (var similarVertex in currentVertex.SimilarStopVertices) { if (similarVertex.Stop.Id == search.DestinationStop.Id) { return(false); } } return(true); }
public IEnumerable <StopConnection> SetTransferConnectionsToSimilarVertices( IEnumerable <StopConnection> vertexFastestConnections, StopVertex stopVertex, IEnumerable <StopVertex> similarStopVertices) { var connectionToStopVertex = vertexFastestConnections .FirstOrNull(p => p.DestinationStop.Stop.Id == stopVertex.Stop.Id); foreach (var similarVertex in similarStopVertices) { var similarVertexFastestConnection = vertexFastestConnections .FirstOrNull(p => p.DestinationStop.Stop.Id == similarVertex.Stop.Id); similarVertexFastestConnection.SourceStop = stopVertex; similarVertexFastestConnection.StartDateTime = connectionToStopVertex.EndDateTime; similarVertexFastestConnection.EndDateTime = connectionToStopVertex.EndDateTime; similarVertexFastestConnection.Line = null; similarVertexFastestConnection.IsTransfer = true; } return(vertexFastestConnections); }