Package com.phasmidsoftware.gryphon.java
Class Edge<V>
java.lang.Object
com.phasmidsoftware.gryphon.java.Edge<V>
- Type Parameters:
V- the vertex type.
- Direct Known Subclasses:
WeightedEdge
Represents an unweighted directed or undirected edge between two vertices.
An Edge<V> carries only structural information — the two endpoint
vertices. For edges that carry a weight or attribute, use
WeightedEdge<V, E> instead.
Edges are immutable. Equality is based on both endpoints.
Usage example:
Edge<String> e = new Edge<>("A", "B");
String from = e.from(); // "A"
String to = e.to(); // "B"
Edge<String> rev = e.reverse(); // Edge("B", "A")
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Edge
Constructs an edge fromfromtoto.- Parameters:
from- the source vertex.to- the target vertex.
-
-
Method Details
-
of
Creates a newEdgefromfromtoto.- Type Parameters:
V- the vertex type.- Parameters:
from- the source vertex.to- the target vertex.- Returns:
- a new
Edge.
-
from
Returns the source vertex of this edge.- Returns:
- the source vertex.
-
to
Returns the target vertex of this edge.- Returns:
- the target vertex.
-
reverse
Returns an edge with the endpoints swapped.For an undirected graph this is equivalent to the original edge; for a directed graph it represents the reverse arc.
- Returns:
- the reversed edge.
-
equals
-
hashCode
public int hashCode() -
toString
-