Skip to main content

grph reachable

Find all nodes reachable from a given node.

Synopsis

grph reachable <file> <node_id> [--direction forward|backward|both] [--max-depth N] [--json]

Description

The reachable command finds all nodes that can be reached from a starting node. For directed graphs, you can search forward (descendants), backward (ancestors), or both.

Arguments

ArgumentDescription
filePath to the GEXF file (required)
node_idID of the starting node (required)

Options

OptionDefaultDescription
--directionforwardDirection: forward (descendants), backward (ancestors), both
--max-depthunlimitedMaximum traversal depth
--jsonOutput as JSON
--helpShow help message

Examples

Forward Reachability (Descendants)

Find all nodes reachable from a starting point:

grph reachable network.gexf lb1

Backward Reachability (Ancestors)

Find all nodes that can reach a target:

grph reachable network.gexf db1 --direction backward

Both Directions

Find the entire connected component:

grph reachable network.gexf server1 --direction both

Find nodes within 2 hops:

grph reachable network.gexf lb1 --max-depth 2

Use Cases

Impact Analysis

Find all components affected by a change:

grph reachable dagger-graph.gexf SharedRepository --direction backward
# Shows everything that depends on SharedRepository

Dependency Tree

Find all dependencies of a component:

grph reachable dagger-graph.gexf MainActivity --direction forward
# Shows everything MainActivity depends on

Transitive Closure

Find all transitively connected nodes:

grph reachable network.gexf central-node --direction both