Chapter 6

Graph Neural Networks: Relationship Data

When your data has connections and relationships, GNNs are your specialized tool.

6 min read

When Data Has Relationships

Most AI architectures assume data comes as sequences (text), grids (images), or independent rows (tabular). But much real-world data is fundamentally about relationships: social networks, molecular structures, transportation systems, recommendation engines.

The Graph Perspective

A graph has nodes (entities) and edges (relationships). In a social network, people are nodes and friendships are edges. In a molecule, atoms are nodes and bonds are edges. GNNs are designed to learn from this structure.

How GNNs Work

GNNs learn by message passingβ€”each node aggregates information from its neighbors, then updates its own representation. After several rounds, each node contains information about its extended neighborhood.

Message Passing Example

Round 1: Each person learns about their direct friends
Round 2: Each person learns about friends-of-friends
Round 3: Each person knows their extended social circle

After enough rounds, the network understands community structure, influence patterns, and connection strengths.

GNN Applications

ApplicationNodesEdgesPrediction
Social networksPeopleFriendshipsNew connections, communities
RecommendationsUsers + ItemsInteractionsWhat to recommend
Drug discoveryAtomsBondsMolecular properties
Fraud detectionAccountsTransactionsSuspicious patterns
Traffic predictionIntersectionsRoadsCongestion, routes
Knowledge graphsEntitiesRelationsMissing facts
Real-World Impact

Pinterest: Uses GNNs for visual recommendations
Uber: Traffic prediction with road networks
Drug companies: Molecular property prediction
Financial institutions: Fraud ring detection

When to Consider GNNs

The Decision Question

Ask yourself: Is the relationship between data points as important as the data points themselves?

If your problem involves networks, connections, or graph-structured data, GNNs are likely your best choice. If relationships don't matter, simpler architectures will work.

Note

GNNs are more specialized than transformers or CNNs. You won't encounter them as frequently, but when your data is naturally graph-structured, they significantly outperform other architectures trying to work around the structure.

AI Assistant
00:00