Skip to main content

Find the Dependency Path Between Two Modules with vg path

vg path reveals the shortest call-graph route between two nodes, so you can see exactly how one part of your codebase reaches another. Use the pick flags to disambiguate endpoints.

Difficulty
Intermediate
Duration
15 minutes
Steps
5

Sometimes you need to know how one module reaches another — for example, why a UI handler ends up touching the database layer. vg path shows the shortest path in the call graph between node A and node B.

Prerequisites

  • A built code graph from vg build
  • Two nodes (A and B) you want to connect

Steps

1. Build the graph

vg build

2. Run path between two nodes

vg path

Provide your start node (A) and end node (B). vg path computes the shortest route through the call graph that connects them.

3. Disambiguate endpoints

If a name matches more than one node, narrow the endpoints with the pick flags:

vg path --pick-a --pick-b

These let you select exactly which A and which B to use when identifiers are ambiguous.

4. Read the path

The output is an ordered chain of nodes from A to B. Each hop is a call-graph edge, so you can see precisely which intermediate functions or modules link the two endpoints.

5. Act on the connection

Use the path to find unexpected coupling, plan a layering fix, or document why two areas depend on each other. If no path exists, the two nodes are not connected in the call graph.

Verification

Confirm vg path returns an ordered chain from A to B. If it reports no path, double-check both endpoints resolve with vg show and that the graph is current via vg status.

Next Steps

  • Surface surprising cross-area links with vg oddities
  • Explain an intermediate node with vg show
  • View the full call tree with vg tree

Prerequisites

  • A built code graph (vg build)
  • Two nodes to connect

Steps

  • 1
    Build the graph
  • 2
    Run path between two nodes
  • 3
    Disambiguate endpoints
  • 4
    Read the path
  • 5
    Act on the connection

Category

Vibgrate