Part X: Sensor Fusion, World Models, and Spatial AI
Chapter 54: Graph Neural Networks for Sensor Networks

Traffic, energy, water, and industrial grids

"I trained one model on cars, one on electrons, one on water, and one on a chemical plant. Halfway through I realized I had written the same message-passing loop four times and only the conservation law changed."

A Grid-Weary AI Agent

Prerequisites

This section is the applications payoff for the chapter, so it assumes the machinery already in place: nodes and relations from Section 54.1, the spatial-process-dynamic graph families from Section 54.2, and the spatiotemporal architectures (DCRNN, Graph WaveNet, BigST) from Section 54.3. Fault localization by message passing (Section 54.4) and the scalability tricks of Section 54.5 are the tools we now point at real infrastructure. Domain grounding comes from Chapter 39 (energy and environmental sensors) and Chapter 35 (industrial sensing). You should be comfortable reading a weighted adjacency \(A\) and a per-node feature tensor \(X \in \mathbb{R}^{N \times T \times F}\).

Four grids, one conservation law wearing four coats

Traffic, power, water, and industrial process networks look like utterly different engineering worlds, and their operators rarely talk to each other. Yet to a graph neural network they are near-identical problems: a set of instrumented junctions (nodes), a set of physical conduits carrying a conserved flow between them (edges), and a demand for forecasts, state estimates, or fault locations that respect the topology. Vehicles conserve on road segments, current obeys Kirchhoff's laws on lines, mass conserves on pipes, and material and energy balance across process units. The single most transferable insight of this chapter is that the GNN's message-passing step is a learned, data-corrected stand-in for a conservation law you already half-know from physics. This section walks the four domains, shows what makes each graph distinctive, names the benchmarks you will actually be measured against, and flags where a method that dominates one grid quietly fails on another.

Traffic networks: the benchmark that made spatiotemporal GNNs famous

What the task is: given loop-detector or probe speeds at hundreds of road sensors over the last hour, forecast speed or flow 15, 30, and 60 minutes ahead at every sensor. Why traffic became the field's proving ground is that two public datasets, METR-LA (207 loop detectors on Los Angeles highways) and PEMS-BAY (325 detectors in the Bay Area), released with the DCRNN paper of Li, Yu, Shahabi, and Liu (2018), gave everyone a clean, shared, spatiotemporal target. How the graph is built matters more here than almost anywhere: as Section 54.2 warned, Euclidean distance lies on a road network, so the standard adjacency uses a thresholded Gaussian kernel over driving distance along the road graph, and DCRNN treats propagation as a directed diffusion so congestion can travel upstream against traffic while vehicles travel downstream.

When traffic forecasting is hard is precisely at the events that matter: an accident is a sudden, sparse, local perturbation that spreads along on-ramps in minutes. A model that nails the smooth daily commute cycle can still miss every incident, which is why leakage-safe evaluation (a running thread of this book, see Chapter 5) insists you split by time, never shuffle across it, and report error stratified by regime rather than one averaged mean-absolute-error number that flatters the model on quiet nights.

Power and energy grids: physics you must not violate

Electrical grids raise the stakes because the underlying physics is exact and unforgiving. What the graph is: buses are nodes, transmission lines and transformers are edges, and the edge weight is a complex admittance from the network's \(Y\)-bus matrix rather than a distance kernel. Why this domain rewards GNNs is that the tasks (state estimation, load and renewable forecasting, topology identification, contingency screening) all obey the AC power-flow equations, which are local: the injection at a bus depends only on its own voltage and its neighbors' voltages through the admittances. That locality is a message-passing graph, so a GNN's inductive bias matches the physics almost exactly, and models built this way generalize across grid sizes far better than a plain multilayer network that ignores topology.

How practitioners exploit this is physics-informed training: penalize the network when its predicted bus injections violate the power-balance residual, blending a data loss with a physics loss the way Chapter 55 develops in general. Simulators such as pandapower and benchmark grids such as SimBench and the MATPOWER cases supply the labeled synthetic data that real utilities, guarding operational SCADA, rarely release. When to be careful: the same connectivity that carries load also carries attacks, so a GNN that estimates state can be fooled by a coordinated false-data-injection on a few well-chosen buses, the cyber-physical threat that Chapter 38 studies directly.

