import java.util.ArrayList;
//Represents vertices of the graph
public class Vertex implements Comparable<Vertex>{
private ArrayList<Edge> outGoingEdges=new ArrayList<>();//out going edges from the node
private String val;//node value
private boolean visited; //visited or not
private Double distance = Double.POSITIVE_INFINITY;//initial distances infinity
private Vertex prev=null;//previous node
public Vertex getPrev() {
return prev;
}
public void setPrev(Vertex prev) {
this.prev = prev;
}
boolean isStart;
public Vertex(String val){
this.val=val;
this.isStart=false;
}
public void addEdge(Vertex dest,double weight){
this.outGoingEdges.add(new Edge(dest, weight));
}
//getter and setters
public ArrayList<Edge> getOutGoingEdges() {
return outGoingEdges;
}
public void setOutGoingEdges(ArrayList<Edge> outGoingEdges) {
this.outGoingEdges = outGoingEdges;
}
public boolean isVisited() {
return visited;
}
public String getVal() {
return val;
}
public void setVal(String val) {
this.val = val;
}
public void setVisited(boolean visited) {
this.visited = visited;
}
public Double getDistance() {
return distance;
}
public void setDistance(Double distance) {
this.distance = distance;
}
@Override
public int compareTo(Vertex o) {
return this.distance.compareTo(o.getDistance());
}
}