1 19 20 package edu.umd.cs.findbugs.graph; 21 22 30 public class AbstractEdge 31 < 32 ActualEdgeType extends AbstractEdge<ActualEdgeType, VertexType>, 33 VertexType extends AbstractVertex<ActualEdgeType, VertexType> 34 > implements GraphEdge<ActualEdgeType, VertexType> { 35 36 private VertexType source; 37 private VertexType target; 38 private int label; 39 private ActualEdgeType nextOutgoingEdge; 40 private ActualEdgeType nextIncomingEdge; 41 42 47 public AbstractEdge(VertexType source, VertexType target) { 48 this.source = source; 49 this.target = target; 50 } 51 52 public VertexType getSource() { 53 return source; 54 } 55 56 public VertexType getTarget() { 57 return target; 58 } 59 60 public int getLabel() { 61 return label; 62 } 63 64 public void setLabel(int label) { 65 this.label = label; 66 } 67 68 public int hashCode() { 69 return source.hashCode() + target.hashCode()*3; 70 } 71 public boolean equals(Object o) { 72 if (!(o instanceof AbstractEdge)) return false; 73 ActualEdgeType other = (ActualEdgeType) o; 74 return source.equals(other.source) && target.equals(other.target); 75 } 76 public int compareTo(ActualEdgeType other) { 77 int cmp = source.compareTo(other.source); 78 if (cmp != 0) 79 return cmp; 80 return target.compareTo(other.target); 81 } 82 83 void setNextOutgoingEdge(ActualEdgeType edge) { 84 nextOutgoingEdge = edge; 85 } 86 87 ActualEdgeType getNextOutgoingEdge() { 88 return nextOutgoingEdge; 89 } 90 91 void setNextIncomingEdge(ActualEdgeType edge) { 92 nextIncomingEdge = edge; 93 } 94 95 ActualEdgeType getNextIncomingEdge() { 96 return nextIncomingEdge; 97 } 98 99 } 100 101 | Popular Tags |