edu.uci.ics.jung.graph
Class SortedSparseMultigraph<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.graph.AbstractGraph<V,E>
      extended by edu.uci.ics.jung.graph.SparseMultigraph<V,E>
          extended by edu.uci.ics.jung.graph.OrderedSparseMultigraph<V,E>
              extended by 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>, Serializable

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.

Author:
Joshua O'Madadhain
See Also:
Serialized Form

Field Summary
protected  Comparator<E> edge_comparator
          Comparator used in ordering edges.
protected  Comparator<V> vertex_comparator
          Comparator used in ordering vertices.
 
Fields inherited from class edu.uci.ics.jung.graph.SparseMultigraph
directedEdges, edges, vertices
 
Constructor Summary
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 Comparators.
 
Method Summary
 boolean addVertex(V vertex)
          Adds vertex to this graph.
static
<V,E> org.apache.commons.collections15.Factory<Graph<V,E>>
getFactory()
          Returns a Factory that creates an instance of this graph type.
 void setVertexComparator(Comparator<V> vertex_comparator)
          Provides a new Comparator 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vertex_comparator

protected Comparator<V> vertex_comparator
Comparator used in ordering vertices. Defaults to util.ComparableComparator if no comparators are specified in the constructor.


edge_comparator

protected Comparator<E> edge_comparator
Comparator used in ordering edges. Defaults to util.ComparableComparator if no comparators are specified in the constructor.

Constructor Detail

SortedSparseMultigraph

public SortedSparseMultigraph(Comparator<V> vertex_comparator,
                              Comparator<E> edge_comparator)
Creates a new instance which sorts its vertices and edges according to the specified Comparators.


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> org.apache.commons.collections15.Factory<Graph<V,E>> getFactory()
Returns a Factory that creates an instance of this graph type.

Type Parameters:
V - the vertex type for the graph factory
E - the edge type for the graph factory

setVertexComparator

public void setVertexComparator(Comparator<V> vertex_comparator)
Provides a new Comparator to 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: Hypergraph
Adds vertex to this graph. Fails if vertex is null or already in the graph.

Specified by:
addVertex in interface Hypergraph<V,E>
Overrides:
addVertex in class OrderedSparseMultigraph<V,E>
Parameters:
vertex - the vertex to add
Returns:
true if the add is successful, and false otherwise


Copyright © 2009. All Rights Reserved.