-
Notifications
You must be signed in to change notification settings - Fork 0
/
CITS2200ProjectTester.java
39 lines (35 loc) · 1.16 KB
/
CITS2200ProjectTester.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
import java.io.*;
//import java.util.*;
public class CITS2200ProjectTester {
public static void loadGraph(CITS2200Project project, String path) {
// The graph is in the following format:
// Every pair of consecutive lines represent a directed edge.
// The edge goes from the URL in the first line to the URL in the second line.
try {
BufferedReader reader = new BufferedReader(new FileReader(path));
while (reader.ready()) {
String from = reader.readLine();
String to = reader.readLine();
System.out.println("Adding edge from " + from + " to " + to);
project.addEdge(from, to);
}
reader.close();
} catch (Exception e) {
System.out.println("There was a problem:");
System.out.println(e.toString());
}
}
public static void main(String[] args) {
// Change this to be the path to the graph file.
String pathToGraphFile = "testdata/example_graph.txt";
// Create an instance of your implementation.
MyProject proj = new MyProject();
// Load the graph into the project.
loadGraph(proj, pathToGraphFile);
// Write your own tests!
String[] cen = proj.getCenters();
for (String i : cen){
System.out.println(i);
}
}
}