Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WEIGHT
Default weight of an edge in an undirected graph (1).
|
E |
extraData |
Constructor and Description |
---|
Edge(Vertex<V> start,
Vertex<V> end)
Constructs information about the given edge with the default edge weight.
|
Edge(Vertex<V> start,
Vertex<V> end,
double weight)
Constructs information about the given edge with the default edge weight.
|
Modifier and Type | Method and Description |
---|---|
Edge<V,E> |
clone()
Returns a copy of this Edge as per the contract of the Object.clone method.
|
boolean |
contains(Vertex<V> vertex)
Returns true if this edge touches the given vertex, that is,
if it is the start or end of this edge.
|
double |
cost()
Returns the weight of this edge.
|
Vertex<V> |
end()
Returns the ending vertex of this edge.
|
boolean |
equals(Object o)
Returns true if o refers to an Edge object with identical state to this Edge object.
|
Vertex<V> |
finish()
Returns the ending vertex of this edge.
|
int |
hashCode()
Returns an integer code for placing this edge into a hash-based collection.
|
void |
setWeight(double weight)
Modifies this edge's weight to be the given value.
|
Vertex<V> |
start()
Returns the starting vertex of this edge.
|
String |
toString()
Returns a string representation of the information about this edge.
|
double |
weight()
Returns the weight of this edge.
|
public static final int DEFAULT_WEIGHT
public E extraData
public Edge(Vertex<V> start, Vertex<V> end)
start
- The starting vertex of the edge.end
- The ending vertex of the edge.edge
- The extra information (if any) to store in this edge; null if none.NullPointerException
- If the start or end vertex is null.public Edge(Vertex<V> start, Vertex<V> end, double weight)
start
- The starting vertex of the edge.end
- The ending vertex of the edge.edge
- The extra information (if any) to store in this edge; null if none.NullPointerException
- If the start or end vertex is null.public Edge<V,E> clone()
public boolean contains(Vertex<V> vertex)
NullPointerException
- If the vertex is null.public double cost()
public Vertex<V> end()
public boolean equals(Object o)
public Vertex<V> finish()
public int hashCode()
public void setWeight(double weight)
weight
- The new weight to use.IllegalArgumentException
- If the weight is negative.public Vertex<V> start()
public double weight()