Skip to main content

grph subgraph

Extract a subgraph containing only specified nodes.

Synopsis

grph subgraph <file> --nodes <id1,id2,...> [--output FILE] [--json]

Description

The subgraph command extracts a subgraph containing only the specified nodes and all edges between them. This is useful for focusing on a specific set of nodes.

Arguments

ArgumentDescription
filePath to the GEXF file (required)

Options

OptionDescription
--nodesComma-separated list of node IDs to include (required)
--outputSave subgraph to a file (GEXF format)
--jsonOutput summary as JSON
--helpShow help message

Examples

Basic Usage

grph subgraph network.gexf --nodes server1,server2,db1

Output:

Subgraph with nodes: server1, server2, db1

Graph Summary
+------------------+------------------------+
| Property | Value |
+------------------+------------------------+
| Node Count | 3 |
| Edge Count | 2 |
+------------------+------------------------+

Save to File

grph subgraph network.gexf --nodes lb1,server1,server2,db1 --output core-path.gexf

JSON Output

grph subgraph network.gexf --nodes server1,server2 --json

Use Cases

Extract Specific Components

Create a subgraph with only certain components:

grph subgraph dagger-graph.gexf --nodes ViewModel1,ViewModel2,SharedRepo --output viewmodels.gexf

Create Test Fixture

Extract a small subset for testing:

grph subgraph production-graph.gexf --nodes nodeA,nodeB,nodeC --output test-fixture.gexf

Focus Analysis

Analyze relationships between specific nodes:

grph subgraph network.gexf --nodes critical1,critical2,critical3 --json
grph edges network.gexf | grep -E "critical1|critical2|critical3"