Package dev.nm.graph
Interface Graph<V,E extends HyperEdge<V>>
-
- Type Parameters:
V
- vertex typeE
- edge type
- All Known Subinterfaces:
DAGraph<V,E>
,DiGraph<V,E>
,Forest<V,E>
,RootedTree<V,E>
,Tree<V,E>
,UnDiGraph<V,E>
- All Known Implementing Classes:
SparseDAGraph
,SparseDiGraph
,SparseGraph
,SparseTree
,SparseUnDiGraph
,VertexTree
public interface Graph<V,E extends HyperEdge<V>>
A graph is a representation of a set of objects where some pairs of the objects are connected by links. The interconnected objects are represented by mathematical abstractions called vertices, and the links that connect some pairs of vertices are called edges. In other words, \(G = \left \langle V, E \right \rangle\).- See Also:
- Wikipedia: Graph (mathematics)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Graph<V,E>
addEdge(E e)
Adds an edge to this graph.Graph<V,E>
addVertex(V v)
Adds a vertex to this graph.Set<E>
edges()
Gets the set of all edges in this graph.Set<E>
edges(V v)
Gets the set of all edges associated with a vertex in this graph.Graph<V,E>
removeEdge(E e)
Removes an edge from this graph.Graph<V,E>
removeVertex(V v)
Removes a vertex from this graph.Set<V>
vertices()
Gets the set of all vertices in this graph.
-
-
-
Method Detail
-
vertices
Set<V> vertices()
Gets the set of all vertices in this graph.- Returns:
- all vertices in this graph
-
edges
Set<E> edges(V v)
Gets the set of all edges associated with a vertex in this graph.- Parameters:
v
- a vertex- Returns:
- all edges associated with a vertex
-
addVertex
Graph<V,E> addVertex(V v)
Adds a vertex to this graph. Does nothing ifv
is already in the graph.- Parameters:
v
- the vertex to add- Returns:
- this graph (for builder pattern)
-
addEdge
Graph<V,E> addEdge(E e)
Adds an edge to this graph. Does nothing ife
is already in the graph. If the edge contains new vertices, those will be added to the graph.- Parameters:
e
- the edge to add- Returns:
- this graph (for builder pattern)
-
removeVertex
Graph<V,E> removeVertex(V v)
Removes a vertex from this graph. Does nothing ifv
is not in the graph. The edges associated with this vertex are also removed.- Parameters:
v
- the vertex to be removed- Returns:
- this graph (for builder pattern)
-
-