T - the weight type of this edge.public final class WeightedEdge<T extends java.lang.Comparable<? super T>> extends java.lang.Object implements DirectedEdge<T,WeightedEdge<T>>, java.lang.Comparable<WeightedEdge<T>>
| Constructor and Description |
|---|
WeightedEdge(int from,
int to,
T weight)
Create a new weighted edge from from to to with the given weight
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(WeightedEdge<T> other) |
boolean |
equals(java.lang.Object o) |
int |
from()
Returns where the edge starts.
|
int |
hashCode() |
WeightedEdge<T> |
reversed()
Returns a new edge with
DirectedEdge.from() and DirectedEdge.to() swapped. |
WeightedEdge<T> |
reweighted(T weight)
Creates a new edge linking the same two vertices with the given weight.
|
int |
to()
Returns where the edge ends.
|
java.lang.String |
toString() |
T |
weight()
Returns the weight of the edge.
|
public WeightedEdge(int from,
int to,
T weight)
from - the vertex where this edge startsto - the vertex on which this edge endsweight - the weight of the edgepublic WeightedEdge<T> reweighted(T weight)
weight - the weight of the new edgepublic int from()
DirectedEdgefrom in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>public int to()
DirectedEdgeto in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>public WeightedEdge<T> reversed()
DirectedEdgeDirectedEdge.from() and DirectedEdge.to() swapped.reversed in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>DirectedEdge.from() and DirectedEdge.to() swappedpublic T weight()
DirectedEdgeweight in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(WeightedEdge<T> other)
compareTo in interface java.lang.Comparable<WeightedEdge<T extends java.lang.Comparable<? super T>>>