V - Vertex typepublic class Edge<V extends Vertible<V>> extends Object
Graph class), it is needed as
basis for some additional tasks, e.g., graph visualization.| Modifier and Type | Field and Description |
|---|---|
protected boolean |
directed
Flag indicating whether this edge is directed.
|
protected V |
end
The end vertex of this edge.
|
protected String |
label
The label of thius graph.
|
protected V |
start
The start vertex of this edge.
|
protected double |
weight
The weight of this edge.
|
protected boolean |
weighted
Flag indicating whether this edge is directed.
|
| Constructor and Description |
|---|
Edge(String label,
V startVertex,
V endVertex) |
Edge(String label,
V startVertex,
V endVertex,
boolean directed) |
Edge(String label,
V startVertex,
V endVertex,
boolean directed,
double weight) |
Edge(V startVertex,
V endVertex)
Creates a directed edge with the specified vertices.
|
Edge(V v,
V w,
boolean directed)
Creates an edge with the specified properties.
|
Edge(V startVertex,
V endVertex,
boolean directed,
double weight)
Creates a weighted edge with the specified properties.
|
| Modifier and Type | Method and Description |
|---|---|
V |
getEndVertex()
Returns the end vertex of this edge.
|
V |
getStartVertex()
Returns the start vertex of this edge.
|
double |
getWeight()
Returns the weight of this edge.
|
boolean |
isDirected()
Returns true if and only if this edge is directed.
|
boolean |
isWeighted()
Returns true if and only if this edge is weighted.
|
String |
toString()
Returns the label of this edge, or the weight if the edge is weighted.
|
protected String label
protected boolean directed
protected boolean weighted
protected double weight
public Edge(V startVertex, V endVertex)
startVertex - the start vertex of this edgeendVertex - the end vertex of this edgepublic Edge(V v, V w, boolean directed)
v - the start vertex of this edgew - the end vertex of this edgedirected - flag indicating whether this edge is directedpublic Edge(String label, V startVertex, V endVertex)
label - the label of this edgestartVertex - the start vertex of this edgeendVertex - the end vertex of this edgepublic Edge(String label, V startVertex, V endVertex, boolean directed)
label - the label of this edgestartVertex - the start vertex of this edgeendVertex - the end vertex of this edgedirected - flag indicating whether this edge is directedpublic Edge(V startVertex, V endVertex, boolean directed, double weight)
startVertex - the start vertex of this edgeendVertex - the end vertex of this edgedirected - flag indicating whether this edge is directedweight - the weight of this edgepublic Edge(String label, V startVertex, V endVertex, boolean directed, double weight)
label - the label of this edgestartVertex - the start vertex of this edgeendVertex - the end vertex of this edgedirected - flag indicating whether this edge is directedweight - the weight of this edgepublic V getStartVertex()
public V getEndVertex()
public boolean isDirected()
public boolean isWeighted()
public double getWeight()
throws IllegalArgumentException
IllegalArgumentException - if this method is called in case of an unweighted edge