public class Edge<T>implement Comparable<Edge>{
private T start;//起点
private T end;//终点
private int distance;
public Edge(T start,T end,int distance){
this.start=start;
this.end=end;
this.diastance=distance;
}
public T getStart() {
return start;
}
public void setStart(T start) {
this.start = start;
}
public T getEnd() {
return end;
}
public void setEnd(T end) {
this.end = end;
}
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
@Override
public int compareTo(Edge obj){
int targetDistance=obj.getDistance();
return this.distance>targetDis?1:(distance==targetDis?0:-1);
}
@Override
public String toString() {
// TODO Auto-generated method stub
return start+"->"+end+":"+distance;
}
}
图的边集
最新推荐文章于 2023-07-04 14:48:05 发布