-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
37 lines (37 loc) · 1.03 KB
/
Node.java
File metadata and controls
37 lines (37 loc) · 1.03 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
/* Project 3
* Abdul Moid Munawar, amunawar, amunawar@u.rochester.edu
* Moazzam Salman, msalman, msalman@u.rochseter.edu
*/
import java.util.HashMap;
/**This class represnts an Intersection/ a Node**/
public class Node implements Comparable<Node> {
double distToSource;
String id;
double lattitude;
double longitude;
boolean visited=false;
Node updater;//acts as parent of Node during Dijsktras Algorithm
HashMap<Node, Edge> adjlist;// stores the edges that this node is connected to (undirected graph)
// constructor
public Node(String id, double lat, double lon) {
this.id = id;
this.lattitude = lat;
this.longitude = lon;
adjlist = new HashMap<Node, Edge>();
}
/** This method will allow priority queueu to know to order Nodes according to their distance from source**/
@Override
public int compareTo(Node arg) {
if(this.distToSource<arg.distToSource) {
return -1;
}
else if(this.distToSource>arg.distToSource) {
return 1;
}
return 0;
}
@Override
public String toString() {
return "Node [ id=" + id + "]";
}
}