public class TreeUtils
extends java.lang.Object
Tree.| Constructor and Description |
|---|
TreeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <V,E> void |
addFromSubTree(Forest<V,E> tree,
Forest<V,E> subTree,
E edge,
V parent,
V root) |
static <V,E> void |
addSubTree(Forest<V,E> tree,
Forest<V,E> subTree,
V node,
E connectingEdge)
Connects
subTree to tree by attaching it as a child
of node with edge connectingEdge. |
static <V,E> java.util.List<V> |
getRoots(Forest<V,E> forest)
Returns the roots of this forest.
|
static <V,E> Tree<V,E> |
getSubTree(Forest<V,E> forest,
V root)
Returns the subtree of
tree which is rooted at root as a Forest. |
static <V,E> void |
growSubTree(Forest<V,E> tree,
Forest<V,E> subTree,
V root)
Populates
subtree with the subtree of tree
which is rooted at root. |
public static <V,E> java.util.List<V> getRoots(Forest<V,E> forest)
V - the vertex typeE - the edge typepublic static <V,E> Tree<V,E> getSubTree(Forest<V,E> forest, V root) throws java.lang.InstantiationException, java.lang.IllegalAccessException
tree which is rooted at root as a Forest.
The tree returned is an independent entity, although it uses the same vertex and edge objects.V - the vertex typeE - the edge typeforest - the tree whose subtree is to be extractedroot - the root of the subtree to be extractedtree which is rooted at rootjava.lang.InstantiationException - if a new tree of the same type cannot be createdjava.lang.IllegalAccessExceptionpublic static <V,E> void growSubTree(Forest<V,E> tree, Forest<V,E> subTree, V root)
subtree with the subtree of tree
which is rooted at root.V - the vertex typeE - the edge typetree - the tree whose subtree is to be extractedsubTree - the tree instance which is to be populated with the subtree of treeroot - the root of the subtree to be extractedpublic static <V,E> void addSubTree(Forest<V,E> tree, Forest<V,E> subTree, V node, E connectingEdge)
subTree to tree by attaching it as a child
of node with edge connectingEdge.V - the vertex typeE - the edge typetree - the tree to which subTree is to be addedsubTree - the tree which is to be grafted on to treenode - the parent of subTree in its new position in treeconnectingEdge - the edge used to connect subtree's root as a child of nodeCopyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence