Linear Algebra

Graph Basics: Adjacency, Degree, and Laplacian

Adjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

status: reviewimportance: criticaldifficulty 3/5math: undergraduateread: 20mlive demo

Concept Structure

Graph Basics: Adjacency, Degree, and Laplacian

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

2prerequisites
2next concepts
3related links

Learner Contract

What this page should let you do.

You are here becauseAdjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

This Linear Algebra concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

By the end4/4 sections ready | runnable code expected | live demo

Explain the mechanism, trace the main notation, and test one prediction in the live demo.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Test the linkManipulate one control and predict the visible change.Then continue to Node Embeddings: DeepWalk and node2vec (review)

Claim/source review status

Substantive review recorded

1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.
Claims1/1 reviewed
Sources4 cited
Codeattached
Demolive
Reviewed2026-07-02
Updatedpage 2026-07-02

Learning item flow

4/4 sections readyAsk about thisResearch room
ConceptGraph Basics: Adjacency, Degree, and LaplacianLinear Algebra
4 sources attachedLocal snapshot ready
concept:linear-algebra/graph-basics-adjacency-laplacian
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

A graph becomes useful to machine learning when we can compute with it.

The picture says which nodes are connected. The matrices say the same thing in a form a model can multiply, normalize, smooth, or pass messages through.

The adjacency matrix AA answers: who is connected to whom?

The degree matrix DD answers: how many neighbors does each node have?

The graph Laplacian L=DAL=D-A answers a subtler question: if each node carries a value, how much does that value jump across edges?

Think of a signal xx placed on the graph: one number xix_i per node. If neighboring nodes have similar values, the graph sees the signal as smooth. If an edge connects very different values, that edge contributes a large penalty.

For graph neural networks, this is the first bridge from topology to computation. The adjacency matrix says where information can move. The degree matrix says how much neighbor mass surrounds a node. The Laplacian says which signals respect the graph's local structure and which ones fight it.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Let G=(V,E)G=(V,E) be an undirected unweighted graph with nodes

V={1,,n}.V=\{1,\ldots,n\}.

The adjacency matrix A{0,1}n×nA\in\{0,1\}^{n\times n} is

