forked from chaandchopra/MinimumSpanningTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriverClass.java
More file actions
38 lines (37 loc) · 1.18 KB
/
DriverClass.java
File metadata and controls
38 lines (37 loc) · 1.18 KB
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
/**
* Test class
*
* @author 17MCMC34,40
* @version (a version number or a date)
*/
import java.io.*;
import com.assignment.Graph;
import com.assignment.InputFile;
public class DriverClass
{
public static void main(String[] args){
try{
InputFile f = new InputFile();
Graph g = f.getGraphFromFile(args[0]);
System.out.println("\nInput Graph : ");
System.out.println(g);
System.out.println("Total weight of graph: "+ g.totalWeight);
Graph mst = g.prims();
System.out.println("\nCorresponding MST : ");
System.out.println(mst);
System.out.println("Total weight of mst: "+ mst.totalWeight);
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Please enter a valid input file as command line argument");
}
catch(NegativeArraySizeException e){
System.out.println("Graph creation error. Provide valid graph file");
}
catch(FileNotFoundException e){
System.out.println("File not found. Please check the input file name & path");
}
catch(Exception e) {
System.out.println(e);
}
}
}