Class TreeUtils
java.lang.Object
edu.uci.ics.jung.graph.util.TreeUtils
Contains static methods for operating on instances of
Tree.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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) ConnectssubTreetotreeby attaching it as a child ofnodewith edgeconnectingEdge.static <V,E> List <V> static <V,E> Tree <V, E> getSubTree(Forest<V, E> forest, V root) Returns the subtree oftreewhich is rooted atrootas aForest.static <V,E> void growSubTree(Forest<V, E> tree, Forest<V, E> subTree, V root) Populatessubtreewith the subtree oftreewhich is rooted atroot.
-
Constructor Details
-
TreeUtils
public TreeUtils()
-
-
Method Details
-
getRoots
-
getSubTree
public static <V,E> Tree<V,E> getSubTree(Forest<V, E> forest, V root) throws InstantiationException, IllegalAccessExceptionReturns the subtree oftreewhich is rooted atrootas aForest. The tree returned is an independent entity, although it uses the same vertex and edge objects.- Type Parameters:
V- the vertex typeE- the edge type- Parameters:
forest- the tree whose subtree is to be extractedroot- the root of the subtree to be extracted- Returns:
- the subtree of
treewhich is rooted atroot - Throws:
InstantiationException- if a new tree of the same type cannot be createdIllegalAccessException- if a new tree of the same type cannot be created
-
growSubTree
Populatessubtreewith the subtree oftreewhich is rooted atroot.- Type Parameters:
V- the vertex typeE- the edge type- Parameters:
tree- the tree whose subtree is to be extractedsubTree- the tree instance which is to be populated with the subtree oftreeroot- the root of the subtree to be extracted
-
addSubTree
public static <V,E> void addSubTree(Forest<V, E> tree, Forest<V, E> subTree, V node, E connectingEdge) ConnectssubTreetotreeby attaching it as a child ofnodewith edgeconnectingEdge.- Type Parameters:
V- the vertex typeE- the edge type- Parameters:
tree- the tree to whichsubTreeis to be addedsubTree- the tree which is to be grafted on totreenode- the parent ofsubTreein its new position intreeconnectingEdge- the edge used to connectsubtree's root as a child ofnode
-
addFromSubTree
-