travsr graph
Print a text representation of the graph around a file or symbol.
Synopsis
travsr graph [<file-or-symbol>] [flags]
travsr graph --all [flags]
The positional argument is optional only because --all replaces it; the two are mutually exclusive. travsr get_dependencies is an alias for travsr graph.
Flags
| Flag | Default | Description |
|---|---|---|
--depth <n>, -d | 3 | Maximum traversal depth from the seed node (ignored with --all) |
--direction <dir>, -D | deps | deps (what this imports or defines) | callers (who depends on it) | both |
--format <fmt>, -f | tree | tree (ASCII) | dot (Graphviz, pipe to dot -Tsvg) | json |
--path <hint> | (none) | Path hint to resolve an ambiguous symbol: a filename, relative path, directory, or fragment (e.g. ppr.rs, crates/travsr-retrieval) |
--edges <mode> | semantic | semantic prefers call and override edges, falling back to structural when there are none. all follows every edge kind (ignored with --all) |
--include-noise | (none) | Include third-party and anonymous-local nodes in the output, which are filtered out by default |
--budget <n> | 4096 | Cap output at roughly this many tokens, 0 for unlimited. Truncation keeps the closest nodes and reports how many were cut |
--all | (none) | Dump the entire indexed graph (ignores --depth, --direction, and --edges) |
Examples
# Tree view of a file's neighbourhood (trimmed)
$ travsr graph crates/travsr-daemon/src/hook.rs --depth 1
crates/travsr-daemon/src/hook.rs (file)
├── depends → use:std::path::PathBuf (import)
├── depends → use:anyhow::Context (import)
├── depends → use:travsr_ipc::ControlTransport (import)
├── defines/binding → fn:install_one (function)
├── defines/binding → fn:git_available (function)
├── defines/binding → const:HOOKS (constant)
...
# Callers of a symbol, one level (trimmed)
$ travsr graph install_hook --direction callers --depth 1
fn:install_hook (function)
├── ref/call ← fn:every_git_event_that_moves_the_tree_gets_a_hook (function)
├── ref/call ← fn:chain_cmd_hook_invokes_backed_up_hook (function)
├── ref/call ← fn:second_install_detects_ownership (function)
...
└── defines/binding ← crates/travsr-daemon/src/hook.rs (file)
# DOT format for Graphviz
$ travsr graph install_hook --direction callers --format dot | dot -Tsvg > install_hook.svg
# Full graph as JSON
$ travsr graph --all --format json > graph.json
DOT output example
DOT output groups nodes into clusters by kind, with one shape and color per kind. Trimmed:
digraph travsr {
rankdir=LR;
compound=true;
graph [fontname="monospace" fontsize=11];
node [fontname="monospace" fontsize=10];
edge [fontname="monospace" fontsize=9];
subgraph cluster_2 {
label="Functions";
style=filled;
color="#eab308";
fillcolor="#fef9c3";
n1321832084134547005 [label="fn:install_hook
crates/travsr-daemon/src/hook.rs" shape=ellipse style=filled fillcolor="#fef9c3" color="#eab308"];
n10293312479894199568 [label="fn:every_git_event_that_moves_the_tree_gets_a_hook
crates/travsr-daemon/src/hook.rs" shape=ellipse style=filled fillcolor="#fef9c3" color="#eab308"];
}
n10293312479894199568 -> n1321832084134547005 [label="ref/call"];
}
Feed DOT output to Graphviz (dot, neato, fdp) for visual graph exploration.