Package org.jungrapht.visualization.util
Class TreeUtils
- java.lang.Object
-
- org.jungrapht.visualization.util.TreeUtils
-
public class TreeUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description TreeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V,E>
voidaddSubTree(org.jgrapht.Graph<V,E> tree, org.jgrapht.Graph<V,E> subTree, V subTreeParent, E connectingEdge)ConnectssubTreetotreeby attaching it as a child ofsubTreeParentwith edgeconnectingEdge.static <V,E>
org.jgrapht.Graph<V,E>getSubTree(org.jgrapht.Graph<V,E> tree, V root)Returns a copy of the subtree oftreewhich is rooted atroot.static <V,E>
voidgrowSubTree(org.jgrapht.Graph<V,E> tree, org.jgrapht.Graph<V,E> subTree, V root)Populatessubtreewith the subtree oftreewhich is rooted atroot.static <V> booleanisForestShaped(org.jgrapht.Graph<V,?> graph)A graph is "forest-shaped" if it is directed, acyclic, and each vertex has at most one predecessor.static <V,E>
voidremoveTreeVertex(org.jgrapht.Graph<V,E> tree, V subRoot)removes a vertex and all descendants from a treestatic <V> Set<V>roots(org.jgrapht.Graph<V,?> graph)
-
-
-
Method Detail
-
roots
public static <V> Set<V> roots(org.jgrapht.Graph<V,?> graph)
-
isForestShaped
public static <V> boolean isForestShaped(org.jgrapht.Graph<V,?> graph)
A graph is "forest-shaped" if it is directed, acyclic, and each vertex has at most one predecessor.
-
getSubTree
public static <V,E> org.jgrapht.Graph<V,E> getSubTree(org.jgrapht.Graph<V,E> tree, V root)Returns a copy of the subtree oftreewhich is rooted atroot.- Type Parameters:
V- the vertex typeE- the edge type- Parameters:
tree- the tree whose subtree is to be extractedroot- the root of the subtree to be extracted
-
growSubTree
public static <V,E> void growSubTree(org.jgrapht.Graph<V,E> tree, org.jgrapht.Graph<V,E> subTree, V root)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(org.jgrapht.Graph<V,E> tree, org.jgrapht.Graph<V,E> subTree, V subTreeParent, E connectingEdge)ConnectssubTreetotreeby attaching it as a child ofsubTreeParentwith 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 totreesubTreeParent- the parent of the root ofsubTreein its new position intreeconnectingEdge- the edge used to connectsubTreeParenttosubtree's root
-
removeTreeVertex
public static <V,E> void removeTreeVertex(org.jgrapht.Graph<V,E> tree, V subRoot)removes a vertex and all descendants from a tree- Type Parameters:
V- the vertex typeE- the edge type- Parameters:
tree- the tree to mutatesubRoot- the vertex to remove
-
-