The right graph is the one physics already drew

Across all four grids, the biggest accuracy gains come not from a deeper network but from using the domain's own connectivity: the road graph, the \(Y\)-bus, the pipe network, the process flowsheet. A GNN on the correct physical graph is a spatial prior so strong that it routinely beats a much larger topology-blind model trained on the same data, because it never has to relearn that non-adjacent nodes do not directly interact. Conversely, feeding a GNN a wrong or invented graph is worse than using no graph at all, since message passing will diligently mix signals that physics keeps separate. Spend your effort on the adjacency; the layers are commodities.

Water distribution and the leak-localization benchmark

Water distribution networks (WDNs) are the domain where GNN fault localization (Section 54.4) meets a life-safety mission: find and isolate a leak before it drains a reservoir or a contaminant before it reaches taps. What the graph is: junctions, tanks, and reservoirs are nodes; pipes, pumps, and valves are directed, conductance-weighted edges taken straight from the utility's hydraulic model. Why it is genuinely hard is chronic under-instrumentation: a network with thousands of pipes may carry only a few dozen pressure and flow sensors, so most nodes are never observed and the GNN must propagate evidence from sparse sensors across the topology to a hidden leak location. The BattLeDIM competition (Battle of the Leakage Detection and Isolation Methods, 2020) and its L-Town benchmark network made this a shared, reproducible target, pairing a realistic pipe topology with a year of simulated pressure and demand.

A city that localized leaks it could not see

An operator working the L-Town benchmark modeled the district as a graph with one node per junction and edges from the pipe inventory, then trained a spatiotemporal GNN to reconstruct expected pressure at every node from the handful of metered ones. When a leak opened, the reconstruction error did not spike at the sensors (they were far away and barely moved); it spiked, after message passing carried the pressure deficit hop by hop, at the unmonitored junction nearest the leak. Because the graph was directed along flow, the anomaly propagated coherently downstream from a single source rather than smearing across the map, and the team could dispatch a crew to a short candidate pipe segment instead of excavating a neighborhood. The pattern is exactly the condition-monitoring philosophy of Chapter 37: the sensors detect, but the graph localizes.

Industrial process grids and what transfers between domains

Industrial plants (refineries, chemical processes, HVAC in large buildings) are the fourth grid and the messiest. What the graph is: process units and measurement points are nodes; pipes, ducts, shafts, and material streams are edges, read from a piping-and-instrumentation diagram (P&ID) or a process flowsheet. Why they resist a purely spatial graph is that two sensors bolted a meter apart on adjacent skids may belong to unconnected process lines, while a controller output and a downstream temperature far across the plant are tightly coupled through the process. How tasks are framed mirrors the other grids: multivariate forecasting for control, virtual sensing of unmeasured quantities, and anomaly localization for early fault detection and prognostics (Chapter 36).

The code below builds the one object every grid shares, the normalized graph shift operator that a message-passing layer applies at each step, from nothing more than an edge list. Swap the edges for road segments, transmission lines, pipes, or process streams and the same operator serves all four domains; only the conservation law you later impose changes.

import numpy as np

# A tiny directed "grid": 5 instrumented junctions, edges from an inventory.
# (i -> j) means flow can carry influence from node i to node j.
edges = [(0, 1), (1, 2), (1, 3), (3, 4), (2, 4)]
N = 5

A = np.zeros((N, N))
for i, j in edges:
    A[i, j] = 1.0            # directed edge weight (use admittance/conductance in practice)

A = A + np.eye(N)           # self-loops: a node keeps its own state (GCN convention)

# Symmetric normalization D^-1/2 (A) D^-1/2 on the undirected support,
# the standard graph shift operator message passing applies each layer.
A_sym = np.maximum(A, A.T)  # undirected support for normalization
deg = A_sym.sum(1)
d_inv_sqrt = 1.0 / np.sqrt(deg)
S = d_inv_sqrt[:, None] * A_sym * d_inv_sqrt[None, :]

