package pathgame.algorithm; /** Class that stores data for a graph edge * */ public class TreeEdge implements Comparable< TreeEdge > { private int src, dest, weight; private boolean checked = false; /** Creates a new TreeEdge with the given parameters * * @param src the index of the source vertex of the edge * @param dest the index of the destination vertex of the edge * @param weight the weight of the edge */ public TreeEdge(int src, int dest, int weight) { this.src = src; this.dest = dest; this.weight = weight; } /** Returns the index of the source vertex of the edge * * @return the index of the source vertex of the edge */ public int getSrc() { return src; } /** Returns the index of the destination vertex of the edge * * @return the index of the destination vertex of the edge */ public int getDest() { return dest; } /** Returns the index of the other vertex, using the given vertex * * @param other the vertex index that shouldn't be returned * @return the other vertex index */ public int getOtherVertex(int other) { if(other == src) { return dest; } else { return src; } } /** Returns the weight of the edge * * @return the weight of the edge */ public Integer getWeight() { return weight; } /** Returns isChecked, which is true if the TreeEdge has been checked * * @return whether this TreeEdge has been checked */ public boolean isChecked() { return checked; } /** Sets isChecked, which is true if the TreeEdge has been checked * * @param checked new status of whether this TreeEdge has been checked */ public void setChecked(boolean checked) { this.checked = checked; } /** Used for sorting Collections of TreeEdges * * @param o the TreeEdge that this one is being compared to * @return the result of compareTo() */ @Override public int compareTo(TreeEdge o) { return this.getWeight().compareTo(o.getWeight()); } }