Example #1
0
 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);
     }
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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);
     }
 }