/** * Returns a copy of the subtree of <code>tree</code> which is rooted at <code>root</code>. * * @param <N> the node type * @param <E> the edge type * @param tree the tree whose subtree is to be extracted * @param root the root of the subtree to be extracted */ public static <N, E> MutableCTreeNetwork<N, E> getSubTree(CTreeNetwork<N, E> tree, N root) { checkNotNull(tree, "tree"); checkNotNull(root, "root"); checkArgument( tree.nodes().contains(root), "Input tree does not contain the input subtree root"); MutableCTreeNetwork<N, E> subtree = TreeNetworkBuilder.from(tree).withRoot(root).build(); growSubTree(tree, subtree, root); return subtree; }