Class ConfigurableMutableGraph<N>

  • Type Parameters:
    N - Node parameter type
    All Implemented Interfaces:
    Graph<N>, MutableGraph<N>

    final class ConfigurableMutableGraph<N>
    extends ForwardingGraph<N>
    implements MutableGraph<N>
    Configurable implementation of MutableGraph that supports both directed and undirected graphs. Instances of this class should be constructed with GraphBuilder.

    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

    • Method Detail

      • addNode

        public boolean addNode​(N node)
        Description copied from interface: MutableGraph
        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 MutableGraph<N>
        Returns:
        true if the graph was modified as a result of this call
      • putEdge

        public boolean putEdge​(N nodeU,
                               N nodeV)
        Description copied from interface: MutableGraph
        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.

        Specified by:
        putEdge in interface MutableGraph<N>
        Returns:
        true if the graph was modified as a result of this call
      • removeNode

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

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