Interface Graph

  • All Known Implementing Classes:
    AntGraph, GraphImpl

    public interface Graph
    Interface to be implemented by graphs. A Graph is both a container and a factory/manager. As a container a Graph can contain both Nodes and SubGraphs and as a factory it is responsible for the creation and ownership of the contained Nodes or Subgraphs. Although some nodes may be stored in subgraphs, the graph is still the factory/manager for them.
    Author:
    Christophe Labouisse
    • Method Detail

      • createLink

        Link createLink​(String linkName,
                        Node startNode,
                        Node endNode)
        Creates a new link between two nodes. Unlike createNode(String), this method do not require the link's name to be unique or not null. Both nodes should be not null.
        Parameters:
        linkName - the new link name, can be null
        startNode - start node
        endNode - end node
        Returns:
        new link
      • createNode

        Node createNode​(String nodeName)
                 throws DuplicateElementException
        Creates a new Node in the top level graph. The object's name must not be null and must be unique within the graph.
        Parameters:
        nodeName - new node's name
        Returns:
        a new Node.
        Throws:
        DuplicateElementException - if there is already a node with the same name.
      • createNode

        Node createNode​(SubGraph subGraph,
                        String nodeName)
                 throws DuplicateElementException
        Creates a new Node in a specific graph. The object's name must not be null and must be unique within the subgraph.
        Parameters:
        subGraph - the subgraph to place the node in.
        nodeName - new node's name
        Returns:
        a new Node.
        Throws:
        DuplicateElementException - if there is already a node with the same name.
      • createSubGraph

        SubGraph createSubGraph​(String subGraphName)
                         throws DuplicateElementException
        Creates a new subgraph in the graph. The subgraph name must not be null and must be unique within the graph.
        Parameters:
        subGraphName - new subgraph name.
        Returns:
        a new SubGraph.
        Throws:
        DuplicateElementException - if a sub graph with the same name already exists in the graph.
      • getName

        String getName()
        Returns the graph's name.
        Returns:
        graph's name.
      • getStartNode

        Node getStartNode()
        Returns the start node of the graph. If no such node is defined, null will be returned.
        Returns:
        start node
      • getSubGraph

        SubGraph getSubGraph​(String subGraphName)
        Find a subgraph from its name.
        Parameters:
        subGraphName - name of the subgraph to find.
        Returns:
        the subgraph or null if not found.
      • getSubgraphs

        Iterator<SubGraph> getSubgraphs()
        Get the nodes contained in the graph. The implementing class should guarantee that the Iterator will only returns object implementing the Node interface. The returned iterator should implement the optional Iterator.remove()method in order to allow the filters to remove nodes.
        Returns:
        an iterator to the graph's nodes.
      • hasSubGraph

        boolean hasSubGraph​(String subGraphName)
        Checks if the graph has a subgraph with a specific name.
        Parameters:
        subGraphName - subgraph to search.
        Returns:
        true if the graph contains a subgraph called nodeName.
      • setStartNode

        void setStartNode​(Node node)
        Sets the graph starting node.
        Parameters:
        node - the node to declare a the start of the graph.
      • getNode

        Node getNode​(String nodeName)
        Find a node from its name.
        Parameters:
        nodeName - name of the node to find.
        Returns:
        the node or null if not found.
      • getNodes

        Iterator<Node> getNodes()
        Get the nodes contained in the graph. The implementing class should guarantee that the Iterator will only returns object implementing the Node interface. The returned iterator should implement the optional Iterator.remove()method in order to allow the filters to remove nodes.
        Returns:
        an iterator to the graph's nodes.
      • hasNode

        boolean hasNode​(String nodeName)
        Checks if the graph has a node with a specific name.
        Parameters:
        nodeName - node to search.
        Returns:
        true if the graph contains a node called nodeName.