public interface Tree extends Graph
| Modifier and Type | Method and Description |
|---|---|
Edge |
addNode(Vertex parent,
Vertex childNode)
Convenience method to adding nodes in a Tree.
|
Tree |
createTree()
Factory method that returns a new instance of TreeImpl.
|
List |
getChildren(Vertex vertex)
Returns the child nodes of the node specified by the argument.
|
int |
getDepth(Vertex node)
Returns the depth of the node in the Tree.
|
int |
getHeight()
Returns the height of the Tree.
|
List |
getLeaves()
Returns a List of the leaves of ths Tree.
|
Vertex |
getParent(Vertex vertex)
Returns the parent node of the node specified by the argument.
|
Vertex |
getRoot()
Returns the current root of the Tree.
|
Tree |
getSubTree(Vertex subTreeRootVertex)
Returns a new instance of a Tree that is rooted
from the specified node.
|
boolean |
isLeaf(Vertex vertex)
Returns true if the specified node is a leaf.
|
void |
setRoot(Vertex rootVertex)
Sets the root of the Tree.
|
add, addEdge, addEdge, addGraphAddEdgeListener, addGraphAddVertexListener, addGraphRemoveEdgeListener, addGraphRemoveVertexListener, addListener, cloneVertices, getAdjacentVertices, getAdjacentVertices, getConnectedSet, getConnectedSet, getDegree, getDegree, getEdges, getEdgesCount, getEdgeSet, getGraphFactory, getTraversal, getVertexSet, getVertices, getVerticesCount, getVerticesIterator, isConnected, remove, removeEdge, removeEdges, removeGraphAddEdgeListener, removeGraphAddVertexListener, removeGraphRemoveEdgeListener, removeGraphRemoveVertexListener, removeListener, setGraphFactory, setTraversal, traversevoid setRoot(Vertex rootVertex) throws GraphException
GraphExceptionVertex getRoot()
Vertex getParent(Vertex vertex) throws GraphException
EmptyTreeException - is the Tree is empty.GraphExceptionList getChildren(Vertex vertex) throws GraphException
EmptyTreeException - is the Tree is empty.GraphExceptionTree getSubTree(Vertex subTreeRootVertex) throws Exception
Although a new Tree is returned, the nodes and edges within the new Tree are the same instances as those of the Tree from where it was taken from.
subTreeRootVertex - The root of the subtree that we want to returnEmptyTreeException - is the Tree is empty.Exceptionint getDepth(Vertex node) throws GraphException
GraphExceptionList getLeaves()
int getHeight()
Edge addNode(Vertex parent, Vertex childNode) throws Exception
Adds a node to the Tree. The parent node must already be existing in the Tree before the child node can be added. To add the root node, specify null as the parent.
Note that the parent and child relativity is dependent for whatever is the current root node of the Tree. Hence, if childNode later on becomes root via setRoot(), then the parent actually becomes the child of childNode.
GraphException - if there is already a root or the child node
is already existing.NoSuchVertexException - if the parent is not null and is not existingExceptionboolean isLeaf(Vertex vertex) throws GraphException
EmptyTreeException - is the Tree is empty.GraphExceptionTree createTree()
Copyright © 2019 JULIE Lab, Germany. All rights reserved.