-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSTTest.java
More file actions
58 lines (53 loc) · 1.48 KB
/
MSTTest.java
File metadata and controls
58 lines (53 loc) · 1.48 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package app;
import java.io.IOException;
//import java.util.ArrayList;
import java.util.Scanner;
import structures.*;
import structures.Graph;
import java.util.ArrayList;
import java.util.Iterator;
import structures.PartialTree;
/**
* Minimum Spanning Tree Driver
* @author Saaqeb
*
*/
public class MSTTest {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
Graph graph;
while (true) {
System.out.print("\nName of graph file: ");
try {
graph = new Graph(sc.next());
break;
} catch (IOException e) {
System.out.println("\nFile does not exist!");
}
}
PartialTreeList ptl = PartialTreeList.initialize(graph);
Iterator<PartialTree> n = ptl.iterator();
while(n.hasNext()) {
PartialTree pt = n.next();
System.out.println(pt.toString());
}
//PartialTreeList MST = new PartialTreeList();
ArrayList<Arc> al = new ArrayList<Arc>();
al = PartialTreeList.execute(ptl);
System.out.println(al);//ArrayList<Arc> al =
System.out.print("\nMST Arcs: ");
for (int i = 0; i < al.size(); i++) {
System.out.print(al.get(i).toString() +" ");
}
System.out.print("\n\nTry another file? (y or n): ");
String s = sc.next();
while (!s.equals("y") && !s.equals("n")) {
System.out.print("\nIncorrect input!\n\nTry another file? (y or n): ");
s = sc.next();
}
if (s.equals("n")) break;
}
sc.close();
}
}