Class AbstractNetwork<N,​E>

  • Type Parameters:
    N - Node parameter type
    E - Edge parameter type
    All Implemented Interfaces:
    Network<N,​E>
    Direct Known Subclasses:
    ImmutableNetwork

    @Beta
    public abstract class AbstractNetwork<N,​E>
    extends java.lang.Object
    implements Network<N,​E>
    This class provides a skeletal implementation of Network. It is recommended to extend this class rather than implement Network directly.
    Since:
    20.0
    • Constructor Detail

      • AbstractNetwork

        public AbstractNetwork()
    • Method Detail

      • asGraph

        public Graph<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>
      • degree

        public int degree​(java.lang.Object node)
        Description copied from interface: Network
        Returns the count of node's incident edges, counting self-loops twice (equivalently, the number of times an edge touches node).

        For directed networks, this is equal to inDegree(node) + outDegree(node).

        For undirected networks, this is equal to incidentEdges(node).size() + (number of self-loops incident to node).

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

        Specified by:
        degree in interface Network<N,​E>
      • inDegree

        public int inDegree​(java.lang.Object 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>
      • outDegree

        public int outDegree​(java.lang.Object 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>
      • adjacentEdges

        public java.util.Set<E> adjacentEdges​(java.lang.Object edge)
        Description copied from interface: Network
        Returns the edges which have an incident node in common with edge. An edge is not considered adjacent to itself.
        Specified by:
        adjacentEdges in interface Network<N,​E>
      • toString

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