-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphPlaceholder.java
More file actions
68 lines (54 loc) · 1.7 KB
/
GraphPlaceholder.java
File metadata and controls
68 lines (54 loc) · 1.7 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
67
68
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
public class GraphPlaceholder implements GraphADT<String, Double> {
protected List<String> path;
public GraphPlaceholder() {
path = new ArrayList<>();
path.add("Union South");
path.add("Computer Sciences and Statistics");
path.add("Atmospheric, Oceanic and Space Sciences");
}
public boolean insertNode(String data) {
return false;
}
public boolean removeNode(String data) {
return false;
}
public boolean containsNode(String data) {
return path.contains(data);
}
public int getNodeCount() {
return path.size();
}
public boolean insertEdge(String pred, String succ, Double weight) {
return false;
}
public boolean removeEdge(String pred, String succ) {
return false;
}
public boolean containsEdge(String pred, String succ) {
return (pred.equals("Union South") && succ.equals("Computer Sciences and Statistics"))
|| (pred.equals("Computer Sciences and Statistics")
&& pred.equals("Atmospheric, Oceanic and Space Sciences"));
}
public Double getEdge(String pred, String succ) {
if (pred.equals("Union South") && succ.equals("Computer Sciences and Statistics")) {
return 176.0;
} else if (pred.equals("Computer Sciences and Statistics")
&& pred.equals("Atmospheric, Oceanic and Space Sciences")) {
return 127.2;
} else {
throw new NoSuchElementException();
}
}
public int getEdgeCount() {
return path.size() - 1;
}
public List<String> shortestPathData(String start, String end) {
return path;
}
public double shortestPathCost(String start, String end) {
return 303.2;
}
}