CLI Reference
grph CLI provides comprehensive commands for working with GEXF graph files.
Commands Overview
Basic Commands
| Command | Description |
|---|---|
grph info | Display a summary of the graph (counts, attributes) |
grph meta | Display full metadata from the GEXF file |
grph nodes | List and filter nodes in the graph |
grph edges | List and filter edges in the graph |
Graph Traversal
| Command | Description |
|---|---|
grph neighbors | Find neighbors of a node |
grph path | Find the shortest path between two nodes |
grph all-paths | Find all simple paths between two nodes |
grph has-path | Check if a path exists between two nodes |
grph reachable | Find all nodes reachable from a given node |
grph common-neighbors | Find nodes that are neighbors of both given nodes |
Graph Analysis
| Command | Description |
|---|---|
grph stats | Display comprehensive graph statistics |
grph centrality | Calculate centrality metrics for nodes |
grph components | Analyze connected components in the graph |
grph degree | Show node degree information |
Subgraph Operations
| Command | Description |
|---|---|
grph ego | Extract the ego graph (neighborhood) around a node |
grph subgraph | Extract a subgraph containing only specified nodes |
Export
| Command | Description |
|---|---|
grph export | Export the graph to different formats |
Global Options
These options are available for all commands:
grph --version # Show version and exit
grph --help # Show help message and exit
Common Options
Most commands support these options:
| Option | Description |
|---|---|
--json | Output results as JSON instead of a table |
--help | Show help for the specific command |
File Argument
All commands require a GEXF file as the first argument:
grph <command> <file.gexf> [options]
The file must:
- Exist and be readable
- Be a valid GEXF XML file
- Use a supported GEXF version (1.1, 1.2, or 1.3)
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error (file not found, parse error, etc.) |
Output Formats
Table Output (Default)
Commands output rich, formatted tables by default:
Nodes (2)
┏━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Label ┃ Attributes ┃
┡━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ server1 │ Web Server 1 │ type=server, weight=1.5 │
│ server2 │ Web Server 2 │ type=server, weight=2.0 │
└─────────┴──────────────┴─────────────────────────┘
JSON Output
Add --json for machine-readable output:
grph nodes graph.gexf --json
[
{
"id": "server1",
"label": "Web Server 1",
"attributes": {"type": "server", "weight": 1.5}
}
]
JSON output is useful for:
- Piping to
jqfor further processing - Integration with other tools
- Scripting and automation