Aij={1,if {i,j}E,0,otherwise.A_{ij}= \begin{cases} 1, & \text{if }\{i,j\}\in E,\\ 0, & \text{otherwise.} \end{cases}

Because the graph is undirected, AA is symmetric.

The degree of node ii is

di=j=1nAij.d_i=\sum_{j=1}^{n}A_{ij}.

The degree matrix is diagonal:

Dii=di,Dij=0 for ij.D_{ii}=d_i,\qquad D_{ij}=0\text{ for }i\ne j.

The combinatorial graph Laplacian is

L=DA.L=D-A.

Now put a scalar signal on the graph:

x=(x1,,xn).x=(x_1,\ldots,x_n)^\top.

The matrix-vector product LxLx has one row per node:

(Lx)i=dixij:{i,j}Exj.(Lx)_i = d_i x_i-\sum_{j:\{i,j\}\in E}x_j.

So (Lx)i(Lx)_i compares node ii to its neighbors. If xix_i agrees with nearby values, the row is small. If xix_i disagrees sharply, the row is large.

The global smoothness energy is the quadratic form

xLx.x^\top Lx.

For an undirected unweighted graph,

xLx={i,j}E(xixj)2.x^\top Lx = \sum_{\{i,j\}\in E}(x_i-x_j)^2.

This identity is the key mechanism. The Laplacian turns local edge disagreements into a single scalar. Smooth graph signals have low energy. Signals that alternate across many edges have high energy.

The same matrices later support several ML operations:

  • graph neural networks use adjacency-like neighborhoods for message passing;
  • spectral clustering studies eigenvectors of Laplacian matrices;
  • graph regularization penalizes functions that vary too much across nearby nodes.

Those later topics add normalization, weights, directed edges, and learned features. This page keeps the first invariant visible: graph structure becomes matrix arithmetic.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import numpy as np

edges = [(0,1), (0,2), (1,3), (2,3), (2,4), (3,4)]
n = 5

A = np.zeros((n, n), dtype=int)
for i, j in edges:
    A[i, j] = A[j, i] = 1

D = np.diag(A.sum(axis=1))
L = D - A

signals = {
    "smooth": np.array([1.0, 0.8, 0.4, 0.3, 0.0]),
    "bridge_jump": np.array([1.0, 1.0, 1.0, -1.0, -1.0]),
    "alternating": np.array([1.0, -1.0, -1.0, 1.0, 1.0]),
}

for name, x in signals.items():
    quadratic = float(x @ L @ x)
    edge_sum = sum((x[i] - x[j]) ** 2 for i, j in edges)
    print(name, "x^T L x =", quadratic, "edge sum =", edge_sum)

The code computes the same quantity two ways. The matrix form xLxx^\top Lx and the edge-sum form agree because the Laplacian is storing local graph disagreements.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

Pick which signal should have the largest Laplacian energy before revealing the matrix and edge ledger. The graph, matrices, and edge contributions are the same object viewed three ways.

Live Concept Demo

Explore Graph Basics: Adjacency, Degree, and Laplacian

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what Graph Basics: Adjacency, Degree, and Laplacian should make visible before reading the result.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

Adjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

Prediction open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Graph Basics: Adjacency, Degree, and Laplacian should make visible.

Visual Inquiry

Make the image answer a mathematical question

Adjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Graph Basics: Adjacency, Degree, and Laplacian easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

course-notes · 2010MIT 6.042J Mathematics for Computer Science: Graph TheoryLehman, Leighton, and Meyer

Grounds vertices, edges, adjacency, and degree as graph vocabulary.

Open source
course-notes · 2019Stanford CS224W: Spectral ClusteringStanford CS224W

Supports adjacency matrix, degree matrix, graph Laplacian, and spectral graph context.

Open source
article · 2007A Tutorial on Spectral ClusteringUlrike von Luxburg

Reference tutorial for graph Laplacians, quadratic forms, and smoothness/clustering intuition.

Open source
article · 2021A Gentle Introduction to Graph Neural NetworksSanchez-Lengeling et al.

High-quality visual bridge from graph structure to node features and later message passing.

Open source

Claim Review

Adjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources4 references

mit-6042-graph-theory, cs224w-spectral-clustering, von-luxburg-2007-spectral-clustering, distill-2021-gnn-intro

Local checks4 local checks

Use equations, runnable code, and demos to check whether the source support is operational.

Substantively reviewedFor an undirected unweighted graph with adjacency matrix A, degree matrix D, and combinatorial Laplacian L=D-A, the quadratic form x^T L x equals the sum of squared differences (x_i-x_j)^2 over edges, so it measures how unsmooth a node signal is across adjacent nodes.Claim metadata: source checked

The sources support the page's finite undirected graph matrices, degree counts, combinatorial Laplacian, row-wise Lx calculation, and edge-sum interpretation of x^T L x.

Sources: MIT 6.042J Mathematics for Computer Science: Graph Theory, Stanford CS224W: Spectral Clustering, A Tutorial on Spectral Clustering, A Gentle Introduction to Graph Neural NetworksUnweighted undirected teaching graph only; excludes normalized Laplacians, directed graph Laplacians, weighted edges, eigenvector clustering algorithms, graph Fourier analysis, and full GNN message passing.A bounded review summary is present; still check caveats and exact reference scope.

Checked MIT graph notes for graph, adjacency, and degree vocabulary; checked Stanford CS224W spectral-clustering notes and von Luxburg's tutorial for adjacency/degree/Laplacian definitions and the Laplacian quadratic-form smoothness identity; used Distill's GNN intro only as a visual bridge to node features and later message passing. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.

Reviewer: codex-local-source-review; reviewed 2026-07-02

Practice Loop

Try the idea before it explains itself

Adjacency, degree, and Laplacian matrices turn a graph into linear algebra: rows name neighborhoods, and x^T L x measures how sharply a signal changes across edges.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Graph Basics: Adjacency, Degree, and Laplacian.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded research drawerClose
ConceptGraph Basics: Adjacency, Degree, and LaplacianLinear Algebra

Research Room

Attach the question to a claim, equation, code, or demo

Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptLinear Algebra

Graph Basics: Adjacency, Degree, and Laplacian

Attached question

What is the smallest example that makes Graph Basics: Adjacency, Degree, and Laplacian click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays in this browser, attached to the selected learning item.

No local draft saved.
Evidence to inspect
  • References to inspect: attached references on this page.
  • Definition, prerequisite, and contrast concept links
  • The equation or runnable code that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Graph Basics: Adjacency, Degree, and Laplacian Selected item key: recorded for copy. Context: Linear Algebra Page anchor: recorded for copy. Open question: What is the smallest example that makes Graph Basics: Adjacency, Degree, and Laplacian click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

View it in context
concept/concept-notebook/linear-algebra/graph-basics-adjacency-laplacian concept:linear-algebra/graph-basics-adjacency-laplacian