Archive for January, 2009

Dijkstra for All Pair Shortest Path using Java

Friday, January 9th, 2009

Graph Problem Using Java. Mostly, people used Floyd-Warshall to solve All Pair Shortest Path problem. But, I try to solve all pair shortest path problem using Dijkstra and it works. The Source code can be seen below. import java.util.*; public class DijkstraASP{ public static void main(String args[]){ Main m =new Main(); } } class Verteks{ int no; int value; String color; Verteks(int no ...

MST (Minimum Spanning Tree) Using Kruskal and Disjoint Sets in Java

Friday, January 9th, 2009

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]