Class 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 Details

    • 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 Details

    • 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.
      Parameters:
      vertex_comparator - specifies how the vertices are to be compared
      edge_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

      public static <V, E> com.google.common.base.Supplier<Graph<V,E>> getFactory()
      Type Parameters:
      V - the vertex type for the graph Supplier
      E - the edge type for the graph Supplier
      Returns:
      a Supplier that creates an instance of this graph type.
    • 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