-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCampusMain.java
More file actions
61 lines (55 loc) · 2.01 KB
/
Copy pathCampusMain.java
File metadata and controls
61 lines (55 loc) · 2.01 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
package hw8;
import java.util.*;
import hw5.Edge;
import hw5.Graph;
import hw7.MarvelPaths2;
import hw8.Buildings;
/**
* CampusMain is a class which gives the entire building information from an
* abbreviated name and finds the shortest path between two buildings.
*
*
* @author RibhavHora
*/
public class CampusMain {
// This class does not represent an ADT.
/**
* Returns the entire Buildings object from the abbreviated name
*
* @param shortName
* the abbreviated name of the building whose entire Buildings object is needed
* @param buildingData
* the name of the file which contains the abbreviated name, full name
* and x and y pixel coordinates separated by tabs
* @returns the corresponding buildings object of the abbreviated shortName
*/
public static Buildings fullBuilding(String shortName, String buildingData) {
assert shortName != null : "shortName cannot be null";
assert buildingData != null : "buildingData cannot be null";
Set<Buildings> nameBuildings = new HashSet<Buildings>();
Map<String, Buildings> shorts = new HashMap<String, Buildings>();
try {
PathParser.parseBuildingData(buildingData, nameBuildings, shorts);
} catch (Exception e) {
System.err.println(e.toString());
e.printStackTrace(System.err);
}
return shorts.get(shortName);
}
/**
* @param startNode
* the starting building from who you want the path to begin
* @param endNode
* the ending building where you want the path to end
* @param graph
* the graph you want to search the path in
* @requires both startNode and endNode are in the graph
* @returns a list of edges that show the shortest path between startNode
* and endNode, returns null if path was not found or buildings
* are not in the graph
*/
public static List<Edge<Buildings, Double>> findPath(Buildings startNode, Buildings endNode,
Graph<Buildings, Double> graph) {
return MarvelPaths2.findPath(startNode, endNode, graph);
}
}