Package dev.nm.graph.type
Class SimpleEdge<V>
- java.lang.Object
-
- dev.nm.graph.type.SimpleEdge<V>
-
- Type Parameters:
V
- vertex type
- All Implemented Interfaces:
Edge<V>
,HyperEdge<V>
,UndirectedEdge<V>
,WeightedEdge<V>
public class SimpleEdge<V> extends Object implements WeightedEdge<V>, UndirectedEdge<V>
A simple edge has two vertices.
-
-
Constructor Summary
Constructors Constructor Description SimpleEdge(V v1, V v2)
Construct a simple edge.SimpleEdge(V v1, V v2, double cost)
Construct a simple edge.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
cost()
Gets the cost or weight of this edge.V
neighbor(V vertex)
Get the unique neighboring vertex connected tovertex
.Set<V>
neighbors(V vertex)
Gets the set of neighboring vertices connected tovertex
.String
toString()
Set<V>
vertices()
Gets the set of vertices associated with the edge.
-
-
-
Method Detail
-
cost
public double cost()
Description copied from interface:WeightedEdge
Gets the cost or weight of this edge.- Specified by:
cost
in interfaceWeightedEdge<V>
- Returns:
- the edge cost
-
vertices
public Set<V> vertices()
Description copied from interface:HyperEdge
Gets the set of vertices associated with the edge.
-
neighbors
public Set<V> neighbors(V vertex)
Description copied from interface:HyperEdge
Gets the set of neighboring vertices connected tovertex
.
-
neighbor
public V neighbor(V vertex)
Get the unique neighboring vertex connected tovertex
. It may be the same asvertex
to account for self loop.
-
-