Skip to main content

grph edges

List and filter edges in the graph.

Synopsis

grph edges <file> [--attr KEY=VALUE]... [--source ID] [--target ID] [--type TYPE] [--json] [--no-attrs]

Description

The edges command lists all edges in a GEXF graph, with optional filtering capabilities. You can filter edges by:

  • Attribute values - Match edges with specific attribute values
  • Source node - Match edges originating from a specific node
  • Target node - Match edges pointing to a specific node
  • Edge type - Match edges of a specific type (directed/undirected)

When multiple filters are specified, they are combined with AND logic - an edge must match all filters to be included.

Arguments

ArgumentDescription
filePath to the GEXF file (required)

Options

OptionDescription
--attr KEY=VALUEFilter by attribute. Can be specified multiple times.
--source IDFilter by source node ID
--target IDFilter by target node ID
--type TYPEFilter by edge type (e.g., directed, undirected)
--jsonOutput as JSON instead of a table
--no-attrsHide the attributes column in table output
--helpShow help message

Examples

List All Edges

grph edges network.gexf

Output:

                           Edges (6)
┏━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Source ┃ Target ┃ Weight ┃ Type ┃ Attributes ┃
┡━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ e0 │ lb1 │ server1 │ 1.0 │ │ relationship=routes │
│ e1 │ lb1 │ server2 │ 1.0 │ │ relationship=routes │
│ e2 │ server1│ db1 │ 2.0 │ │ relationship=queries│
│ e3 │ server2│ db1 │ 2.0 │ │ relationship=queries│
│ e4 │ server1│ cache1 │ 0.5 │ │ relationship=caches │
│ e5 │ server2│ cache1 │ 0.5 │ │ relationship=caches │
└────┴────────┴─────────┴────────┴──────┴─────────────────────┘

Filter by Source Node

Find all edges originating from the load balancer:

grph edges network.gexf --source lb1

Output:

                           Edges (2)
┏━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Source ┃ Target ┃ Weight ┃ Type ┃ Attributes ┃
┡━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ e0 │ lb1 │ server1 │ 1.0 │ │ relationship=routes │
│ e1 │ lb1 │ server2 │ 1.0 │ │ relationship=routes │
└────┴────────┴─────────┴────────┴──────┴─────────────────────┘

Filter by Target Node

Find all edges pointing to the database:

grph edges network.gexf --target db1

Filter by Attribute

Find all edges with a specific relationship:

grph edges network.gexf --attr relationship=queries

Combine Filters (AND Logic)

Find edges from server1 to db1:

grph edges network.gexf --source server1 --target db1

Find query edges from server1:

grph edges network.gexf --source server1 --attr relationship=queries

JSON Output

grph edges network.gexf --source lb1 --json
[
{
"id": "e0",
"source": "lb1",
"target": "server1",
"weight": 1.0,
"type": null,
"label": null,
"attributes": {
"relationship": "routes"
}
},
{
"id": "e1",
"source": "lb1",
"target": "server2",
"weight": 1.0,
"type": null,
"label": null,
"attributes": {
"relationship": "routes"
}
}
]

Hide Attributes Column

grph edges network.gexf --no-attrs

Edge Properties

Each edge in the output includes:

PropertyDescription
IDUnique edge identifier
SourceID of the source node
TargetID of the target node
WeightEdge weight (if defined)
TypeEdge type (directed/undirected, if specified per-edge)
AttributesCustom attributes defined in the GEXF file

Finding Connections

All Edges for a Node

To find all edges connected to a node (both incoming and outgoing), run two queries:

# Outgoing edges
grph edges graph.gexf --source nodeA

# Incoming edges
grph edges graph.gexf --target nodeA

Or combine with JSON and jq:

grph edges graph.gexf --json | jq '[.[] | select(.source == "nodeA" or .target == "nodeA")]'

Path Between Nodes

To check if there's a direct edge between two nodes:

grph edges graph.gexf --source nodeA --target nodeB

If no edges are returned, there's no direct connection.