Class ConfigurableMutableValueGraph<N,​V>

  • Type Parameters:
    N - Node parameter type
    V - Value parameter type
    All Implemented Interfaces:
    Graph<N>, MutableValueGraph<N,​V>, ValueGraph<N,​V>

    final class ConfigurableMutableValueGraph<N,​V>
    extends ConfigurableValueGraph<N,​V>
    implements MutableValueGraph<N,​V>
    Configurable implementation of MutableValueGraph that supports both directed and undirected graphs. Instances of this class should be constructed with ValueGraphBuilder.

    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

      • ConfigurableMutableValueGraph

        ConfigurableMutableValueGraph​(AbstractGraphBuilder<? super N> builder)
        Constructs a mutable graph with the properties specified in builder.
    • Method Detail

      • addNode

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

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

        public V putEdgeValue​(N nodeU,
                              N nodeV,
                              V value)
        Description copied from interface: MutableValueGraph
        Adds an edge connecting nodeU to nodeV if one is not already present; associate that edge with value. In an undirected graph, the edge will also connect nodeV to nodeU.

        Values do not have to be unique. However, values must be non-null.

        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:
        putEdgeValue in interface MutableValueGraph<N,​V>
        Returns:
        the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.
      • removeNode

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

        public V removeEdge​(java.lang.Object nodeU,
                            java.lang.Object nodeV)
        Description copied from interface: MutableValueGraph
        Removes the edge connecting nodeU to nodeV, if it is present.
        Specified by:
        removeEdge in interface MutableValueGraph<N,​V>
        Returns:
        the value previously associated with the edge connecting nodeU to nodeV, or null if there was no such edge.