forked from liornagar799/Ex2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx2.java
50 lines (44 loc) · 1.58 KB
/
Ex2.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
import api.*;
/**
* This class is the main class for Ex2 - your implementation will be tested using this class.
*/
public class Ex2 {
/**
* This static function will be used to test your implementation
* @param json_file - a json file (e.g., G1.json - G3.gson)
* @return
*/
public static DirectedWeightedGraph getGrapg(String json_file) {
DirectedWeightedGraph g = new DirectedWeightedGraphImpl();
DirectedWeightedGraphAlgorithms algo = new DirectedWeightedGraphAlgorithmsImpl();
algo.init(g);
algo.load(json_file);
DirectedWeightedGraph ans = algo.copy();
return ans;
}
/**
* This static function will be used to test your implementation
* @param json_file - a json file (e.g., G1.json - G3.gson)
* @return
*/
public static DirectedWeightedGraphAlgorithms getGrapgAlgo(String json_file) {
DirectedWeightedGraph g = new DirectedWeightedGraphImpl();
DirectedWeightedGraphAlgorithms algo = new DirectedWeightedGraphAlgorithmsImpl();
algo.init(getGrapg(json_file));
algo.load(json_file);
DirectedWeightedGraphAlgorithms ans = algo;
return ans;
}
/**
* This static function will run your GUI using the json fime.
* @param json_file - a json file (e.g., G1.json - G3.gson)
*/
public static void runGUI(String json_file) {
DirectedWeightedGraphAlgorithms alg = getGrapgAlgo(json_file);
new GUI(alg.getGraph());
}
public static void main(String[] args) {
String file = args[0];
runGUI(file);
}
}