I’m curious about how agentic tools can better understand a codebase if they know how to traverse a Graph.

For that reason, I (read Claude Code) have put together a CLI tool to easily consume a Graph. I call it grph.

How does this work?

The CLI is a thin wrapper around the Python library NetworkX. The codebase exposes a number of features.

The CLI ingests a graph formatted with GEXF format. This is a universal way of defining a graph.

Neighbours

Imagine you have an airline route network. You’re at Gatwick and want to know where you can fly direct:

$ grph neighbors routes.gexf Gatwick

Neighbors of Gatwick (depth=1, direction=all)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID        β”‚ Label       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Barcelona β”‚ Barcelona   β”‚
β”‚ Amsterdam β”‚ Amsterdam   β”‚
β”‚ Nice      β”‚ Nice        β”‚
β”‚ Berlin    β”‚ Berlin      β”‚
β”‚ Lisbon    β”‚ Lisbon      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

What about with one layover?

$ grph neighbors routes.gexf Gatwick --depth 2

Shortest Path

How do I get from Edinburgh to Dubrovnik with the fewest connections?

$ grph path routes.gexf Edinburgh Dubrovnik

Path found (length: 3)
Edinburgh β†’ Gatwick β†’ Split β†’ Dubrovnik

Or find all the options:

$ grph all-paths routes.gexf Edinburgh Dubrovnik --max-depth 4

PageRank

Which airports are the most critical hubs in the network? PageRank reveals where traffic flows through:

$ grph centrality routes.gexf --type pagerank --top 5

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Node      β”‚ Score     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Gatwick   β”‚ 0.0892    β”‚
β”‚ Barcelona β”‚ 0.0734    β”‚
β”‚ Amsterdam β”‚ 0.0651    β”‚
β”‚ Milan     β”‚ 0.0612    β”‚
β”‚ Paris     β”‚ 0.0598    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

And more

Find isolated route clusters - are there parts of the network disconnected from each other?

$ grph components routes.gexf --list

Blast radius - if Gatwick closes, which destinations become unreachable from Edinburgh?

$ grph reachable routes.gexf Edinburgh

Extract a subgraph - pull out just the UK airports for focused analysis:

$ grph subgraph routes.gexf --nodes Gatwick,Edinburgh,Manchester,Bristol --output uk-routes.gexf

But why?

I work in a medium-sized Android codebase. It has a lot of complexity baked into it: modularisation and a complex DI graph. I want Claude Code to be able to browse and understand both static and dynamic connections.

The same queries that answer β€œhow do I fly from Edinburgh to Dubrovnik?” can answer β€œhow does MainActivity depend on DatabaseHelper?” - it’s all just graph traversal.