TreeEdge.java 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package pathgame.algorithm;
  2. public class TreeEdge implements Comparable< TreeEdge > {
  3. private int src, dest, weight;
  4. private boolean checked = false;
  5. public TreeEdge(int src, int dest, int weight) {
  6. this.src = src;
  7. this.dest = dest;
  8. this.weight = weight;
  9. }
  10. public int getSrc() {
  11. return src;
  12. }
  13. public int getDest() {
  14. return dest;
  15. }
  16. public int getOtherVertex(int other) {
  17. if(other == src) {
  18. return dest;
  19. }
  20. else {
  21. return src;
  22. }
  23. }
  24. public Integer getWeight() {
  25. return weight;
  26. }
  27. public boolean isChecked() {
  28. return checked;
  29. }
  30. public void setChecked(boolean checked) {
  31. this.checked = checked;
  32. }
  33. @Override
  34. public int compareTo(TreeEdge o) {
  35. return this.getWeight().compareTo(o.getWeight());
  36. }
  37. }