Skip to main content

CLI Reference

grph CLI provides comprehensive commands for working with GEXF graph files.

Commands Overview

Basic Commands

CommandDescription
grph infoDisplay a summary of the graph (counts, attributes)
grph metaDisplay full metadata from the GEXF file
grph nodesList and filter nodes in the graph
grph edgesList and filter edges in the graph

Graph Traversal

CommandDescription
grph neighborsFind neighbors of a node
grph pathFind the shortest path between two nodes
grph all-pathsFind all simple paths between two nodes
grph has-pathCheck if a path exists between two nodes
grph reachableFind all nodes reachable from a given node
grph common-neighborsFind nodes that are neighbors of both given nodes

Graph Analysis

CommandDescription
grph statsDisplay comprehensive graph statistics
grph centralityCalculate centrality metrics for nodes
grph componentsAnalyze connected components in the graph
grph degreeShow node degree information

Subgraph Operations

CommandDescription
grph egoExtract the ego graph (neighborhood) around a node
grph subgraphExtract a subgraph containing only specified nodes

Export

CommandDescription
grph exportExport 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:

OptionDescription
--jsonOutput results as JSON instead of a table
--helpShow 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

CodeMeaning
0Success
1Error (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 jq for further processing
  • Integration with other tools
  • Scripting and automation