Explore the Call Tree with vg tree
vg tree prints the depth-bounded, cycle-safe call tree rooted at a node — callees by default, callers with --callers — so you can scope a change in both directions.
When you want to see everything a function reaches — or everything that reaches it — vg tree prints the call tree rooted at a node. It is depth-bounded and cycle-safe, so it stays readable even in tangled code.
Prerequisites
- A built code graph from
vg build
Steps
1. Build the graph
vg build
2. View the call tree
vg tree
By default vg tree shows callees — the chain of what your node calls, then what those call, and so on.
3. Invert to callers
To see what depends on the node instead, flip the direction:
vg tree --callers
This roots the tree at your node and walks upward through everything that calls it.
4. Bound the depth
Control how deep the tree goes with --depth:
vg tree --depth 3
A bounded depth keeps the output focused on the layers you care about.
5. Use the tree to plan work
A callees tree helps you understand what a function relies on before you modify it; a callers tree (--callers) shows who you might break. Together they frame the scope of a change.
Verification
Confirm vg tree prints a rooted tree and that --callers inverts the direction. If the tree is empty, rebuild with vg build and check the node with vg show.
Next Steps
- Quantify the blast radius with
vg impact - Connect two nodes with
vg path - Find the most-depended-on nodes with
vg hubs