public class Edge<V,E>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_WEIGHT
Default weight of an edge in an undirected graph (1).
|
Constructor and Description |
---|
Edge(V start,
V end,
E edge)
Constructs information about the given edge with the default edge weight.
|
Edge(V start,
V end,
E edge,
int weight)
Constructs information about the given edge with the given weight.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(V vertex)
Returns true if this edge touches the given vertex, that is,
if it is the start or end of this edge.
|
E |
edge()
Returns the extra information, if any, stored in this edge.
|
V |
end()
Returns the ending vertex of this edge.
|
boolean |
equals(java.lang.Object o)
Returns true if o refers to an Edge object with identical state to this Edge object.
|
int |
hashCode()
Returns an integer code for placing this edge into a hash-based collection.
|
void |
setEdge(E edge)
Modifies this edge's extra information to be the given value.
|
void |
setWeight(int weight)
Modifies this edge's weight to be the given value.
|
V |
start()
Returns the starting vertex of this edge.
|
java.lang.String |
toString()
Returns a string representation of the information about this edge.
|
int |
weight()
Returns the weight of this edge.
|
public static final int DEFAULT_WEIGHT
public Edge(V start, V end, E edge)
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.java.lang.NullPointerException
- If the start or end vertex is null.public Edge(V start, V end, E edge, int 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.weight
- Edge's weight; cannot be negative. Set to 1 in an unweighted graph.java.lang.IllegalArgumentException
- If the weight is negative.java.lang.NullPointerException
- If the start or end vertex is null.public boolean contains(V vertex)
java.lang.NullPointerException
- If the vertex is null.public E edge()
public V end()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the object to examinepublic int hashCode()
hashCode
in class java.lang.Object
public void setEdge(E edge)
edge
- The new information to use.public void setWeight(int weight)
weight
- The new weight to use.java.lang.IllegalArgumentException
- If the weight is negative.public V start()
public int weight()
public java.lang.String toString()
toString
in class java.lang.Object