@@ -0,0 +1,1242 @@
+Algoritmo para hallar el arbol cobertor m%C3%ADnimo de un grafo  no dirigido y conexo. %0A%0Aimport java.util.*;%0A%0Astatic int v, e; //vertices, arcos%0Astatic int MAX=100005; %0Astatic ArrayList%3CNode%3E ady%5B%5D = new ArrayList%5BMAX%5D;%0Astatic boolean marked%5B%5D = new boolean%5BMAX%5D;%0Astatic int rta;%0Astatic PriorityQueue%3CNode%3E pq;%0A%0A//limpiar las estructuras de datos    %0Astatic void init() %7B%0A%09rta = 0;%0A%09pq = new PriorityQueue%3CNode%3E();%0A    for (int j = 0; j %3C= v; j++) %7B%0A        marked%5Bj%5D = false;%0A        ady%5Bj%5D = new ArrayList%3CNode%3E();%0A    %7D%0A%7D%0A%0Astatic void prim()%7B%0A%09process(0); //Nodo inicial;%0A%09int u, w;%0A %0A%09while( pq.size() %3E 0 )%7B%0A%09%09u = pq.peek().adjacent;%0A%09%09w = pq.peek().cost;%0A %0A%09%09pq.poll();%0A %0A%09%09if( !marked%5Bu%5D )%7B%0A%09%09%09rta += w;%0A%09%09%09process(u);%0A%09%09%7D%0A%09%7D%0A%7D%0A %0Astatic void process( int u )%7B%0A%09marked%5Bu%5D = true;%0A%09int i, v;%0A %0A%09for( i = 0; i %3C ady%5Bu%5D.size(); i++ )%7B%0A%09%09v = ady%5Bu%5D.get(i).adjacent;%0A        if( !marked%5Bv%5D )%7B%0A%09%09%09pq.add( new Node( v, ady%5Bu%5D.get(i).cost ) );%09%0A%09%09%7D%0A%09%7D%0A%7D%0A%0Astatic class Node implements Comparable%3CNode%3E %7B%0A%09public int adjacent;%0A    public int cost;%0A %0A%09public Node(int ady, int c) %7B%0A%09    this.adjacent = ady;%0A%09    this.cost = c;%0A    %7D%0A %0A%09@Override%0A%09public int compareTo(Node o) %7B%0A%09    if (this.cost %3E= o.cost)  return 1;%0A        else    return -1;%0A%09%7D%0A%7D 

Add Prim algorithm java