Interface Subgraph

  • All Superinterfaces:
    Graph
    All Known Subinterfaces:
    DirectedSubgraph, UndirectedSubgraph

    public interface Subgraph
    extends Graph
    A subgraph is a subset of a graph based on a graph view.

    A subgraph has the same or less elements compared to the graph it's based on. This interface inherits from Graph and all read operations behave in a similar fashion. For instance, calling getNodes will return only nodes in this subgraph. However, write operations such as addNode or removeNode are used to control which elements are part of the view.

    • Method Detail

      • getView

        GraphView getView()
        Gets the view associated with this subgraph.
        Specified by:
        getView in interface Graph
        Returns:
        the graph view
      • getRootGraph

        Graph getRootGraph()
        Return the root graph this subgraph is based on.
        Returns:
        the root graph
      • addNode

        boolean addNode​(Node node)
        Adds a node to this subgraph.

        The node should be part of the root graph.

        Specified by:
        addNode in interface Graph
        Parameters:
        node - the node to add
        Returns:
        true if the node has been added, false otherwise
      • addAllNodes

        boolean addAllNodes​(Collection<? extends Node> nodes)
        Adds a collection of nodes to this subgraph.

        The nodes should be part of the root graph.

        Specified by:
        addAllNodes in interface Graph
        Parameters:
        nodes - the nodes to add
        Returns:
        true if at least a node has been added, false otherwise
      • addEdge

        boolean addEdge​(Edge edge)
        Adds an edge to this subgraph.

        The edge should be part of the root graph.

        Specified by:
        addEdge in interface Graph
        Parameters:
        edge - the edge to add
        Returns:
        true if the edge has been added, false otherwise
      • addAllEdges

        boolean addAllEdges​(Collection<? extends Edge> edges)
        Adds a collection of edges to this subgraph.

        The edges should be part of the root graph.

        Specified by:
        addAllEdges in interface Graph
        Parameters:
        edges - the edges to add
        Returns:
        true if at least an edge has been added, false otherwise
      • removeNode

        boolean removeNode​(Node node)
        Removes a node from this subgraph.

        The node should be part of the root graph.

        Specified by:
        removeNode in interface Graph
        Parameters:
        node - the node to remove
        Returns:
        true if removed, false otherwise
      • removeAllNodes

        boolean removeAllNodes​(Collection<? extends Node> nodes)
        Removes a collection of nodes from this subgraph.

        The nodes should be part of the root graph.

        Specified by:
        removeAllNodes in interface Graph
        Parameters:
        nodes - the nodes to remove
        Returns:
        true if at least a node is removed, false otherwise
      • removeEdge

        boolean removeEdge​(Edge edge)
        Removes an edge from this subgraph.

        The edge should be part of the root graph.

        Specified by:
        removeEdge in interface Graph
        Parameters:
        edge - the edge to remove
        Returns:
        true if removed, false otherwise
      • removeAllEdges

        boolean removeAllEdges​(Collection<? extends Edge> edges)
        Removes a collection of edges from this subgraph.

        The edges should be part of the root graph.

        Specified by:
        removeAllEdges in interface Graph
        Parameters:
        edges - the edges to remove
        Returns:
        true if at least an edge has been removed, false otherwise
      • fill

        void fill()
        Fills the subgraph so all elements in the graph are in the subgraph.
      • union

        void union​(Subgraph subGraph)
        Unions the given subgraph with this sugbgraph.

        The given subgraph remains unchanged.

        Parameters:
        subGraph - the subgraph to do the union with
      • intersection

        void intersection​(Subgraph subGraph)
        Intersects the given subgraph with this sugbgraph.

        The given subgraph remains unchanged.

        Parameters:
        subGraph - the subgraph to do the intersection with
      • not

        void not()
        Inverse this subgraph so all elements in the graph are removed and all elements not in the graph are added.