Beispiel #1
0
 private bool IsEndSearchJourneyTime(DijkstraPoint endPoint = null)
 {
     if (endPoint != null && endPoint.IsChecked)
     {
         return(true);
     }
     foreach (var point in _dijkstraGraph.Ways.Keys)
     {
         if (!point.IsChecked)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #2
0
        private DijkstraPoint FindNextStartPoint()
        {
            DijkstraPoint nextStartPoint = null;

            foreach (var point in _dijkstraGraph.Ways.Keys.Where(point => !point.IsChecked))
            {
                if (nextStartPoint == null)
                {
                    nextStartPoint = point;
                    continue;
                }
                if (nextStartPoint.Weight > point.Weight)
                {
                    nextStartPoint = point;
                }
            }
            return(nextStartPoint);
        }
        public DijkstraGraph(Graph graph)
        {
            _ways = new Dictionary <DijkstraPoint, List <DijkstraPoint> >();

            foreach (var vertex in graph.Vertices)
            {
                _ways[new DijkstraPoint(vertex)] = new List <DijkstraPoint>();
            }

            foreach (var edge in graph.Edges)
            {
                DijkstraPoint dijkstraVertexFrom = _ways.Keys.First(diykstraPoint => diykstraPoint.Id == edge.StartVertexId);

                Vertex        vertexTo         = graph.Vertices.First(vertice => vertice.Id == edge.EndVertexId);
                DijkstraPoint dijkstraVertexTo = new DijkstraPoint(vertexTo);
                dijkstraVertexTo.JourneyTimeToThisPoint = edge.JourneyTime;

                _ways[dijkstraVertexFrom].Add(dijkstraVertexTo);
            }
        }