Ejemplo n.º 1
0
 static public MazeGraph <T> Execute(MazeGraph <T> G)
 {
     initializeVariables(G);
     enqueueAdjEdges(G, 0);
     for (int i = 1; i < N; i++)
     {
         do
         {
             edge = queue.top();
             queue.delete();
         } while (added[edge.dest]);
         g.addEdge(edge.orig, edge.dest, edge.cost);
         g.addEdge(edge.dest, edge.orig, edge.cost);
         added[edge.dest] = true;
         enqueueAdjEdges(G, edge.dest);
     }
     return(g);
 }
Ejemplo n.º 2
0
 public static MazeGraph <T> Execute(MazeGraph <T> G)
 {
     initializeVariables(G);
     for (int count = 1; count < n;)
     {
         Edge <T> edge = queue.top();
         queue.delete();
         int leader1 = P.find(edge.orig);
         int leader2 = P.find(edge.dest);
         if (leader1 != leader2)
         {
             P.join(leader1, leader2);
             g.addEdge(edge.orig, edge.dest, edge.cost);
             g.addEdge(edge.dest, edge.orig, edge.cost);
             ++count;
         }
     }
     return(g);
 }