Interface GraphElementsController


  • public interface GraphElementsController

    This interface defines part of the Data Laboratory API basic actions.

    It contains methods for manipulating the nodes and edges of the graph.

    All the provided methods take care to check first that the nodes and edges to manipulate are in the graph.

    Author:
    Eduardo Ramos
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean areEdgesInGraph​(Edge[] edges)
      Checks if an array of edges are contained in the main view graph.
      boolean areNodesInGraph​(Node[] nodes)
      Checks if an array of nodes are contained in the main view graph.
      Edge createEdge​(String id, Node source, Node target, boolean directed)
      Creates and edge between source and target node (if it does not already exist), directed or undirected.
      Edge createEdge​(String id, Node source, Node target, boolean directed, Object typeLabel)
      Creates and edge between source and target node (if it does not already exist), directed or undirected.
      Edge createEdge​(String id, Node source, Node target, boolean directed, Object typeLabel, Graph graph)
      Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.
      Edge createEdge​(String id, Node source, Node target, boolean directed, Graph graph)
      Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.
      Edge createEdge​(Node source, Node target, boolean directed)
      Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.
      Edge createEdge​(Node source, Node target, boolean directed, Object typeLabel)
      Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.
      Edge createEdge​(Node source, Node target, boolean directed, Object typeLabel, Graph graph)
      Creates and edge between source and target node (if it does not already exist), directed or undirected.
      Edge createEdge​(Node source, Node target, boolean directed, Graph graph)
      Creates and edge between source and target node (if it does not already exist), directed or undirected.
      void createEdges​(Node source, Node[] allNodes, boolean directed)
      Tries to create edges between the source node and all other edges, directed or undirected.
      Node createNode​(String label)
      Creates a node with default id and the given label in the current graph.
      Node createNode​(String label, String id)
      Creates a node with the given id and label in the current graph.
      Node createNode​(String label, String id, Graph graph)
      Creates a node with the given id and label.
      Node createNode​(String label, Graph graph)
      Creates a node with default id and the given label.
      void deleteEdge​(Edge edge)
      Tries to delete an edge checking first if it is on the graph.
      void deleteEdges​(Edge[] edges)
      Tries to delete an array of edges checking first if they are on the graph.
      void deleteEdgesWithNodes​(Edge[] edges, boolean deleteSource, boolean deleteTarget)
      Tries to delete an array of edges checking first if they are on the graph and also deletes their source and target node if it is indicated.
      void deleteEdgeWithNodes​(Edge edge, boolean deleteSource, boolean deleteTarget)
      Tries to delete an edge checking first if it is on the graph and also deletes its source and target node if it is indicated.
      void deleteNode​(Node node)
      Tries to delete a node checking first if it is on the graph.
      void deleteNodes​(Node[] nodes)
      Tries to delete an array of nodes checking first if they are on the graph.
      Node duplicateNode​(Node node)
      Duplicates a node if it is in the graph, and returns the new node.
      void duplicateNodes​(Node[] nodes)
      Tries to duplicate an array of nodes with the same behaviour as duplicateNode method.
      int getEdgesCount()
      Returns the number of edges in the graph.
      Edge[] getNodeEdges​(Node node)
      Prepares and returns an array with the edges incident to the specified node.
      Node[] getNodeNeighbours​(Node node)
      Prepares and returns an array with the neighbour nodes of the specified node.
      int getNodesCount()
      Returns the number of nodes in the graph.
      boolean isEdgeInGraph​(Edge edge)
      Checks if an edge is contained in the main view graph.
      boolean isNodeFixed​(Node node)
      Checks the fixed state of a node.
      boolean isNodeInGraph​(Node node)
      Checks if a node is contained in the main view graph.
      Node mergeNodes​(Graph graph, Node[] nodes, Node selectedNode, Column[] columns, AttributeRowsMergeStrategy[] mergeStrategies, boolean deleteMergedNodes)
      Merges 2 or more nodes into a new one node that has all the edges of the merged nodes.
      void setNodeFixed​(Node node, boolean fixed)
      Sets the fixed state of a node to the indicated.
      void setNodesFixed​(Node[] nodes, boolean fixed)
      Sets the fixed state of an array of nodes to the indicated.
    • Method Detail

      • createNode

        Node createNode​(String label)
        Creates a node with default id and the given label in the current graph.
        Parameters:
        label - Label for the node
        Returns:
        The new created node
      • createNode

        Node createNode​(String label,
                        Graph graph)
        Creates a node with default id and the given label.
        Parameters:
        label - Label for the node
        graph - Graph to insert the node into
        Returns:
        The new created node
      • createNode

        Node createNode​(String label,
                        String id)

        Creates a node with the given id and label in the current graph.

        If a node with that id already exists, no node will be created

        Parameters:
        label - Label for the node
        id - Id for the node
        Returns:
        The new created node or null if a node with the given id already exists
      • createNode

        Node createNode​(String label,
                        String id,
                        Graph graph)

        Creates a node with the given id and label.

        If a node with that id already exists, no node will be created

        Parameters:
        label - Label for the node
        id - Id for the node
        graph - Graph to insert the node into
        Returns:
        The new created node or null if a node with the given id already exists
      • duplicateNode

        Node duplicateNode​(Node node)

        Duplicates a node if it is in the graph, and returns the new node.

        If the node has children, they are also copied as children of the new node.

        Sets the same properties and attributes for the node as the original node: id, label and AttributeColumns with DATA AttributeOrigin. Does not copy AttributeColumns with COMPUTED AttributeOrigin.

        Parameters:
        node - Node to copy
        Returns:
        New node
      • duplicateNodes

        void duplicateNodes​(Node[] nodes)
        Tries to duplicate an array of nodes with the same behaviour as duplicateNode method.
        Parameters:
        nodes - Array of nodes to duplicate
      • createEdge

        Edge createEdge​(Node source,
                        Node target,
                        boolean directed)

        Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.

        Parameters:
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(Node source,
                        Node target,
                        boolean directed,
                        Object typeLabel)

        Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.

        Parameters:
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        typeLabel - Edge type label or null
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(Node source,
                        Node target,
                        boolean directed,
                        Graph graph)

        Creates and edge between source and target node (if it does not already exist), directed or undirected.

        Parameters:
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        graph - Graph to insert the node into
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(Node source,
                        Node target,
                        boolean directed,
                        Object typeLabel,
                        Graph graph)

        Creates and edge between source and target node (if it does not already exist), directed or undirected.

        Parameters:
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        typeLabel - Edge type label or null
        graph - Graph to insert the node into
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(String id,
                        Node source,
                        Node target,
                        boolean directed)

        Creates and edge between source and target node (if it does not already exist), directed or undirected.

        If a edge with the given id already exists, no edge will be created.

        Parameters:
        id - Id for the new edge
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(String id,
                        Node source,
                        Node target,
                        boolean directed,
                        Object typeLabel)

        Creates and edge between source and target node (if it does not already exist), directed or undirected.

        If a edge with the given id already exists, no edge will be created.

        Parameters:
        id - Id for the new edge
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        typeLabel - Edge type label or null
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(String id,
                        Node source,
                        Node target,
                        boolean directed,
                        Graph graph)

        Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.

        If a edge with the given id already exists, no edge will be created.

        Parameters:
        id - Id for the new edge
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        graph - Graph to insert the node into
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdge

        Edge createEdge​(String id,
                        Node source,
                        Node target,
                        boolean directed,
                        Object typeLabel,
                        Graph graph)

        Creates and edge between source and target node (if it does not already exist), directed or undirected, in the current graph.

        If a edge with the given id already exists, no edge will be created.

        Parameters:
        id - Id for the new edge
        source - Source node
        target - Target node
        directed - Indicates if the edge has to be directed
        typeLabel - Edge type label or null
        graph - Graph to insert the node into
        Returns:
        New edge if the edge was created succesfully, null otherwise
      • createEdges

        void createEdges​(Node source,
                         Node[] allNodes,
                         boolean directed)

        Tries to create edges between the source node and all other edges, directed or undirected.

        An edge won't be created if it already exists or is a self-loop.

        Parameters:
        source - Source node
        allNodes - All edges
        directed - Indicates if the edges have to be directed
      • deleteNode

        void deleteNode​(Node node)
        Tries to delete a node checking first if it is on the graph.
        Parameters:
        node - Node to delete
      • deleteNodes

        void deleteNodes​(Node[] nodes)
        Tries to delete an array of nodes checking first if they are on the graph.
        Parameters:
        nodes - Array of nodes to delete
      • deleteEdge

        void deleteEdge​(Edge edge)
        Tries to delete an edge checking first if it is on the graph.
        Parameters:
        edge - Edge to delete
      • deleteEdges

        void deleteEdges​(Edge[] edges)
        Tries to delete an array of edges checking first if they are on the graph.
        Parameters:
        edges - Array of edges to delete
      • deleteEdgeWithNodes

        void deleteEdgeWithNodes​(Edge edge,
                                 boolean deleteSource,
                                 boolean deleteTarget)
        Tries to delete an edge checking first if it is on the graph and also deletes its source and target node if it is indicated.
        Parameters:
        edge - Edge to delete
        deleteSource - Indicates if the source node has to be deleted
        deleteTarget - Indicates if the target node has to be deleted
      • deleteEdgesWithNodes

        void deleteEdgesWithNodes​(Edge[] edges,
                                  boolean deleteSource,
                                  boolean deleteTarget)
        Tries to delete an array of edges checking first if they are on the graph and also deletes their source and target node if it is indicated.
        Parameters:
        edges - Array of edges to delete
        deleteSource - Indicates if the source nodes have to be deleted
        deleteTarget - Indicates if the target nodes have to be deleted
      • mergeNodes

        Node mergeNodes​(Graph graph,
                        Node[] nodes,
                        Node selectedNode,
                        Column[] columns,
                        AttributeRowsMergeStrategy[] mergeStrategies,
                        boolean deleteMergedNodes)
        Merges 2 or more nodes into a new one node that has all the edges of the merged nodes. An AttributeRowsMergeStrategy must be provided for each column of the nodes.
        Parameters:
        graph - Graph that contains the nodes
        nodes - Nodes to merge (at least 1)
        selectedNode - Main selected node of the nodes to merge (or null to use first node)
        columns - Columns to apply a merge strategy in each row
        mergeStrategies - Strategies to merge rows of each column in columns
        deleteMergedNodes - Indicates if merged nodes should be deleted
        Returns:
        New resulting node
      • setNodeFixed

        void setNodeFixed​(Node node,
                          boolean fixed)
        Sets the fixed state of a node to the indicated.
        Parameters:
        node - Node to set fixed state
        fixed - Fixed state for the node
      • setNodesFixed

        void setNodesFixed​(Node[] nodes,
                           boolean fixed)
        Sets the fixed state of an array of nodes to the indicated.
        Parameters:
        nodes - Array of nodes to set fixed state
        fixed - Fixed state for the nodes
      • isNodeFixed

        boolean isNodeFixed​(Node node)
        Checks the fixed state of a node.
        Parameters:
        node - Node to check
        Returns:
        Fixed state of the node
      • getNodeNeighbours

        Node[] getNodeNeighbours​(Node node)
        Prepares and returns an array with the neighbour nodes of the specified node.
        Parameters:
        node - Node to get neighbours
        Returns:
        Array of neighbour nodes
      • getNodeEdges

        Edge[] getNodeEdges​(Node node)
        Prepares and returns an array with the edges incident to the specified node.
        Parameters:
        node - Node to get edges
        Returns:
        Array of incident edges
      • getNodesCount

        int getNodesCount()
        Returns the number of nodes in the graph.
        Returns:
        Nodes count
      • getEdgesCount

        int getEdgesCount()
        Returns the number of edges in the graph.
        Returns:
        Edges count
      • isNodeInGraph

        boolean isNodeInGraph​(Node node)
        Checks if a node is contained in the main view graph.
        Parameters:
        node - Node to check
        Returns:
        True if the node is in the graph, false otherwise
      • areNodesInGraph

        boolean areNodesInGraph​(Node[] nodes)
        Checks if an array of nodes are contained in the main view graph.
        Parameters:
        nodes - Array of nodes to check
        Returns:
        True if all the nodes are in the graph, false otherwise
      • isEdgeInGraph

        boolean isEdgeInGraph​(Edge edge)
        Checks if an edge is contained in the main view graph.
        Parameters:
        edge - Edge to check
        Returns:
        True if the edge is in the graph, false otherwise
      • areEdgesInGraph

        boolean areEdgesInGraph​(Edge[] edges)
        Checks if an array of edges are contained in the main view graph.
        Parameters:
        edges - Edges to check
        Returns:
        True if all the edges are in the graph, false otherwise