print("degrees            :", deg.astype(int))
print("shift op row sums  :", S.sum(1).round(2))   # ~1 where normalized
print("2-hop reach (S^2>0):", (np.linalg.matrix_power(S, 2) > 0).sum(1))
Building the normalized graph shift operator \(S = D^{-1/2} A D^{-1/2}\) from a bare edge list, the single primitive shared by traffic, power, water, and process GNNs. The reported two-hop reach shows how far a signal travels after two message-passing layers, the quantity that decides whether a distant fault is even visible to a given node.

Right tool: domain graphs and spatiotemporal models off the shelf

The hand-rolled operator above is worth writing once to see \(S\) clearly, but you would not maintain it. PyTorch Geometric Temporal ships the traffic benchmarks (METRLADatasetLoader, PemsBayDatasetLoader) with their prebuilt adjacencies and ready spatiotemporal layers (DCRNN, A3T-GCN, MTGNN), turning roughly 200 lines of dataset download, driving-distance graph construction, normalization, and windowing into about five. For power grids, pandapower exports the \(Y\)-bus and topology directly; for water, an EPANET model read through WNTR gives you the pipe graph. The library owns the plumbing so you spend your budget on the adjacency and the physics loss, which is where the accuracy actually lives.

Where the state of the art sits

Traffic remains the most saturated benchmark: DCRNN (Li et al., 2018), Graph WaveNet (Wu et al., 2019), and their linear-time successor BigST (Han et al., 2024) trade blows on METR-LA and PEMS-BAY, and the frontier has shifted from raw error to scaling to grids of tens of thousands of nodes (Section 54.5). Power-grid GNNs are the fastest-growing frontier, with physics-informed and topology-aware models for state estimation and power flow that generalize across grid configurations, plus a hard security literature on false-data injection (Chapter 38). Water leak localization crystallized around BattLeDIM and L-Town, and industrial process monitoring is trending toward foundation-style models that transfer one pretrained graph encoder across plants. The unifying open problem is cross-domain transfer: whether a single conservation-aware spatiotemporal backbone can be pretrained once and fine-tuned on any of the four grids, the direction Chapter 53 pushes for world models generally.

A closing caution that ties the four together: the metric must match the mission. Traffic and load forecasting are scored on horizon-wise error, but water and process anomaly localization are scored on how close the predicted fault location is to the true one and how few false digs it triggers, a spatial accuracy no averaged error captures. Whichever grid you work, pair the forecast with calibrated uncertainty (Chapter 18) so an operator learns when to trust the model and when a low-confidence alert deserves a human eye before a crew rolls.

Exercise: one backbone, four grids

Take the five-node shift operator from the code snippet as a stand-in grid. (a) Interpret the same edge list as a road network, a power grid, a water network, and a process line, and for each state what the node feature and the forecast target would be. (b) For the water and power cases, write the one conservation residual you would add as a physics loss (mass balance at a junction; power balance at a bus) and explain how it constrains the two-hop-reachable nodes. (c) Argue in three sentences why leak localization needs a directed graph while highway speed forecasting can tolerate a symmetric one. Which single design change would most improve a topology-blind baseline on all four grids at once?

Self-check

  1. Why does driving distance, not straight-line distance, define the adjacency for METR-LA and PEMS-BAY, and what would break if you used Euclidean distance?
  2. What makes the AC power-flow structure a natural fit for message passing, and how does that fit help a power-grid GNN generalize across grid sizes?
  3. In a sparsely instrumented water network, the pressure sensors barely move when a distant leak opens yet the GNN still localizes it. By what mechanism does the anomaly reach the right hidden node?

What's Next

In Section 54.7, we ask the question every operator asks after a GNN flags a fault: why here, and can I trust it? Interpretability for graph models means attributing a prediction to specific edges and nodes, reading the learned adjacency as a hypothesis about hidden couplings, and separating a real physical pathway from a spurious correlation the network memorized. The four grids of this section give interpretability its teeth, because on infrastructure an unexplained alert is an alert nobody acts on.