Grph
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.