public class SortedSparseMultigraph<V,E> extends OrderedSparseMultigraph<V,E> implements MultiGraph<V,E>
Graph
that is suitable for sparse graphs,
orders its vertex and edge collections according to either specified Comparator
instances or the natural ordering of their elements, and permits directed, undirected,
and parallel edges.Modifier and Type | Field and Description |
---|---|
protected java.util.Comparator<E> |
edge_comparator
Comparator used in ordering edges. |
protected java.util.Comparator<V> |
vertex_comparator
Comparator used in ordering vertices. |
directedEdges, edges, vertices
Constructor and Description |
---|
SortedSparseMultigraph()
Creates a new instance which sorts its vertices and edges according to
their natural ordering.
|
SortedSparseMultigraph(java.util.Comparator<V> vertexComparator,
java.util.Comparator<E> edgeComparator)
Creates a new instance which sorts its vertices and edges according to the
specified
Comparator s. |
Modifier and Type | Method and Description |
---|---|
boolean |
addVertex(V vertex)
Adds
vertex to this graph. |
static <V,E> Factory<Graph<V,E>> |
getFactory()
Returns a
Factory that creates an instance of this graph type. |
void |
setVertexComparator(java.util.Comparator<V> vertex_comparator)
Provides a new
Comparator to be used in sorting the vertices. |
getIncidentEdges, getNeighbors, getPredecessors, getSuccessors
addEdgeWithEndpoints, containsEdge, containsVertex, findEdge, getDefaultEdgeType, getDest, getEdgeCount, getEdgeCount, getEdges, getEdgesView, getEdgeType, getEndpoints, getIncoming_internal, getInEdges, getOutEdges, getOutgoing_internal, getSource, getVertexCount, getVerticesView, isDest, isSource, removeEdge, removeVertex
addEdge, addEdge, addEdgeWithEndPoints, addEdgeWithVertices, addEdgeWithVertices, degree, findEdgeSet, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree
protected java.util.Comparator<V> vertex_comparator
Comparator
used in ordering vertices. Defaults to util.ComparableComparator
if no comparators are specified in the constructor.protected java.util.Comparator<E> edge_comparator
Comparator
used in ordering edges. Defaults to util.ComparableComparator
if no comparators are specified in the constructor.public SortedSparseMultigraph(java.util.Comparator<V> vertexComparator, java.util.Comparator<E> edgeComparator)
Comparator
s.public SortedSparseMultigraph()
public static <V,E> Factory<Graph<V,E>> getFactory()
Factory
that creates an instance of this graph type.V
- the vertex type for the graph factoryE
- the edge type for the graph factorypublic void setVertexComparator(java.util.Comparator<V> vertex_comparator)
Comparator
to be used in sorting the vertices.vertex_comparator
- the comparator that defines the new orderingpublic boolean addVertex(V vertex)
Hypergraph
vertex
to this graph. Fails if vertex
is null or already in the graph.addVertex
in interface Hypergraph<V,E>
addVertex
in class OrderedSparseMultigraph<V,E>
vertex
- the vertex to addtrue
if the add is successful, and false
otherwiseCopyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence