Package edu.uci.ics.jung.graph
Class SortedSparseMultigraph<V,E>
java.lang.Object
edu.uci.ics.jung.graph.AbstractGraph<V,E>
edu.uci.ics.jung.graph.SparseMultigraph<V,E>
edu.uci.ics.jung.graph.OrderedSparseMultigraph<V,E>
edu.uci.ics.jung.graph.SortedSparseMultigraph<V,E>
- All Implemented Interfaces:
Graph<V,
,E> Hypergraph<V,
,E> MultiGraph<V,
,E> Serializable
public class SortedSparseMultigraph<V,E>
extends OrderedSparseMultigraph<V,E>
implements MultiGraph<V,E>
An implementation of
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.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Comparator
<E> Comparator
used in ordering edges.protected Comparator
<V> Comparator
used in ordering vertices.Fields inherited from class edu.uci.ics.jung.graph.SparseMultigraph
directedEdges, edges, vertices
-
Constructor Summary
ConstructorsConstructorDescriptionCreates 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 specifiedComparator
s. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsvertex
to this graph.static <V,
E> com.google.common.base.Supplier <Graph<V, E>> void
setVertexComparator
(Comparator<V> vertex_comparator) Provides a newComparator
to be used in sorting the vertices.Methods inherited from class edu.uci.ics.jung.graph.OrderedSparseMultigraph
getIncidentEdges, getNeighbors, getPredecessors, getSuccessors
Methods inherited from class edu.uci.ics.jung.graph.SparseMultigraph
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
Methods inherited from class edu.uci.ics.jung.graph.AbstractGraph
addEdge, addEdge, addEdge, addEdge, addEdge, degree, findEdgeSet, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree, toString
-
Field Details
-
vertex_comparator
Comparator
used in ordering vertices. Defaults toutil.ComparableComparator
if no comparators are specified in the constructor. -
edge_comparator
Comparator
used in ordering edges. Defaults toutil.ComparableComparator
if no comparators are specified in the constructor.
-
-
Constructor Details
-
SortedSparseMultigraph
Creates a new instance which sorts its vertices and edges according to the specifiedComparator
s.- Parameters:
vertex_comparator
- specifies how the vertices are to be comparededge_comparator
- specifies how the edges are to be compared
-
SortedSparseMultigraph
public SortedSparseMultigraph()Creates a new instance which sorts its vertices and edges according to their natural ordering.
-
-
Method Details
-
getFactory
- Type Parameters:
V
- the vertex type for the graph SupplierE
- the edge type for the graph Supplier- Returns:
- a
Supplier
that creates an instance of this graph type.
-
setVertexComparator
Provides a newComparator
to be used in sorting the vertices.- Parameters:
vertex_comparator
- the comparator that defines the new ordering
-
addVertex
Description copied from interface:Hypergraph
Addsvertex
to this graph. Fails ifvertex
is null or already in the graph.- Specified by:
addVertex
in interfaceHypergraph<V,
E> - Overrides:
addVertex
in classOrderedSparseMultigraph<V,
E> - Parameters:
vertex
- the vertex to add- Returns:
true
if the add is successful, andfalse
otherwise
-