-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject1.java
55 lines (45 loc) · 1.49 KB
/
project1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package project1;
import java.io.IOException;
public class project1 {
public static void main(String args[]) throws IOException{
System.gc();
System.out.println("Enter 1 for random mode then give nodes and density as arguments");
System.out.println("Enter 2 for file mode and give file name as argument");
int size=0;
int density=0;
if(Integer.parseInt(args[0])==1){
size = Integer.parseInt(args[1]);
density = Integer.parseInt(args[2]);
if(density> ((size*(size-1))/2))
{
density=(size*(size-1))/2; // Maximum no. of edges
}
GenGraph g= new GenGraph(size, density);
g.makeGraph();
// calling for finding mst
mst m= new mst(g.getNeighbourlist(),size);
mstFheap m1= new mstFheap(g.getNeighbourlist(), size);
System.out.println("Normal data structure cose:-"+m.start());
m1.start();
System.out.println("Fibonacci Heap data structure:-"+m1.cost());
//m1.print();
}
else if(Integer.parseInt(args[0])==2){
GraphFile g= new GraphFile();
g.fileRead(args[1]);
size=g.getSize();
density=g.getDensity();
if(density> ((size*(size-1))/2))
{
density=(size*(size-1))/2; // Maximum no. of edges
}
// calling for finding mst
mst m= new mst(g.getNeighbourlist(),size);
mstFheap m1= new mstFheap(g.getNeighbourlist(), size);
System.out.println("Normal data structure cose:-"+m.start());
m1.start();
System.out.println("Fibonacci Heap data structure:-"+m1.cost());
//m1.print();
}
}
}