|
Gephi Toolkit Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface HierarchicalGraph
Implementation of graphs within graphs concept, by proposing methods to manipulate the hierarchy of nodes.
The hierarchical graph maintains a tree of all nodes, it's the hierarchy and a
in-view flag for each. Note that 'view' means something else than for
GraphView
.
A node in the hierarchy view means it is visible and none of its ancestors or
descendants are. If this node is expanded, it's children become 'in-view'. If it is
retracted, its parent becomes 'in-view'. The hierarchy view can be modified with
expand()
, retract()
, resetViewToLeaves()
,
resetViewToTopNodes()
and resetViewToLevel()
. Note that
the nodes and edges returns by getNodes()
or getEdges()
use only nodes in the current view. To get all nodes in the hierarchy, see
getNodesTree()
.
GraphModel
Method Summary | |
---|---|
boolean |
addNode(Node node,
Node parent)
Add node as a child of parent in the graph. |
void |
clearMetaEdges(Node node)
Clears all meta edges for node . |
boolean |
expand(Node node)
Expands the graph view from node to its children. |
void |
flatten()
Flatten the hierarchy by keeping only nodes in the view and by transforming meta edges into edges. |
NodeIterable |
getChildren(Node node)
Returns children of node . |
int |
getChildrenCount(Node node)
Returns the number of children of node . |
NodeIterable |
getDescendant(Node node)
Returns descendants of node . |
int |
getDescendantCount(Node node)
Returns the number of descendant of node . |
EdgeIterable |
getEdgesAndMetaEdges()
Return a unique EdgeIterable for edges and meta edges. |
EdgeIterable |
getEdgesAndMetaEdges(Node node)
Returns edges and meta edges incident to node . |
EdgeIterable |
getEdgesTree()
Similar as Graph.getEdges() but all nodes are visited in the hierarchy, so
it returns edges for all possible nodes. |
int |
getHeight()
Returns the height of the tree. |
EdgeIterable |
getHierarchyEdges()
|
EdgeIterable |
getInnerEdges(Node nodeGroup)
Returns edges incident to nodeGroup and nodeGroup 's descendants. |
int |
getLevel(Node node)
Returns the level of node in the hierarchy. |
int |
getLevelSize(int level)
The number of nodes located at the given level int the hierarchy. |
int |
getMetaDegree(Node node)
Returns the degree for node's meta edges. |
MetaEdge |
getMetaEdge(Node node1,
Node node2)
Finds and returns a directed or undirected meta edge that connects node1 and
node2 . |
EdgeIterable |
getMetaEdges()
Returns meta edges for the whole graph. |
EdgeIterable |
getMetaEdges(Node nodeGroup)
Returns meta edges for nodeGroup . |
NodeIterable |
getNodes(int level)
Returns nodes at the given level in the hierarchy. |
NodeIterable |
getNodesTree()
Similar as Graph.getNodes() but all nodes are visited, not only those in the current view. |
EdgeIterable |
getOuterEdges(Node nodeGroup)
Returns edges not incident to nodeGroup or nodeGroup 's descendants. |
Node |
getParent(Node node)
Returns the parent of node or null if node 's parent is (virtual) root. |
NodeIterable |
getTopNodes()
Returns roots of the hierarchy forest. |
int |
getTotalDegree(Node node)
Returns the sum of the degree and the meta-edge degree. |
Node |
groupNodes(Node[] nodes)
Group nodes into a new node group (i.e. cluster). |
boolean |
isAncestor(Node node,
Node ancestor)
Returns true if ancestor is an ancestor of node . |
boolean |
isDescendant(Node node,
Node descendant)
Returns true if descendant is a descendant of node . |
boolean |
isFollowing(Node node,
Node following)
Returns true if following is after node . |
boolean |
isInView(Node node)
Returns true if node is currently in the graph view. |
boolean |
isParent(Node node,
Node parent)
Returns true if parent is the parent of node . |
boolean |
isPreceding(Node node,
Node preceding)
Returns true if preceding is before node . |
void |
moveToGroup(Node node,
Node nodeGroup)
Move node and descendants of node to nodeGroup , as node will be a child of
nodeGroup . |
void |
removeFromGroup(Node node)
Remove node from its parent group and append it to node 's parent. |
void |
resetViewToLeaves()
Reset the current view to leaves of the clustered graph tree. |
void |
resetViewToLevel(int level)
Reset the current view to nodes located at the specified level in the
clustered graph hierarchy. |
void |
resetViewToTopNodes()
Reset the current view to top nodes of the clustered graph tree. |
boolean |
retract(Node node)
Retracts the graph view from node 's children to node . |
void |
ungroupNodes(Node nodeGroup)
Ungroup nodes in nodeGroup and destroy nodeGroup . |
ImmutableTreeNode |
wrapToTreeNode()
Returns the hierarchy tree of all nodes in the form of a TreeNode . |
Methods inherited from interface org.gephi.graph.api.Graph |
---|
addEdge, addNode, clear, clearEdges, clearEdges, contains, contains, getDegree, getEdge, getEdge, getEdge, getEdgeCount, getEdges, getEdges, getEdgeVersion, getGraphModel, getNeighbors, getNode, getNode, getNodeCount, getNodes, getNodeVersion, getOpposite, getView, isAdjacent, isAdjacent, isDirected, isSelfLoop, readLock, readUnlock, readUnlockAll, removeEdge, removeNode, setId, setId, writeLock, writeUnlock |
Method Detail |
---|
boolean addNode(Node node, Node parent)
node
as a child of parent
in the graph. If parent
is
null
, node
is added as a child of the (virtual) root node.
Fails if the node already exists.
node
- the node to addparent
- the existing node whose a child is to be added or null
true
if add is successful, false otherwise
java.lang.IllegalArgumentException
- if node
is null
,
or if parent
is not legal in the graph
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockint getChildrenCount(Node node)
node
. Returns zero
if node
is a leaf.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queried
node
's children
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphint getDescendantCount(Node node)
node
. Returns zero
if node
is a leaf.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queried
node
's descendant
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphNode getParent(Node node)
node
or null
if node
's parent is (virtual) root.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node whose parent is to be returned
node
's parent
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphNodeIterable getChildren(Node node)
node
.
node
- the node whose children are to be returned
node
's children
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphNodeIterable getDescendant(Node node)
node
. Descendants are nodes which node
is an ancestor.
node
- the node whose descendant are to be returned
node
's descendant
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphEdgeIterable getInnerEdges(Node nodeGroup)
nodeGroup
and nodeGroup
's descendants. Edges connected
to nodes which are not descendant of nodeGroup
are excluded.
nodeGroup
- the node whose inner edges are to be returned
nodeGroup
java.lang.IllegalArgumentException
- if nodeGroup
is null
or not legal in the graphEdgeIterable getOuterEdges(Node nodeGroup)
nodeGroup
or nodeGroup
's descendants.
Edges connected to nodes which are descendant of nodeGroup
are excluded.
nodeGroup
- the node whose outer edges are to be returned
nodeGroup
java.lang.IllegalArgumentException
- if nodeGroup
is null
or not legal in the graphNodeIterable getTopNodes()
zero
. If all nodes have the same level (i.e. no hierarchy) this
method is similar as getNodes()
.
NodeIterable getNodesTree()
Graph.getNodes()
but all nodes are visited, not only those in the current view.
EdgeIterable getEdgesTree()
Graph.getEdges()
but all nodes are visited in the hierarchy, so
it returns edges for all possible nodes.
NodeIterable getNodes(int level)
level
in the hierarchy. Top nodes
have the level zero
and leaves' level is the height of the tree.
level
- the level whose nodes are to be returned
level
in the tree
java.lang.IllegalArgumentException
- if level
is not between 0 and the height of the treeint getLevelSize(int level)
level
int the hierarchy. Similar as
getNodes(level).toArray().length
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
level
- the level whose nodes are to be returned
level
java.lang.IllegalArgumentException
- if level
is not between 0 and the height of the treeboolean isDescendant(Node node, Node descendant)
true
if descendant
is a descendant of node
. True if node
is an ancestor
of descendant
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be querieddescendant
- the descendant node to be queried
true
if descendant
is a descendant of node
java.lang.IllegalArgumentException
- if node
or descendant
is null
or not legal in the graphboolean isAncestor(Node node, Node ancestor)
true
if ancestor
is an ancestor of node
. True if node
is a descendant of
ancestor
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queriedancestor
- the ancestor to be queried
true
if ancestor
is an ancestor of node
java.lang.IllegalArgumentException
- if node
or ancestor
is null
or not legal in the graphboolean isFollowing(Node node, Node following)
true
if following
is after node
. The definition is similar to XML
following
axis. Is true when following
has a greater pre and post order than node
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queriedfollowing
- the following to be queried
true
if following
is following node
java.lang.IllegalArgumentException
- if node
or following
is null
or not legal in the graphboolean isPreceding(Node node, Node preceding)
true
if preceding
is before node
. The definition is similar to XML
preceding
axis. Is true when preceding
has a lower pre and post order than node
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queriedpreceding
- the preceding to be queried
true
if preceding
is preceding node
java.lang.IllegalArgumentException
- if node
or preceding
is null
or not legal in the graphboolean isParent(Node node, Node parent)
true
if parent
is the parent of node
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queriedparent
- the parent to be queried
true
if parent
is the parent of node
java.lang.IllegalArgumentException
- if node
or parent
is null
or not legal in the graphint getHeight()
zero
when all nodes have the same level.
Warning: This method is not thread safe, be sure to call it in a locked statement.
int getLevel(Node node)
node
in the hierarchy. Roots have the level zero
and it inscreases when going down
in the tree.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queried
node
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graphvoid moveToGroup(Node node, Node nodeGroup)
node
and descendants of node
to nodeGroup
, as node
will be a child of
nodeGroup
. Be aware nodeGroup
can't be a descendant of node
.
node
- the node to be appened to nodeGroup
childrennodeGroup
- the node to receive node
as a child
java.lang.IllegalArgumentException
- if node
or nodeGroup
is null
or not legal in the graph,
or if nodeGroup
is a descendant of node
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockvoid removeFromGroup(Node node)
node
from its parent group and append it to node
's parent. In other words node
rise
one level in the tree and is no more a child of its parent.
node
- the node to be removed from it's group
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graph,
or if node
is already at the top of the tree
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockNode groupNodes(Node[] nodes)
nodes
into a new node group (i.e. cluster). Creates an upper node in the tree and appends nodes
to it.
Content of nodes
can be existing groups. In that case, nodes
must only contains roots of groups.
Therefore all nodes in nodes
must have the same parent. The method returns the newly
created group of nodes.
nodes
- the nodes to be grouped in a new group
nodes
and descendants of nodes
java.lang.IllegalArgumentException
- if nodes
is null
,
or if nodes
is empty,
or if content nodes are not legal in the graph,
or if nodes
' parent is not similar between elements
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockvoid ungroupNodes(Node nodeGroup)
nodeGroup
and destroy nodeGroup
. Descendants of nodeGroup
are appened to
nodeGroup
's parent node. This method is the opposite of groupNodes()
. If called with the result of
groupNodes()
the state will be equal to the state before calling groupNodes()
.
nodeGroup
- the parent node of nodes to be ungrouped
java.lang.IllegalArgumentException
- if node
is null
, empty or not legal in the graph
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockvoid flatten()
EdgeIterable getHierarchyEdges()
ImmutableTreeNode wrapToTreeNode()
TreeNode
.
TreeNode
wrapper of all nodes in the hierarchy treeboolean expand(Node node)
node
to its children. The children of node
are put in the view and
node
is pulled off. Fails if node
is not currently in the view or if node
don't
have any children.
Meta edges are automatically updated.
node
- the node to be expanded
true
if the expand succeed or false
if not
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graph
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockboolean retract(Node node)
node
's children to node
. The children of node
are pulled
off the view and node
is added to the view. Fails if node
is already in the view of if node
don't have any children.
Meta edges are automatically updated.
node
- the nodes' parent to be retracted
true
if the expand succeed or false
if not
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graph
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockboolean isInView(Node node)
node
is currently in the graph view.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node to be queried
true
if node
is in the view, false
otherwise
java.lang.IllegalArgumentException
- if nodeGroup
is null
or not legal in
the graphvoid resetViewToLeaves()
getNodesInView()
method returns only these leaves.
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockvoid resetViewToTopNodes()
getNodesInView()
method returns only these nodes.
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockvoid resetViewToLevel(int level)
level
in the
clustered graph hierarchy. Therefore the getNodesInView()
method returns
only these nodes.
java.lang.IllegalArgumentException
- if level
is not between 0 and the height of the tree
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lockEdgeIterable getMetaEdges()
Example:
In a clustered graph, let's define group1
and group2
, both with
two leaves as children. Leaves are named l11
, l12
, l21
and l22
. Then we add an edge between l11
and l22
.
Then we look at the view of the graph. Let's say the view is set for groups only, that means
only groups are visible and leaves are not. At this point we can say a meta edge exist between
group1
and group2
and it represents the edge l11-l22
.
Therefore meta edges are useful when a graph is retracted/collapsed into clusters. Relations between clusters can be get with meta edges directly. Note that a meta edge knows which edges it represents and its weight is the sum of content edges' weight.
EdgeIterable getEdgesAndMetaEdges()
EdgeIterable
for edges and meta edges. The content is the
union of getEdges()
and getMetaEdges()
.
EdgeIterable getMetaEdges(Node nodeGroup)
nodeGroup
.
nodeGroup
- the node whose meta edges are queried
java.lang.IllegalArgumentException
- if nodeGroup
is null
or not legal in
the graphEdgeIterable getEdgesAndMetaEdges(Node node)
node
.
For directed graph, note that self-loops are repeated only once. Undirected graphs repeats edges once by default.
node
- the node whose incident edges and meta edges are to be returned
node
java.lang.IllegalArgumentException
- if node
is null
or not legal in the graph.MetaEdge getMetaEdge(Node node1, Node node2)
node1
and
node2
. Returns null
if no such edge is found.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node1
- the first incident node of the queried meta edgenode2
- thge second incident node of the queried meta edge
node1
and node2
or null
if no such edge exists
java.lang.IllegalArgumentException
- if node1
or node2
are null
or not legal nodes in the graphint getMetaDegree(Node node)
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node whose meta degree is queried
node
java.lang.IllegalArgumentException
- if node
is null
of not legal in
the graph.int getTotalDegree(Node node)
getDegree(Node) + getMetaDegree(Node)
.
Warning: This method is not thread safe, be sure to call it in a locked statement.
node
- the node whose total degree is queried
node
java.lang.IllegalArgumentException
- if node
is null
of not legal in
the graph.void clearMetaEdges(Node node)
node
.
node
- the node whose meta edges will be deleted
java.lang.IllegalArgumentException
- if node
is null
of not legal in
the graph.
java.lang.IllegalMonitorStateException
- if the current thread is holding a read lock
|
Gephi Toolkit Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |