Graph

A graph modality represents entities and relationships as nodes and edges. Graphs appear in molecules, protein contact maps, knowledge graphs, citation networks, routes, tool-call traces, and interaction networks.

A graph is:

with node features and optional edge features:

The adjacency matrix records connectivity:

Key Ideas

  • Node order is usually arbitrary, so permutation invariance or equivariance matters.
  • Edge construction is part of the data representation, not a neutral preprocessing step.
  • Graphs can be directed, undirected, typed, weighted, dynamic, or geometric.
  • Dense pairwise relationships may be better treated as attention or set modeling; sparse typed relationships often suit graph models.

Graph Construction Boundary

A graph is often derived from another object:

where contains rules such as distance cutoffs, k-nearest neighbors, bond definitions, contact thresholds, relation extraction, or temporal adjacency. Changing changes the task input.

Representation Contract

A graph input should state:

where is the node set, is the edge set, are node features, are edge features, and stores masks for valid nodes, edges, or subgraphs.

DomainNodeEdgeSplit Risk
moleculeatombond, distance, contactsame scaffold or standardized molecule across splits
proteinresidue, atom, domaincontact, sequence adjacency, spatial neighborhomolog or template leakage
protein-ligand complexatom, residue, ligand fragmentbond, contact, distance, interactionsame protein family or ligand scaffold
knowledge graphentityrelation tripleentity leakage across train/test edges
agent tracestate, message, tool calltransition, dependency, citationsame task template or hidden state reuse

Permutation Contract

If node order is arbitrary, a graph-level output should be invariant:

where is a permutation matrix. Node-level outputs should be equivariant:

This distinction should be stated before choosing pooling, attention, or message passing.

Output Levels

Graph tasks differ by prediction unit:

The pooling/readout, loss, metric, and split should match the output level. A graph-level split does not necessarily prevent node or entity leakage.

Edge Semantics

Edges can mean very different things:

Edge TypeMeaningRisk
observed bond/relationpart of the raw objectmay miss alternative chemical states or relation uncertainty
distance cutoffgeometric proximitycutoff is a modeling hyperparameter
k-nearest neighborfixed local densitycan connect through unavailable deployment context
learned edgeinferred during model executionmust not use test labels or future information
temporal edgeevent orderfuture edges can leak labels

For molecular and protein graphs, edge construction is often as important as the GNN architecture.

Leakage Risks

  • The same entity appears in train and test through different graph neighborhoods.
  • Edges are constructed using labels or future information.
  • Global normalization or message passing crosses examples during batching.
  • Random row splits leak near-duplicate molecular graphs, protein contact maps, or knowledge-graph entities.

Practical Checks

  • What are nodes and edges?
  • Are edges observed, constructed, thresholded, or learned?
  • Are node and edge features available at deployment?
  • Does the split prevent near-duplicate graphs or entity leakage?
  • Is the task node-level, edge-level, graph-level, or subgraph-level?
  • Does batching preserve graph isolation?
  • Are edge construction rules fixed before evaluation?
  • Is the model expected to be permutation invariant or equivariant?
  • Does the edge definition preserve the task’s physical, biological, or relational meaning?
  • Are graph-level metrics hiding node-level or edge-level failure modes?