public GDirectedGraph<V, E> toTree(V root) {

		// first sort the vertices topologically
		List<V> sorted = topolocigalSort(root);

		// Visit nodes in the sorted order and track the longest path to each node from the root.
		Map<V, Depth> depthMap = assignDepths(root, sorted);

		// Assign vertices to the tree in the sorted order and only using edges where the "from"
		// vertex (parent) is at a depth 1 less then the depth of "to" vertex. This will ensure
		// that the tree is ordered such that if all the original forward edges are added back in,
		// they would always flow down the tree.
		return createTree(root, sorted, depthMap);

	}
Creates a tree graph with the given vertex as the root from this object's graph.

@param root the vertex to be used as the root
getting first shot at claiming children for its sub-tree.
@return a graph with edges removed such that the graph is a tree.
Ghidra/Framework/Graph/src/main/java/ghidra/graph/GraphToTreeAlgorithm.java