Parents, Children, and Depth in Rooted Trees
Rooting a tree gives each nonroot vertex one parent on its path to the root. Depth is its distance in edges from that root.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Measure a short branch
For root A with child B and B's child C, depths are zero, one, and two. C is a descendant of A and B. See trees as graphs for why the path to the root is unique.
Compare node and tree quantities
Depth measures down to a specified node. Tree height measures the longest downward distance from the root under the edge convention. A different rooting can change every one of these depths.[1]
Choose a root and recompute affected relationships
In path A–B–C–D rooted at A, depths are zero, one, two and three. Rooting at C makes C depth zero, B and D depth one, and A depth two. The undirected graph stayed the same. See height of a tree.
Root A: A→B→C→D
Root C: C→B→A and C→D
Depths with root C: C0, B1, D1, A2
Use the right reference point for an answer
Depth counts edges from the root. Height of a node commonly counts edges to its deepest descendant. These can differ even at a leaf or at the root. Test a leaf and the same internal vertex after changing the root.