Class ImmutableNetwork<N,E>

java.lang.Object
com.google.common.graph.AbstractNetwork<N,E>
com.google.common.graph.ImmutableNetwork<N,E>
Type Parameters:
N - Node parameter type
E - Edge parameter type
All Implemented Interfaces:
Network<N,E>

@Beta public final class ImmutableNetwork<N,E> extends AbstractNetwork<N,E>
A Network whose elements and structural relationships will never change. Instances of this class may be obtained with copyOf(Network).

See the Guava User's Guide's discussion of the Immutable* types for more information on the properties and guarantees provided by this class.

Since:
20.0
  • Field Details

    • nodeConnections

      protected final com.google.common.graph.MapIteratorCache<N,com.google.common.graph.NetworkConnections<N,E>> nodeConnections
    • edgeToReferenceNode

      protected final com.google.common.graph.MapIteratorCache<E,N> edgeToReferenceNode
  • Method Details

    • copyOf

      public static <N, E> ImmutableNetwork<N,E> copyOf(Network<N,E> network)
      Returns an immutable copy of network.
    • copyOf

      @Deprecated public static <N, E> ImmutableNetwork<N,E> copyOf(ImmutableNetwork<N,E> network)
      Deprecated.
      no need to use this
      Simply returns its argument.
    • asGraph

      public ImmutableGraph<N> asGraph()
      Description copied from interface: Network
      Returns a live view of this network as a Graph. The resulting Graph will have an edge connecting node A to node B if this Network has an edge connecting A to B.

      If this network allows parallel edges, parallel edges will be treated as if collapsed into a single edge. For example, the Network.degree(Object) of a node in the Graph view may be less than the degree of the same node in this Network.

      Specified by:
      asGraph in interface Network<N,E>
      Overrides:
      asGraph in class AbstractNetwork<N,E>
    • nodes

      public Set<N> nodes()
      Description copied from interface: Network
      Returns all nodes in this network, in the order specified by Network.nodeOrder().
    • edges

      public Set<E> edges()
      Description copied from interface: Network
      Returns all edges in this network, in the order specified by Network.edgeOrder().
    • isDirected

      public boolean isDirected()
      Description copied from interface: Network
      Returns true if the edges in this network are directed. Directed edges connect a source node to a target node, while undirected edges connect a pair of nodes to each other.
    • allowsParallelEdges

      public boolean allowsParallelEdges()
      Description copied from interface: Network
      Returns true if this network allows parallel edges. Attempting to add a parallel edge to a network that does not allow them will throw an UnsupportedOperationException.
    • allowsSelfLoops

      public boolean allowsSelfLoops()
      Description copied from interface: Network
      Returns true if this network allows self-loops (edges that connect a node to itself). Attempting to add a self-loop to a network that does not allow them will throw an UnsupportedOperationException.
    • nodeOrder

      public ElementOrder<N> nodeOrder()
      Description copied from interface: Network
      Returns the order of iteration for the elements of Network.nodes().
    • edgeOrder

      public ElementOrder<E> edgeOrder()
      Description copied from interface: Network
      Returns the order of iteration for the elements of Network.edges().
    • incidentEdges

      public Set<E> incidentEdges(Object node)
      Description copied from interface: Network
      Returns the edges whose incident nodes in this network include node.
    • incidentNodes

      public EndpointPair<N> incidentNodes(Object edge)
      Description copied from interface: Network
      Returns the nodes which are the endpoints of edge in this network.
    • adjacentNodes

      public Set<N> adjacentNodes(Object node)
      Description copied from interface: Network
      Returns the nodes which have an incident edge in common with node in this network.
    • edgesConnecting

      public Set<E> edgesConnecting(Object nodeU, Object nodeV)
      Description copied from interface: Network
      Returns the set of edges directly connecting 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.

    • inEdges

      public Set<E> inEdges(Object node)
      Description copied from interface: Network
      Returns 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).

    • outEdges

      public Set<E> outEdges(Object node)
      Description copied from interface: Network
      Returns 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).

    • predecessors

      public Set<N> predecessors(Object node)
      Description copied from interface: Network
      Returns 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).

    • successors

      public Set<N> successors(Object node)
      Description copied from interface: Network
      Returns 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).

    • checkedConnections

      protected final com.google.common.graph.NetworkConnections<N,E> checkedConnections(Object node)
    • checkedReferenceNode

      protected final N checkedReferenceNode(Object edge)
    • containsNode

      protected final boolean containsNode(@Nullable Object node)
    • containsEdge

      protected final boolean containsEdge(@Nullable Object edge)