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()
DirectedEdge
from
in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>
public int to()
DirectedEdge
to
in interface DirectedEdge<T extends java.lang.Comparable<? super T>,WeightedEdge<T extends java.lang.Comparable<? super T>>>
public WeightedEdge<T> reversed()
DirectedEdge
DirectedEdge.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()
DirectedEdge
weight
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.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(WeightedEdge<T> other)
compareTo
in interface java.lang.Comparable<WeightedEdge<T extends java.lang.Comparable<? super T>>>