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 Comparator<E> |
edge_comparator
Comparator used in ordering edges. |
protected 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(Comparator<V> vertex_comparator,
Comparator<E> edge_comparator)
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> com.google.common.base.Supplier<Graph<V,E>> |
getFactory() |
void |
setVertexComparator(Comparator<V> vertex_comparator)
Provides a new
Comparator to be used in sorting the vertices. |
getIncidentEdges, getNeighbors, getPredecessors, getSuccessors
addEdge, containsEdge, containsVertex, findEdge, getDefaultEdgeType, getDest, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getEndpoints, getIncoming_internal, getInEdges, getOutEdges, getOutgoing_internal, getSource, getVertexCount, getVertices, isDest, isSource, removeEdge, removeVertex
addEdge, addEdge, addEdge, addEdge, addEdge, degree, findEdgeSet, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree, toString
protected Comparator<V> vertex_comparator
Comparator
used in ordering vertices. Defaults to util.ComparableComparator
if no comparators are specified in the constructor.protected Comparator<E> edge_comparator
Comparator
used in ordering edges. Defaults to util.ComparableComparator
if no comparators are specified in the constructor.public SortedSparseMultigraph(Comparator<V> vertex_comparator, Comparator<E> edge_comparator)
Comparator
s.vertex_comparator
- specifies how the vertices are to be comparededge_comparator
- specifies how the edges are to be comparedpublic SortedSparseMultigraph()
public static <V,E> com.google.common.base.Supplier<Graph<V,E>> getFactory()
V
- the vertex type for the graph SupplierE
- the edge type for the graph SupplierSupplier
that creates an instance of this graph type.public void setVertexComparator(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 © 2015. All rights reserved.