Package dev.nm.graph.type
Class SparseGraph<V,E extends HyperEdge<V>>
- java.lang.Object
-
- dev.nm.graph.type.SparseGraph<V,E>
-
- Type Parameters:
V- vertex typeE- edge type
- All Implemented Interfaces:
Graph<V,E>
- Direct Known Subclasses:
SparseDiGraph,SparseUnDiGraph
public class SparseGraph<V,E extends HyperEdge<V>> extends Object implements Graph<V,E>
This class implements the sparse graph representation.
-
-
Constructor Summary
Constructors Constructor Description SparseGraph()Construct an empty graph.SparseGraph(Graph<V,E> g)(Copy) construct a graph from another graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.booleancontains(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.StringtoString()Set<V>vertices()Gets the set of all vertices in this graph.
-
-
-
Method Detail
-
vertices
public Set<V> vertices()
Description copied from interface:GraphGets the set of all vertices in this graph.
-
edges
public Set<E> edges()
Description copied from interface:GraphGets the set of all edges in this graph.
-
edges
public Set<E> edges(V v)
Description copied from interface:GraphGets the set of all edges associated with a vertex in this graph.
-
addVertex
public SparseGraph<V,E> addVertex(V v)
Description copied from interface:GraphAdds a vertex to this graph. Does nothing ifvis already in the graph.
-
addEdge
public SparseGraph<V,E> addEdge(E e)
Description copied from interface:GraphAdds an edge to this graph. Does nothing ifeis already in the graph. If the edge contains new vertices, those will be added to the graph.
-
removeVertex
public SparseGraph<V,E> removeVertex(V v)
Description copied from interface:GraphRemoves a vertex from this graph. Does nothing ifvis not in the graph. The edges associated with this vertex are also removed.
-
removeEdge
public SparseGraph<V,E> removeEdge(E e)
Description copied from interface:GraphRemoves an edge from this graph. Does nothing ifeis not in the graph. The vertices associated with the edge is not removed.
-
contains
public boolean contains(V v)
Check if this graph contains a vertex.- Parameters:
v- a vertex- Returns:
trueif this graph contains the vertex
-
-