Class AbstractGraph<N>

java.lang.Object
com.google.common.graph.AbstractBaseGraph<N>
com.google.common.graph.AbstractGraph<N>
Type Parameters:
N - Node parameter type
All Implemented Interfaces:
BaseGraph<N>, Graph<N>, PredecessorsFunction<N>, SuccessorsFunction<N>
Direct Known Subclasses:
ForwardingGraph

public abstract class AbstractGraph<N> extends AbstractBaseGraph<N> implements Graph<N>
This class provides a skeletal implementation of Graph. It is recommended to extend this class rather than implement Graph directly.
Since:
20.0
  • Constructor Details

    • AbstractGraph

      public AbstractGraph()
  • Method Details

    • equals

      public final boolean equals(@CheckForNull Object obj)
      Description copied from interface: Graph
      Returns true iff object is a Graph that has the same elements and the same structural relationships as those in this graph.

      Thus, two graphs A and B are equal if all of the following are true:

      Graph properties besides directedness do not affect equality. For example, two graphs may be considered equal even if one allows self-loops and the other doesn't. Additionally, the order in which nodes or edges are added to the graph, and the order in which they are iterated over, are irrelevant.

      A reference implementation of this is provided by equals(Object).

      Specified by:
      equals in interface Graph<N>
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Description copied from interface: Graph
      Returns the hash code for this graph. The hash code of a graph is defined as the hash code of the set returned by Graph.edges().

      A reference implementation of this is provided by hashCode().

      Specified by:
      hashCode in interface Graph<N>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this graph.
      Overrides:
      toString in class Object