Class Graphs.TransposedNetwork<N,E>

java.lang.Object
com.google.common.graph.AbstractNetwork<N,E>
com.google.common.graph.ForwardingNetwork<N,E>
com.google.common.graph.Graphs.TransposedNetwork<N,E>
All Implemented Interfaces:
Network<N,E>, PredecessorsFunction<N>, SuccessorsFunction<N>
Enclosing class:
Graphs

private static class Graphs.TransposedNetwork<N,E> extends ForwardingNetwork<N,E>
  • Field Details

    • network

      private final Network<N,E> network
  • Constructor Details

    • TransposedNetwork

      TransposedNetwork(Network<N,E> network)
  • Method Details

    • delegate

      Network<N,E> delegate()
      Specified by:
      delegate in class ForwardingNetwork<N,E>
    • predecessors

      public Set<N> predecessors(N node)
      Description copied from interface: Network
      Returns a live view of all nodes in this network adjacent to node which can be reached by traversing node's incoming edges against the direction (if any) of the edge.

      In an undirected network, this is equivalent to Network.adjacentNodes(Object).

      If node is removed from the network after this method is called, the `Set` returned by this method will be invalidated, and will throw `IllegalStateException` if it is accessed in any way.

      Specified by:
      predecessors in interface Network<N,E>
      Specified by:
      predecessors in interface PredecessorsFunction<N>
      Overrides:
      predecessors in class ForwardingNetwork<N,E>
    • successors

      public Set<N> successors(N node)
      Description copied from interface: Network
      Returns a live view of all nodes in this network adjacent to node which can be reached by traversing node's outgoing edges in the direction (if any) of the edge.

      In an undirected network, this is equivalent to Network.adjacentNodes(Object).

      This is not the same as "all nodes reachable from node by following outgoing edges". For that functionality, see Graphs.reachableNodes(Graph, Object).

      If node is removed from the network after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

      • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
      • hashCode() does not throw
      • if node is re-added to the network after having been removed, view's behavior is undefined
      Specified by:
      successors in interface Network<N,E>
      Specified by:
      successors in interface SuccessorsFunction<N>
      Overrides:
      successors in class ForwardingNetwork<N,E>
    • inDegree

      public int inDegree(N node)
      Description copied from interface: Network
      Returns the count of node's incoming edges in a directed network. In an undirected network, returns the Network.degree(Object).

      If the count is greater than Integer.MAX_VALUE, returns Integer.MAX_VALUE.

      Specified by:
      inDegree in interface Network<N,E>
      Overrides:
      inDegree in class ForwardingNetwork<N,E>
    • outDegree

      public int outDegree(N node)
      Description copied from interface: Network
      Returns the count of node's outgoing edges in a directed network. In an undirected network, returns the Network.degree(Object).

      If the count is greater than Integer.MAX_VALUE, returns Integer.MAX_VALUE.

      Specified by:
      outDegree in interface Network<N,E>
      Overrides:
      outDegree in class ForwardingNetwork<N,E>
    • inEdges

      public Set<E> inEdges(N node)
      Description copied from interface: Network
      Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge to end at node.

      In a directed network, an incoming edge's EndpointPair.target() equals node.

      In an undirected network, this is equivalent to Network.incidentEdges(Object).

      If node is removed from the network after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

      • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
      • hashCode() does not throw
      • if node is re-added to the network after having been removed, view's behavior is undefined
      Specified by:
      inEdges in interface Network<N,E>
      Overrides:
      inEdges in class ForwardingNetwork<N,E>
    • outEdges

      public Set<E> outEdges(N node)
      Description copied from interface: Network
      Returns a live view of all edges in this network which can be traversed in the direction (if any) of the edge starting from node.

      In a directed network, an outgoing edge's EndpointPair.source() equals node.

      In an undirected network, this is equivalent to Network.incidentEdges(Object).

      If node is removed from the network after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

      • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
      • hashCode() does not throw
      • if node is re-added to the network after having been removed, view's behavior is undefined
      Specified by:
      outEdges in interface Network<N,E>
      Overrides:
      outEdges in class ForwardingNetwork<N,E>
    • incidentNodes

      public EndpointPair<N> incidentNodes(E edge)
      Description copied from interface: Network
      Returns the nodes which are the endpoints of edge in this network.
      Specified by:
      incidentNodes in interface Network<N,E>
      Overrides:
      incidentNodes in class ForwardingNetwork<N,E>
    • edgesConnecting

      public Set<E> edgesConnecting(N nodeU, N nodeV)
      Description copied from interface: Network
      Returns a live view of the set of edges that each directly connect nodeU to nodeV.

      In an undirected network, this is equal to edgesConnecting(nodeV, nodeU).

      The resulting set of edges will be parallel (i.e. have equal Network.incidentNodes(Object)). If this network does not allow parallel edges, the resulting set will contain at most one edge (equivalent to edgeConnecting(nodeU, nodeV).asSet()).

      If either nodeU or nodeV are removed from the network after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

      • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
      • hashCode() does not throw
      • if nodeU or nodeV are re-added to the network after having been removed, view's behavior is undefined
      Specified by:
      edgesConnecting in interface Network<N,E>
      Overrides:
      edgesConnecting in class ForwardingNetwork<N,E>
    • edgesConnecting

      public Set<E> edgesConnecting(EndpointPair<N> endpoints)
      Description copied from interface: Network
      Returns a live view of the set of edges that each directly connect endpoints (in the order, if any, specified by endpoints).

      The resulting set of edges will be parallel (i.e. have equal Network.incidentNodes(Object)). If this network does not allow parallel edges, the resulting set will contain at most one edge (equivalent to edgeConnecting(endpoints).asSet()).

      If this network is directed, endpoints must be ordered.

      If either element of endpoints is removed from the network after this method is called, the Set view returned by this method will be invalidated, and will throw IllegalStateException if it is accessed in any way, with the following exceptions:

      • view.equals(view) evaluates to true (but any other `equals()` expression involving view will throw)
      • hashCode() does not throw
      • if either endpoint is re-added to the network after having been removed, view's behavior is undefined
      Specified by:
      edgesConnecting in interface Network<N,E>
      Overrides:
      edgesConnecting in class ForwardingNetwork<N,E>
    • edgeConnecting

      public Optional<E> edgeConnecting(N nodeU, N nodeV)
      Description copied from interface: Network
      Returns the single edge that directly connects nodeU to nodeV, if one is present, or Optional.empty() if no such edge exists.

      In an undirected network, this is equal to edgeConnecting(nodeV, nodeU).

      Specified by:
      edgeConnecting in interface Network<N,E>
      Overrides:
      edgeConnecting in class ForwardingNetwork<N,E>
    • edgeConnecting

      public Optional<E> edgeConnecting(EndpointPair<N> endpoints)
      Description copied from interface: Network
      Returns the single edge that directly connects endpoints (in the order, if any, specified by endpoints), if one is present, or Optional.empty() if no such edge exists.

      If this network is directed, the endpoints must be ordered.

      Specified by:
      edgeConnecting in interface Network<N,E>
      Overrides:
      edgeConnecting in class ForwardingNetwork<N,E>
    • edgeConnectingOrNull

      @CheckForNull public E edgeConnectingOrNull(N nodeU, N nodeV)
      Description copied from interface: Network
      Returns the single edge that directly connects nodeU to nodeV, if one is present, or null if no such edge exists.

      In an undirected network, this is equal to edgeConnectingOrNull(nodeV, nodeU).

      Specified by:
      edgeConnectingOrNull in interface Network<N,E>
      Overrides:
      edgeConnectingOrNull in class ForwardingNetwork<N,E>
    • edgeConnectingOrNull

      @CheckForNull public E edgeConnectingOrNull(EndpointPair<N> endpoints)
      Description copied from interface: Network
      Returns the single edge that directly connects endpoints (in the order, if any, specified by endpoints), if one is present, or null if no such edge exists.

      If this network is directed, the endpoints must be ordered.

      Specified by:
      edgeConnectingOrNull in interface Network<N,E>
      Overrides:
      edgeConnectingOrNull in class ForwardingNetwork<N,E>
    • hasEdgeConnecting

      public boolean hasEdgeConnecting(N nodeU, N nodeV)
      Description copied from interface: Network
      Returns true if there is an edge that directly connects nodeU to nodeV. This is equivalent to nodes().contains(nodeU) && successors(nodeU).contains(nodeV), and to edgeConnectingOrNull(nodeU, nodeV) != null.

      In an undirected network, this is equal to hasEdgeConnecting(nodeV, nodeU).

      Specified by:
      hasEdgeConnecting in interface Network<N,E>
      Overrides:
      hasEdgeConnecting in class ForwardingNetwork<N,E>
    • hasEdgeConnecting

      public boolean hasEdgeConnecting(EndpointPair<N> endpoints)
      Description copied from interface: Network
      Returns true if there is an edge that directly connects endpoints (in the order, if any, specified by endpoints).

      Unlike the other EndpointPair-accepting methods, this method does not throw if the endpoints are unordered and the network is directed; it simply returns false. This is for consistency with Graph.hasEdgeConnecting(EndpointPair) and ValueGraph.hasEdgeConnecting(EndpointPair).

      Specified by:
      hasEdgeConnecting in interface Network<N,E>
      Overrides:
      hasEdgeConnecting in class ForwardingNetwork<N,E>