Tree Visualizer: Diameter, Binary Lifting LCA & Tree DP
Reroot any tree cleanly with a hierarchical layout engine, import AtCoder/Codeforces parent arrays or LeetCode parent = [-1,...] syntax, and inspect post-order DP states step-by-step.
Built-In Tree Algorithms
Tree Diameter & Centers
Double-BFS traversal highlighting endpoints of the longest simple path and central node(s).Binary Lifting LCA
Visualizes depth equalization and simultaneous2^k ancestor jumps toward the Lowest Common Ancestor.
Subtree Size & Depth DP
Bottom-up postorder trace displaying computedsz[u] and depth per vertex.
Tree Max Independent Set (MIS)
Evaluatesdp[u][0] vs dp[u][1] bottom-up and reconstructs the optimal independent vertex set.
Tree Centroid Decomposition
Identifies centroid vertex/vertices splitting the tree into components of size at mostN / 2.
Pasteable Tree Inputs
# Option 1: Edge pairs 1 2 1 3 2 4 2 5 3 6 3 7 # Option 2: Codeforces / AtCoder parent array (N nodes, p_2..p_N) 5 1 1 2 2
Frequently Asked Questions
How do I reroot a tree in Hierarchical Tree layout?
Switch Layout to Hierarchical Tree, click any vertex, and click Set as Tree Root in the Node Tracer panel.
Does bottom bar show when a graph is a valid Tree?
Yes — as soon as the active graph is connected and acyclic (E = V - 1), a green Tree badge appears in the status bar.