Class ConfigurableMutableNetwork<N,​E>

  • Type Parameters:
    N - Node parameter type
    E - Edge parameter type
    All Implemented Interfaces:
    MutableNetwork<N,​E>, Network<N,​E>

    final class ConfigurableMutableNetwork<N,​E>
    extends ConfigurableNetwork<N,​E>
    implements MutableNetwork<N,​E>
    Configurable implementation of MutableNetwork that supports both directed and undirected graphs. Instances of this class should be constructed with NetworkBuilder.

    Time complexities for mutation methods are all O(1) except for removeNode(N node), which is in O(d_node) where d_node is the degree of node.

    • Constructor Detail

      • ConfigurableMutableNetwork

        ConfigurableMutableNetwork​(NetworkBuilder<? super N,​? super E> builder)
        Constructs a mutable graph with the properties specified in builder.
    • Method Detail

      • addNode

        public boolean addNode​(N node)
        Description copied from interface: MutableNetwork
        Adds node if it is not already present.

        Nodes must be unique, just as Map keys must be. They must also be non-null.

        Specified by:
        addNode in interface MutableNetwork<N,​E>
        Returns:
        true if the network was modified as a result of this call
      • addNodeInternal

        private NetworkConnections<N,​E> addNodeInternal​(N node)
        Adds node to the graph and returns the associated NetworkConnections.
        Throws:
        java.lang.IllegalStateException - if node is already present
      • addEdge

        public boolean addEdge​(N nodeU,
                               N nodeV,
                               E edge)
        Description copied from interface: MutableNetwork
        Adds edge connecting nodeU to nodeV. In an undirected network, the edge will also connect nodeV to nodeU.

        Edges must be unique, just as Map keys must be. They must also be non-null.

        Behavior if nodeU and nodeV are not already present in this network is implementation-dependent. Suggested behaviors include (a) silently adding nodeU and nodeV to the network (this is the behavior of the default implementations) or (b) throwing IllegalArgumentException.

        If edge already connects nodeU to nodeV (in the specified order if this network Network.isDirected(), else in any order), then this method will have no effect.

        Specified by:
        addEdge in interface MutableNetwork<N,​E>
        Returns:
        true if the network was modified as a result of this call
      • removeNode

        public boolean removeNode​(java.lang.Object node)
        Description copied from interface: MutableNetwork
        Removes node if it is present; all edges incident to node will also be removed.
        Specified by:
        removeNode in interface MutableNetwork<N,​E>
        Returns:
        true if the network was modified as a result of this call
      • removeEdge

        public boolean removeEdge​(java.lang.Object edge)
        Description copied from interface: MutableNetwork
        Removes edge from this network, if it is present.
        Specified by:
        removeEdge in interface MutableNetwork<N,​E>
        Returns:
        true if the network was modified as a result of this call