Added a Graph datastructure and refactored the Line/Vertex classes

This commit is contained in:
Quinn
2023-05-02 09:49:38 -05:00
parent 9b0acbe34c
commit 3321e77061
18 changed files with 859 additions and 68 deletions

59
src/Graph/Edge.java Normal file
View File

@@ -0,0 +1,59 @@
package Graph;
public class Edge {
Vertex vStart = null;
Vertex vEnd = null;
float weight = 0;
/**
* @param vStart the vertex the edge starts at
* @param vEnd the vertex the edge ends at
* @param weight the weight of the edge
*/
Edge(Vertex vStart, Vertex vEnd, float weight){
this.vStart = vStart;
this.vEnd = vEnd;
this.weight = weight;
}
/**
* @param vStart the vertex the edge starts at
* @param vEnd the vertex the edge ends at
*/
Edge(Vertex vStart, Vertex vEnd){
this.vStart = vStart;
this.vEnd = vEnd;
}
Edge(){}
/**
* @return the weight of the edge
*/
public float getWeight(){
return weight;
}
/**
* @param newWeight set the edge's weight to something new
*/
public void setWeight(float newWeight){
this.weight = newWeight;
}
/**
* @return the vertex at the end of the edge
*/
public Vertex getEndVertex(){
return vEnd;
}
/**
* @return the vertex at the start of the edge
*/
public Vertex getStartVertex(){
return vStart;
}
}