public interface WeightedGraph extends Graph
The return value of getWeight() may be a "sentinel" value that indicates the requested edge is absent from the graph. Typical sentinels include positive or negative infinity, zero, or NaN. Classes that implement this interface should specify what sentinel value they use, or allow the user to choose their own sentinel.
Note that any of these methods may throw an IndexOutOfBoundsException if any of the input vertex IDs are out of bounds.
Modifier and Type | Method and Description |
---|---|
boolean |
addEdge(int begin,
int end,
double weight)
Adds a weighted edge between two vertices.
|
double |
getWeight(int begin,
int end)
Gets the weight of the edge between two vertices.
|
double |
missingEdgeSentinel()
Returns the "sentinel" weight value for edges not in the graph.
|
boolean |
setWeight(int begin,
int end,
double weight)
Sets the weight of an edge already in the graph.
|
addVertex, clear, getDegree, getInDegree, getNeighbors, hasEdge, isDirected, isEmpty, numEdges, numVerts
boolean addEdge(int begin, int end, double weight)
boolean setWeight(int begin, int end, double weight)
double getWeight(int begin, int end)
double missingEdgeSentinel()