Skip to main content

grph neighbors

Find neighbors of a node in the graph.

Synopsis

grph neighbors <file> <node_id> [--direction in|out|all] [--depth N] [--json]

Description

The neighbors command finds nodes that are directly connected to a specified node. For directed graphs, you can control whether to find predecessors (incoming edges), successors (outgoing edges), or both.

Use the --depth option to find multi-hop neighbors (nodes within N edges of the target).

Arguments

ArgumentDescription
filePath to the GEXF file (required)
node_idID of the node to find neighbors for (required)

Options

OptionDefaultDescription
--directionallDirection for directed graphs: in (predecessors), out (successors), or all (both)
--depth1Number of hops to traverse
--jsonOutput as JSON instead of a table
--helpShow help message

Examples

Basic Usage

Find all direct neighbors of a node:

grph neighbors network.gexf server1

Direction Control

Find only incoming neighbors (predecessors):

grph neighbors network.gexf db1 --direction in

Find only outgoing neighbors (successors):

grph neighbors network.gexf lb1 --direction out

Multi-Hop Neighbors

Find all nodes within 2 hops:

grph neighbors network.gexf lb1 --depth 2

JSON Output

grph neighbors network.gexf server1 --json

Use Cases

Dependency Analysis

Find what a component depends on:

grph neighbors dagger-graph.gexf MyViewModel --direction out

Impact Analysis

Find what depends on a component:

grph neighbors dagger-graph.gexf SharedRepository --direction in

Neighborhood Exploration

Explore the local structure around a node:

grph neighbors network.gexf central-node --depth 3