MST (Minimum Spanning Tree) Using Kruskal and Disjoint Sets in Java
January 9th, 2009 | by admin |Solution of Problem 1676 - Networking on TOJ.
Using Kruskal Algorithm and Disjoint Sets
Source :
Introduction of Algorithm, Thomas H. Cormen dkk
Data Structures and Problem Solving Using Java, Mark Allen Weiss
import java.util.*;
class DisjointSets{
int s[];
DisjointSets(int size){
s = new int[size];
Arrays.fill(s,-1);
}
public void gabung(int r1,int r2){
if(s[r1] list = new ArrayList();
DisjointSets d = new DisjointSets(route);
for(int i=0 ; i(){
public int compare(Edge a,Edge b){
return a.weight-b.weight;
}
});
int hasil=0;
for(int i=0 ; i
One Response to “MST (Minimum Spanning Tree) Using Kruskal and Disjoint Sets in Java”
By Sely Haudy on Mar 24, 2009 | Reply
Wah, bung ferdi tulisannya berat berat sekalehhh
hohohoohohohohoh