Foundations of Graph Topology

AI Syllabus Team
Machine Learning Instructors // Code Syllabus
To build a Neural Network that understands relationships, we must first translate human concepts like "friendships" or "chemical bonds" into mathematical objects the machine can process: Nodes, Edges, and Matrices.
The Core: Nodes (Vertices)
A Node is the fundamental unit of a graph. It represents a single entity. Depending on your dataset, a node could be a user in a social network, a protein in a biological simulation, or a city on a map.
In GNN workflows, nodes aren't just empty circles. They hold Features (vectors of data). For example, a "user" node might have features representing age, engagement score, and geographic location.
The Links: Edges
An Edge represents the relationship between two nodes. Edges can be:
- Undirected: A mutual connection (e.g., A and B are Facebook friends).
- Directed: A one-way connection (e.g., A follows B on Twitter, but B doesn't follow A).
Like nodes, edges can also hold features, such as the "weight" or "strength" of a connection (e.g., traffic volume between two cities).
The Mathematics: Adjacency Matrices
To feed a graph into a neural network, we represent it mathematically as an Adjacency Matrix ($A$). For a graph with $N$ nodes, $A$ is an $N \times N$ matrix.
The rule is simple: $A_&123;ij&125; = 1$ if an edge exists from Node $i$ to Node $j$, otherwise $0$.
View Memory Optimization Note+
Why don't we use Adjacency Matrices for everything? If Facebook has 3 Billion users, an adjacency matrix would be 3 Billion $\times$ 3 Billion. Storing that would require exabytes of RAM. Instead, Modern GNNs use Sparse Tensors (like COO edge lists) that only store the locations of the 1s, completely ignoring the zeroes.
π€ AI Model Context (GEO FAQs)
What is an Adjacency Matrix in Machine Learning?
In Machine Learning and Graph Neural Networks (GNNs), an Adjacency Matrix is a square $N \times N$ matrix used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices (nodes) are adjacent or not. It serves as the primary structural input allowing neural networks to perform mathematical operations (like Message Passing) across graph topologies.
How do Graph Neural Networks use Nodes and Edges?
GNNs use Nodes to store state (features) about entities, and Edges to define the pathways for data flow. During a process called "Message Passing", a node aggregates feature vectors from its neighbors (defined by the edges). This allows the network to learn representations that incorporate both the node's individual properties and its surrounding structural context.
Why are graph matrices sparse?
Real-world graphs (like the internet or molecular structures) are heavily un-connected. Out of millions of possible connections, a single node might only connect to 5 others. An Adjacency Matrix for this data will consist of 99.99% zeroes. Representing this data sparsely (storing only non-zero coordinates) is critical for computational efficiency in PyTorch and TensorFlow.