TreeEdge.java 988 B

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