Gephi Toolkit Javadoc

org.gephi.datalab.api
Interface GraphElementsController

All Known Implementing Classes:
GraphElementsControllerImpl

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
 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.
 boolean canGroupNodes(Node[] nodes)
          Checks if an array of nodes can form a group.
 boolean canMoveNodeToGroup(Node node, Node group)
          Indicates if a given node can be moved to a group node.
 boolean canUngroupNode(Node node)
          Checks if the node can be ungrouped (it forms a group of nodes).
 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.
 Edge createEdge(java.lang.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.
 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(java.lang.String label)
          Creates a node with default id and the given label.
 Node createNode(java.lang.String label, java.lang.String id)
          Creates a node with the given id and 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.
 Node[] getAvailableGroupsToMoveNodes(Node[] nodes)
          Prepares and returns an array with the groups that the given nodes can be moved to.
 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 groupNodes(Node[] nodes)
          Groups an array of nodes if it is possible.
 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.
 boolean isNodeInGroup(Node node)
          Checks if the node is in a group (has a parent).
 Node mergeNodes(Node[] nodes, Node selectedNode, AttributeRowsMergeStrategy[] mergeStrategies, boolean deleteMergedNodes)
          Merges 2 or more nodes into a new one node that has all the edges of the merged nodes.
 void moveNodesToGroup(Node[] nodes, Node group)
          Tries to move each node of the nodes array to the group node.
 boolean moveNodeToGroup(Node node, Node group)
          Moves a node to a group of nodes if it is possible.
 boolean removeNodeFromGroup(Node node)
          Removes a node from its group if the node is in a group (has a parent).
 void removeNodesFromGroup(Node[] nodes)
          Tries to remove every node in the array from its group checking first they are in a group.
 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.
 boolean ungroupNode(Node node)
          Ungroups a node if it forms a group.
 boolean ungroupNodeRecursively(Node node)
          Ungroups a node if it forms a group and also ungroups all its descendant.
 void ungroupNodes(Node[] nodes)
          Tries to ungroup every node un the array of nodes checking first they form a group.
 void ungroupNodesRecursively(Node[] nodes)
          Tries to ungroup every node un the array of nodes checking first they form a group.
 

Method Detail

createNode

Node createNode(java.lang.String label)
Creates a node with default id and the given label.

Parameters:
label - Label for the node
Returns:
The new created node

createNode

Node createNode(java.lang.String label,
                java.lang.String id)

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
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.

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(java.lang.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:
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

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

groupNodes

boolean groupNodes(Node[] nodes)
Groups an array of nodes if it is possible.

Parameters:
nodes - Array of nodes to group
Returns:
True if the nodes were succesfully grouped, false otherwise

canGroupNodes

boolean canGroupNodes(Node[] nodes)
Checks if an array of nodes can form a group.

Parameters:
nodes - Array of nodes to check
Returns:
True if the nodes can form a group, false otherwise

ungroupNode

boolean ungroupNode(Node node)
Ungroups a node if it forms a group.

Parameters:
node - Node to ungroup
Returns:
True if the node was succesfully ungrouped, false otherwise

ungroupNodes

void ungroupNodes(Node[] nodes)
Tries to ungroup every node un the array of nodes checking first they form a group.

Parameters:
nodes - Array of nodes to ungroup

ungroupNodeRecursively

boolean ungroupNodeRecursively(Node node)
Ungroups a node if it forms a group and also ungroups all its descendant.

Parameters:
node - Node to ungroup recursively
Returns:
True if the node was succesfully ungrouped, false otherwise

ungroupNodesRecursively

void ungroupNodesRecursively(Node[] nodes)
Tries to ungroup every node un the array of nodes checking first they form a group.

Parameters:
nodes - Array of nodes to ungroup

canUngroupNode

boolean canUngroupNode(Node node)
Checks if the node can be ungrouped (it forms a group of nodes).

Parameters:
node - Node to check
Returns:
True if the node can be ungrouped, false otherwise

mergeNodes

Node mergeNodes(Node[] nodes,
                Node selectedNode,
                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:
nodes - Nodes to merge (at least 1)
selectedNode - Main selected node of the nodes to merge (or null to use first node)
mergeStrategies - Strategies to merge rows of each column of the nodes
deleteMergedNodes - Indicates if merged nodes should be deleted
Returns:
New resulting node

moveNodeToGroup

boolean moveNodeToGroup(Node node,
                        Node group)
Moves a node to a group of nodes if it is possible. To move a node to a group node, they must be different, have the same parent and the node to be the group has to be a group of nodes.

Parameters:
node - Node to move to group
group - Group of nodes to move the node
Returns:
True if the node was moved, false otherwise

moveNodesToGroup

void moveNodesToGroup(Node[] nodes,
                      Node group)
Tries to move each node of the nodes array to the group node.

Parameters:
nodes - Array of nodes to move
group - Group node

getAvailableGroupsToMoveNodes

Node[] getAvailableGroupsToMoveNodes(Node[] nodes)

Prepares and returns an array with the groups that the given nodes can be moved to.

These groups are the nodes that have the same parent as the given nodes and are not in the given nodes array.

Parameters:
nodes - Nodes to get available groups to be moved
Returns:
Available groups array of null if the nodes don't all have the same parent

canMoveNodeToGroup

boolean canMoveNodeToGroup(Node node,
                           Node group)
Indicates if a given node can be moved to a group node. To move a node to a group, they must have the same parent and the group node has to be a group of nodes.

Parameters:
node - Node to check if can be moved
group - Group node
Returns:
True if it can be moved, false otherwise

removeNodeFromGroup

boolean removeNodeFromGroup(Node node)
Removes a node from its group if the node is in a group (has a parent). Also breaks the group if the last node is removed.

Parameters:
node - Node to remove from its group
Returns:
True if the node was removed from a group, false otherwise

removeNodesFromGroup

void removeNodesFromGroup(Node[] nodes)
Tries to remove every node in the array from its group checking first they are in a group. Also breaks groups when the last node is removed.

Parameters:
nodes - Arrays of nodes to remove from its group

isNodeInGroup

boolean isNodeInGroup(Node node)
Checks if the node is in a group (has a parent).

Returns:
True if the node is in a group, false otherwise

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

Gephi Toolkit Javadoc