V
- vertex typeE
- edge typepublic class SparseGraph<V,E extends HyperEdge<V>> extends Object implements Graph<V,E>
Constructor and Description |
---|
SparseGraph()
Construct an empty graph.
|
SparseGraph(Graph<V,E> g)
(Copy) construct a graph from another graph.
|
Modifier and Type | Method and Description |
---|---|
SparseGraph<V,E> |
addEdge(E e)
Adds an edge to this graph.
|
SparseGraph<V,E> |
addVertex(V v)
Adds a vertex to this graph.
|
boolean |
contains(V v)
Check if this graph contains a vertex.
|
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.
|
SparseGraph<V,E> |
removeEdge(E e)
Removes an edge from this graph.
|
SparseGraph<V,E> |
removeVertex(V v)
Removes a vertex from this graph.
|
String |
toString() |
Set<V> |
vertices()
Gets the set of all vertices in this graph.
|
public Set<V> vertices()
Graph
public Set<E> edges()
Graph
public Set<E> edges(V v)
Graph
public SparseGraph<V,E> addVertex(V v)
Graph
v
is already in the graph.public SparseGraph<V,E> addEdge(E e)
Graph
e
is already in the graph.
If the edge contains new vertices, those will be added to the graph.public SparseGraph<V,E> removeVertex(V v)
Graph
v
is not in the graph.
The edges associated with this vertex are also removed.public SparseGraph<V,E> removeEdge(E e)
Graph
e
is not in the graph.
The vertices associated with the edge is not removed.public boolean contains(V v)
v
- a vertextrue
if this graph contains the vertexCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.