-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
67 lines (51 loc) · 1.64 KB
/
Copy pathMain.java
File metadata and controls
67 lines (51 loc) · 1.64 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
59
60
61
62
63
64
65
66
//STUDENT: Rose Lin
//TEACHER: Mr. Radulovic
//DATE: May 7th, 2019
//DESCRIPTION: Mini ADT Assignment | Main Class
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner file = new Scanner(new File("src/miniAdtAssignment/DATA.txt")); // read file
// establish variables (length, size)
int l = file.nextInt();
int s = file.nextInt();
file.nextLine(); // space
// make the adjList
AdjacencyList d = new AdjacencyList(s); // empty list
String[] genes = new String[s];
for (int i = 0; i < s; i++) {
genes[i] = file.nextLine(); // fill string array with values
}
for (int i = 0; i < s; i++) {
for (int j = 0; j < s; j++) {
d.addEdge(i, genes[i], genes[j]); // add the nodes
}
}
// establish variables (maximum changes, number of genes, before mutation, after
// mutation)
int m = file.nextInt();
int g = file.nextInt();
String[] p;
file.nextLine(); // space
while (file.hasNextLine()) {
p = file.nextLine().split(" ");
BFS bfs = new BFS(p[0], p[1], s, genes, d);
//three cases
if (bfs.compute() != -1 && bfs.compute() <= m) { //if fulfills mutation requirements
System.out.println("YES");
System.out.println(bfs.compute());
}
if (bfs.compute() == -1 ) { //if path does not exist
System.out.println("NO");
System.out.println(bfs.compute());
}
if (bfs.compute() != -1 && bfs.compute() >m) { //if path exceeds maximum number of mutations
System.out.println("NO");
System.out.println(bfs.compute());
}
}
}
}