Class BasicLightGraph<N,​E extends GraphEdge<N>>

  • Type Parameters:
    N - Node type.
    E - Edge type.
    All Implemented Interfaces:
    GraphAdapter<N,​E>
    Direct Known Subclasses:
    BasicSuperLightGraph

    public class BasicLightGraph<N,​E extends GraphEdge<N>>
    extends Object
    implements GraphAdapter<N,​E>
    Basic and naive graph implementation using light nodes.

    Node can be any object.

    Author:
    Damien Carbonne
    • Constructor Detail

      • BasicLightGraph

        public BasicLightGraph​(boolean sorted)
      • BasicLightGraph

        public BasicLightGraph()
    • Method Detail

      • setLocked

        public void setLocked​(boolean locked)
      • isLocked

        public boolean isLocked()
      • clear

        public void clear()
        Clears this graph.
        Throws:
        cdc.util.lang.InvalidStateException - When this graph is locked.
      • addNode

        public <X extends N> X addNode​(X node)
        Adds a node to this graph.
        Type Parameters:
        X - The node type.
        Parameters:
        node - The node.
        Returns:
        The passed node.
        Throws:
        IllegalArgumentException - When node is null or is already contained in this graph.
        cdc.util.lang.InvalidStateException - When this graph is locked.
      • removeNode

        public void removeNode​(N node)
        Remove a node from this graph.
        Parameters:
        node - The node.
        Throws:
        IllegalArgumentException - When node is null or is not contained in this graph.
        cdc.util.lang.InvalidStateException - When this graph is locked.
      • addEdge

        public <X extends E> X addEdge​(X edge)
        Adds an edge to this graph.
        Type Parameters:
        X - The edge type.
        Parameters:
        edge - The edge.
        Returns:
        The passed edge.
        Throws:
        IllegalArgumentException - When edge is null or is already contained in this graph, or edge source or target don't not belong to this graph.
        cdc.util.lang.InvalidStateException - When this graph is locked.
      • removeEdge

        public void removeEdge​(E edge)
        Removes an edge from this graph.
        Parameters:
        edge - The edge.
        Throws:
        IllegalArgumentException - When edge is null or is not contained in this graph.
        cdc.util.lang.InvalidStateException - When this graph is locked.
      • containsEdge

        public boolean containsEdge​(N source,
                                    N target)
        Return true if this graph contains at least one edge between a source node and a target node.
        Parameters:
        source - The source node.
        target - The target node.
        Returns:
        true if this graph contains at least one edge between source and target.