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>,java.io.Serializable
public class SortedSparseMultigraph<V,E> extends OrderedSparseMultigraph<V,E> implements MultiGraph<V,E>
An implementation ofGraphthat is suitable for sparse graphs, orders its vertex and edge collections according to either specifiedComparatorinstances or the natural ordering of their elements, and permits directed, undirected, and parallel edges.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<E>edge_comparatorComparatorused in ordering edges.protected java.util.Comparator<V>vertex_comparatorComparatorused in ordering vertices.-
Fields inherited from class edu.uci.ics.jung.graph.SparseMultigraph
directedEdges, edges, vertices
-
-
Constructor Summary
Constructors Constructor Description SortedSparseMultigraph()Creates a new instance which sorts its vertices and edges according to their natural ordering.SortedSparseMultigraph(java.util.Comparator<V> vertex_comparator, java.util.Comparator<E> edge_comparator)Creates a new instance which sorts its vertices and edges according to the specifiedComparators.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddVertex(V vertex)Addsvertexto this graph.static <V,E>
com.google.common.base.Supplier<Graph<V,E>>getFactory()voidsetVertexComparator(java.util.Comparator<V> vertex_comparator)Provides a newComparatorto 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 Detail
-
vertex_comparator
protected java.util.Comparator<V> vertex_comparator
Comparatorused in ordering vertices. Defaults toutil.ComparableComparatorif no comparators are specified in the constructor.
-
edge_comparator
protected java.util.Comparator<E> edge_comparator
Comparatorused in ordering edges. Defaults toutil.ComparableComparatorif no comparators are specified in the constructor.
-
-
Constructor Detail
-
SortedSparseMultigraph
public SortedSparseMultigraph(java.util.Comparator<V> vertex_comparator, java.util.Comparator<E> edge_comparator)
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 Detail
-
getFactory
public static <V,E> com.google.common.base.Supplier<Graph<V,E>> 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
public void setVertexComparator(java.util.Comparator<V> vertex_comparator)
Provides a newComparatorto be used in sorting the vertices.- Parameters:
vertex_comparator- the comparator that defines the new ordering
-
addVertex
public boolean addVertex(V vertex)
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
-
-