Interface MutableNetwork<N,​E>

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

    @Beta
    public interface MutableNetwork<N,​E>
    extends Network<N,​E>
    A subinterface of Network which adds mutation methods. When mutation is not required, users should prefer the Network interface.
    Since:
    20.0
    • Method Detail

      • addNode

        boolean addNode​(N node)
        Adds node if it is not already present.

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

        Returns:
        true if the network was modified as a result of this call
      • addEdge

        boolean addEdge​(N nodeU,
                        N nodeV,
                        E edge)
        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.

        Returns:
        true if the network was modified as a result of this call
        Throws:
        java.lang.IllegalArgumentException - if edge already exists and does not connect nodeU to nodeV, or if the introduction of the edge would violate Network.allowsParallelEdges() or Network.allowsSelfLoops()
      • removeNode

        boolean removeNode​(java.lang.Object node)
        Removes node if it is present; all edges incident to node will also be removed.
        Returns:
        true if the network was modified as a result of this call
      • removeEdge

        boolean removeEdge​(java.lang.Object edge)
        Removes edge from this network, if it is present.
        Returns:
        true if the network was modified as a result of this call