Interface MutableGraph<N>

  • Type Parameters:
    N - Node parameter type
    All Superinterfaces:
    Graph<N>

    @Beta
    public interface MutableGraph<N>
    extends Graph<N>
    A subinterface of Graph which adds mutation methods. When mutation is not required, users should prefer the Graph 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 graph was modified as a result of this call
      • putEdge

        boolean putEdge​(N nodeU,
                        N nodeV)
        Adds an edge connecting nodeU to nodeV if one is not already present. In an undirected graph, the edge will also connect nodeV to nodeU.

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

        Returns:
        true if the graph was modified as a result of this call
        Throws:
        java.lang.IllegalArgumentException - if the introduction of the edge would violate Graph.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 graph was modified as a result of this call
      • removeEdge

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