public DijkstraShortestPath(DirectedWeightedGraph <V> graph, V startVertex) : base(graph, startVertex)
        {
            for (int i = 0; i < graph.TotalVertices(); i++)
            {
                _distanceTo[i] = Double.PositiveInfinity;
            }
            _distanceTo[startVertex.GetHashCode()] = 0.0;

            _indexedPQ.Insert(startVertex.GetHashCode(), 0.0);
            while (!_indexedPQ.IsEmpty)
            {
                var result = _indexedPQ.Extract(); // Min
                foreach (var edge in graph.Adjacency(result))
                {
                    Relax(edge);
                }
            }
        }
Example #2
0
 public ShortestPath(DirectedWeightedGraph <V> graph, V startVertex)
 {
 }