Class DirectedGraphConnections<N,V>

java.lang.Object
com.google.common.graph.DirectedGraphConnections<N,V>
Type Parameters:
N - Node parameter type
V - Value parameter type
All Implemented Interfaces:
GraphConnections<N,V>

final class DirectedGraphConnections<N,V> extends Object implements GraphConnections<N,V>
An implementation of GraphConnections for directed graphs.
  • Field Details

    • PRED

      private static final Object PRED
    • adjacentNodeValues

      private final Map<N,Object> adjacentNodeValues
    • orderedNodeConnections

      @CheckForNull private final List<DirectedGraphConnections.NodeConnection<N>> orderedNodeConnections
      All node connections in this graph, in edge insertion order.

      Note: This field and adjacentNodeValues cannot be combined into a single LinkedHashMap because one target node may be mapped to both a predecessor and a successor. A LinkedHashMap combines two such edges into a single node-value pair, even though the edges may not have been inserted consecutively.

    • predecessorCount

      private int predecessorCount
    • successorCount

      private int successorCount
  • Constructor Details

  • Method Details

    • of

      static <N, V> DirectedGraphConnections<N,V> of(ElementOrder<N> incidentEdgeOrder)
    • ofImmutable

      static <N, V> DirectedGraphConnections<N,V> ofImmutable(N thisNode, Iterable<EndpointPair<N>> incidentEdges, Function<N,V> successorNodeToValueFn)
    • adjacentNodes

      public Set<N> adjacentNodes()
      Specified by:
      adjacentNodes in interface GraphConnections<N,V>
    • predecessors

      public Set<N> predecessors()
      Specified by:
      predecessors in interface GraphConnections<N,V>
    • successors

      public Set<N> successors()
      Specified by:
      successors in interface GraphConnections<N,V>
    • incidentEdgeIterator

      public Iterator<EndpointPair<N>> incidentEdgeIterator(N thisNode)
      Description copied from interface: GraphConnections
      Returns an iterator over the incident edges.
      Specified by:
      incidentEdgeIterator in interface GraphConnections<N,V>
      Parameters:
      thisNode - The node that this all of the connections in this class are connected to.
    • value

      @CheckForNull public V value(N node)
      Description copied from interface: GraphConnections
      Returns the value associated with the edge connecting the origin node to node, or null if there is no such edge.
      Specified by:
      value in interface GraphConnections<N,V>
    • removePredecessor

      public void removePredecessor(N node)
      Description copied from interface: GraphConnections
      Remove node from the set of predecessors.
      Specified by:
      removePredecessor in interface GraphConnections<N,V>
    • removeSuccessor

      @CheckForNull public V removeSuccessor(Object node)
      Description copied from interface: GraphConnections
      Remove node from the set of successors. Returns the value previously associated with the edge connecting the two nodes.
      Specified by:
      removeSuccessor in interface GraphConnections<N,V>
    • addPredecessor

      public void addPredecessor(N node, V unused)
      Description copied from interface: GraphConnections
      Add node as a predecessor to the origin node. In the case of an undirected graph, it also becomes a successor. Associates value with the edge connecting the two nodes.
      Specified by:
      addPredecessor in interface GraphConnections<N,V>
    • addSuccessor

      @CheckForNull public V addSuccessor(N node, V value)
      Description copied from interface: GraphConnections
      Add node as a successor to the origin node. In the case of an undirected graph, it also becomes a predecessor. Associates value with the edge connecting the two nodes. Returns the value previously associated with the edge connecting the two nodes.
      Specified by:
      addSuccessor in interface GraphConnections<N,V>
    • isPredecessor

      private static boolean isPredecessor(@CheckForNull Object value)
    • isSuccessor

      private static boolean isSuccessor(@CheckForNull Object value)