Graph Topology
The gat graph commands analyze power network topology: detect islands, compute graph statistics, find shortest paths, and export to graph formats for visualization.
Overview
| Command | Purpose |
|---|---|
gat graph stats | Compute graph statistics (nodes, edges, density) |
gat graph islands | Detect electrically isolated islands |
gat graph path | Find shortest path between buses |
gat graph export | Export to DOT/GraphML for visualization |
gat graph neighbors | List buses connected to a given bus |
Quick Start
Basic Statistics
Output:
Graph Statistics
────────────────
Nodes (buses): 118
Edges (branches): 186
Density: 0.027
Average degree: 3.15
Max degree: 9 (bus 69)
Diameter: 14
Connected: Yes (1 island)
Detect Islands
Output:
Island Detection
────────────────
Total islands: 2
Island 1: 115 buses
Buses: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]
Island 2: 3 buses (ISOLATED)
Buses: [116, 117, 118]
Warning: Disconnected from main grid
Export for Visualization
# Export to DOT format (Graphviz)
# Render with Graphviz
Graph Statistics
gat graph stats
Compute topological properties of the network graph:
Output columns:
| Metric | Description |
|---|---|
nodes | Number of buses |
edges | Number of branches (including transformers) |
density | Edge density: 2E / (N × (N-1)) |
avg_degree | Average connections per bus |
max_degree | Most connected bus |
min_degree | Least connected bus |
diameter | Longest shortest path |
radius | Minimum eccentricity |
num_islands | Number of connected components |
Options
Use Cases
Pre-analysis validation:
# Verify network connectivity before OPF
|
# Should be 1 for a valid network
Compare network variants:
# Analyze topology changes
Island Detection
gat graph islands
Identify electrically isolated subnetworks:
Output format:
Options
Workflows
Pre-power-flow validation:
#!/bin/bash
# Check for islands before running power flow
ISLANDS=
if [; then
fi
Contingency analysis:
# Find contingencies that island the network
for; do
# Temporarily open branch
islands=
if [; then
fi
done
Path Finding
gat graph path
Find shortest path between two buses:
Output:
Shortest Path: Bus 1 → Bus 118
──────────────────────────────
Hops: 7
Path: 1 → 2 → 5 → 6 → 11 → 12 → 117 → 118
Path details:
1 → 2: Branch L1-2 (line, 10.5 km)
2 → 5: Branch L2-5 (line, 25.0 km)
5 → 6: Branch T5-6 (transformer)
6 → 11: Branch L6-11 (line, 15.2 km)
11 → 12: Branch L11-12 (line, 8.3 km)
12 → 117: Branch L12-117 (line, 42.1 km)
117 → 118: Branch L117-118 (line, 5.0 km)
Total impedance: 0.0234 + j0.1567 pu
Options
Use Cases
Trace power flow path:
# Find path from generator to load
Identify critical paths:
# Find all paths between major substations
Neighbor Analysis
gat graph neighbors
List buses directly connected to a given bus:
Output:
Neighbors of Bus 5
──────────────────
Direct connections: 4
Bus 2: Branch L2-5 (line)
Bus 4: Branch L4-5 (line)
Bus 6: Branch T5-6 (transformer)
Bus 7: Branch L5-7 (line)
Options
Use Cases
Local topology analysis:
# Analyze substation connectivity
| \
Find isolated buses:
# Buses with only one connection (radial endpoints)
| \
Graph Export
gat graph export
Export network topology for visualization tools:
# DOT format (Graphviz)
# GraphML format (Gephi, yEd)
# JSON format (D3.js, vis.js)
DOT Format Options
Rendering with Graphviz:
# Simple layout
# Force-directed layout (better for large networks)
# Circular layout
# SVG for web
GraphML Format Options
Opening in Gephi:
- Open Gephi → File → Open → grid.graphml
- Apply layout (ForceAtlas 2 works well for power grids)
- Color by node attribute (voltage level, bus type)
JSON Format for Web
Structure:
Using with D3.js:
// Load and visualize
"grid.json";
Advanced Workflows
Topology Validation Pipeline
#!/bin/bash
# validate_topology.sh - Check network topology before analysis
GRID=
REPORT="topology_report.md"
# 1. Basic statistics
# 2. Island detection
ISLANDS=
if [; then
else
fi
# 3. Degree analysis
| \
# 4. Export for visualization
Critical Branch Analysis
#!/bin/bash
# Find branches whose failure would island the network
GRID=
BRANCHES=
for; do
# Check if removing this branch creates islands
result=
islands=
if [; then
|
fi
done
Multi-Network Comparison
# Compare topology of base case vs expansion plan
Troubleshooting
"Network has multiple islands"
Cause: Open branches disconnecting parts of the network
Solution:
# Find open branches
| \
# Check which branches are critical
Path not found
Cause: Buses are in different islands
Solution:
# Check which island each bus belongs to
| \
Export produces empty file
Cause: No buses/branches in network
Solution:
# Verify network loaded correctly
Integration
Python NetworkX Integration
"""Load GAT network as NetworkX graph."""
=
=
=
return
# Usage
=
Rust Integration
use Network;
use ;
let network = load_network?;
// Compute statistics
let analyzer = new;
println!;
println!;
println!;
// Detect islands
let detector = new;
let islands = detector.detect?;
println!;
// Find path
let path = analyzer.shortest_path?;
println!;
Related Commands
- Network Inspection — Detailed component data
- Contingency Analysis — N-1 security assessment
- Convert — Import/export network formats
Theory Reference
- Contingency Analysis Theory — Topology-based screening
- Graph Theory — Mathematical foundations