public SimplePrimMST(EdgeWeightedGraph G) : base(G) { _marked = new bool[G.V()]; _edgeTo = new Edge[G.V()]; _pq = new IndexMinPQ <double>(G.E()); _pq.Insert(0, 0d); while (!_pq.IsEmpty()) { int v = _pq.RemoveMin(); Visit(G, v); } }
public DijkstraSP(EdgeWeightedDigraph G, int s) : base(G, s) { _pq = new IndexMinPQ <double>(G.E()); for (int i = 0; i < G.V(); i++) { _distTo[i] = double.PositiveInfinity; } _distTo[s] = 0d; _pq.Insert(0, 0d); while (!_pq.IsEmpty()) { var w = _pq.RemoveMin(); Relax(G, w); } }
public PrimMST(EdgeWeightedGraph G) : base(G) { _marked = new bool[G.V()]; _edgeTo = new Edge[G.V()]; _distTo = new double[G.V()]; _pq = new IndexMinPQ <double>(G.E()); for (int v = 0; v < G.V(); v++) { _distTo[v] = double.PositiveInfinity; } _distTo[0] = 0d; _pq.Insert(0, 0d); while (!_pq.IsEmpty()) { int v = _pq.RemoveMin(); Visit(G, v); } }