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> Comparatorused in ordering edges.protected Comparator<V> Comparatorused in ordering vertices.Fields inherited from class 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 specifiedComparators. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAddsvertexto this graph.static <V,E> com.google.common.base.Supplier <Graph<V, E>> voidsetVertexComparator(Comparator<V> vertex_comparator) Provides a newComparatorto be used in sorting the vertices.Methods inherited from class OrderedSparseMultigraph
getIncidentEdges, getNeighbors, getPredecessors, getSuccessorsMethods inherited from class 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, removeVertexMethods inherited from class 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
Comparatorused in ordering vertices. Defaults toutil.ComparableComparatorif no comparators are specified in the constructor. -
edge_comparator
Comparatorused in ordering edges. Defaults toutil.ComparableComparatorif no comparators are specified in the constructor.
-
-
Constructor Details
-
SortedSparseMultigraph
Creates a new instance which sorts its vertices and edges according to the specifiedComparators.- 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
Supplierthat creates an instance of this graph type.
-
setVertexComparator
Provides a newComparatorto be used in sorting the vertices.- Parameters:
vertex_comparator- the comparator that defines the new ordering
-
addVertex
Description copied from interface:HypergraphAddsvertexto this graph. Fails ifvertexis null or already in the graph.- Specified by:
addVertexin interfaceHypergraph<V,E> - Overrides:
addVertexin classOrderedSparseMultigraph<V,E> - Parameters:
vertex- the vertex to add- Returns:
trueif the add is successful, andfalseotherwise
-