This Linear Algebra concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Linear Algebra
Graph Theory Basics for GNNs and Graphical Models
Graphs are nodes plus edges; adjacency, degree, paths, cycles, DAGs, topological orders, and Laplacians are the shared vocabulary behind GNNs and graphical models.
Concept Structure
Graph Theory Basics for GNNs and Graphical Models
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
No hard prerequisite is listed; start from the intuition and fill gaps only when the notation demands it.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
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.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
A graph is a way to say which things are allowed to talk to which other things.
The things are nodes or vertices. The connections are edges. Once you have those two ingredients, the same object can support several kinds of machine-learning reasoning:
- In graph neural networks, neighbors exchange messages.
- In spectral methods, the graph becomes matrices such as adjacency, degree, and Laplacian matrices.
- In Bayesian networks, a directed acyclic graph gives parent sets for local conditional probabilities.
That is why graph basics belong in the mathematical backbone. They are not decoration around the model. They decide which variables are local, which paths exist, which computations can be parallelized, and which factorizations are legal.
The first mental split is direction.
An undirected edge says two nodes are adjacent:
A directed edge says information or dependence points one way:
Directed graphs can have directed cycles, such as
A directed acyclic graph, or DAG, has no directed cycle. DAGs are special because they can be ordered so every edge points forward. That order is called a topological order.
For probabilistic models, a DAG does one more job: it tells us the parents of each variable. If node has parents , a Bayesian network uses the scaffold
The graph does not magically choose the numbers in those conditional distributions. It chooses the local questions each conditional table, density, or neural conditional model must answer.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a graph. The node set is
For an undirected graph, each edge is an unordered pair . For a directed graph, each edge is an ordered pair , often drawn as .
The adjacency matrix records edges:
For an undirected graph, is symmetric. For a directed graph, need not be symmetric.
The out-degree and in-degree of node are
For an undirected graph, the degree is usually just
The degree matrix is diagonal:
The combinatorial graph Laplacian is
This matrix is one bridge from graph structure to linear algebra. If is a value placed on node , then a common smoothness quantity is
for the undirected version of the graph. The expression is small when adjacent nodes have similar values.
Now switch back to directed graphs. A directed path is a sequence
where every arrow is present. A directed cycle is a directed path that returns to a node already on the path.
A directed graph is a DAG if it has no directed cycle.
A topological order is an ordering of nodes such that every edge points from an earlier node to a later node. A finite directed graph has a topological order exactly when it is acyclic.
For a Bayesian-network DAG, the parent set of node is
The graph supplies the factorization pattern
So the same graph object has two useful readings:
- matrix reading: adjacency, degree, Laplacian, neighborhoods;
- probabilistic reading: parent sets, topological order, local conditionals.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
nodes = ["Rain", "Sprinkler", "Wet", "Traffic", "Late"]
edges = [("Rain","Sprinkler"), ("Rain","Wet"), ("Rain","Traffic"),
("Sprinkler","Wet"), ("Wet","Late"), ("Traffic","Late")]
idx = {node: i for i, node in enumerate(nodes)}
A = [[0] * len(nodes) for _ in nodes]
for u, v in edges:
A[idx[u]][idx[v]] = 1
parents = {v: [u for u, w in edges if w == v] for v in nodes}
children = {u: [v for w, v in edges if w == u] for u in nodes}
undirected_degree = [
sum(A[i][j] or A[j][i] for j in range(len(nodes))) for i in range(len(nodes))
]
def creates_cycle(candidate):
graph = edges + [candidate]
visiting, done = set(), set()
def dfs(u):
if u in visiting: return True
if u in done: return False
visiting.add(u)
for a, b in graph:
if a == u and dfs(b): return True
visiting.remove(u); done.add(u)
return False
return any(dfs(node) for node in nodes)
print("parents:", parents)
print("children:", children)
print("undirected degree:", dict(zip(nodes, undirected_degree)))
print("Late -> Rain creates cycle?", creates_cycle(("Late", "Rain")))
The code has two views of the same graph. A and the degree list are the matrix view. parents and creates_cycle are the DAG view used by graphical models.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
The DAG Factorization Lab below hides the cycle result, topological order, and factorization ledger until you commit.
Choose one candidate edge. Predict whether adding it creates a directed cycle or keeps the graph acyclic. Then reveal:
- the adjacency and parent-set ledger;
- the directed path that proves a cycle, if one appears;
- a valid topological order when the graph is still a DAG;
- the Bayesian-network factorization scaffold for the current graph.
Live Concept Demo
Explore Graph Theory Basics for GNNs and Graphical Models
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Graph Theory Basics for GNNs and Graphical Models 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
Graphs are nodes plus edges; adjacency, degree, paths, cycles, DAGs, topological orders, and Laplacians are the shared vocabulary behind GNNs and graphical models.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Graph Theory Basics for GNNs and Graphical Models should make visible.
Visual Inquiry
Make the image answer a mathematical question
Graphs are nodes plus edges; adjacency, degree, paths, cycles, DAGs, topological orders, and Laplacians are the shared vocabulary behind GNNs and graphical models.
Which visible object should carry the first intuition?
Pick the cue that should make Graph Theory Basics for GNNs and Graphical Models easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Grounds graph vocabulary including vertices, edges, adjacency, degree, paths, directed graphs, and connectivity.
Open sourceSupports DAG vocabulary, the no-directed-cycle condition, and topological-order scheduling intuition.
Open sourceCurriculum anchor for graphs as ML objects represented by nodes, edges, neighborhoods, and adjacency structures.
Open sourceSupports the degree matrix, adjacency matrix, and graph Laplacian as matrix views of graph structure.
Open sourceSupports directed acyclic graphs as Bayesian-network structure and the product of local conditionals over parent sets.
Open sourceClaim Review
Graphs are nodes plus edges; adjacency, degree, paths, cycles, DAGs, topological orders, and Laplacians are the shared vocabulary behind GNNs and graphical models.
Claims without a substantive review badge still need exact source-support review.
mit-6042-graph-theory, mit-6042-dags, cs224w-graph-representation, cs224w-spectral-clustering, cs228-bayesian-networks
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support the page's distinction between graph structure, matrix representation, path/cycle reasoning, DAG validity, topological orders, and using parents in a DAG to write a Bayesian-network product.
Sources: MIT 6.042J Mathematics for Computer Science: Graph Theory, MIT 6.042J Mathematics for Computer Science: Directed Acyclic Graphs and Scheduling, Stanford CS224W: Machine Learning with Graphs, Stanford CS224W: Spectral Clustering, Stanford CS228 Notes: Bayesian NetworksFinite five-node teaching graph only; excludes spectral graph theory beyond the first Laplacian identity, graph isomorphism, random graphs, advanced GNN message passing, and full Bayesian-network inference.A bounded review summary is present; still check caveats and exact reference scope.Checked MIT graph notes for vertices, edges, adjacency, degree, paths, directed graph vocabulary, and DAG/topological-order intuition; checked CS224W context for graph ML representations and Laplacian matrices; checked CS228 for Bayesian-network DAGs and parent-set factorization. GPT Pro publication critique remains pending.
Reviewer: codex-local-source-review; reviewed 2026-07-02Source support candidates
course-notes 2010MIT 6.042J Mathematics for Computer Science: Graph TheoryGrounds graph vocabulary including vertices, edges, adjacency, degree, paths, directed graphs, and connectivity.
course-notes 2010MIT 6.042J Mathematics for Computer Science: Directed Acyclic Graphs and SchedulingSupports DAG vocabulary, the no-directed-cycle condition, and topological-order scheduling intuition.
course-notes 2026Stanford CS224W: Machine Learning with GraphsCurriculum anchor for graphs as ML objects represented by nodes, edges, neighborhoods, and adjacency structures.
course-notes 2019Stanford CS224W: Spectral ClusteringSupports the degree matrix, adjacency matrix, and graph Laplacian as matrix views of graph structure.
Practice Loop
Try the idea before it explains itself
Graphs are nodes plus edges; adjacency, degree, paths, cycles, DAGs, topological orders, and Laplacians are the shared vocabulary behind GNNs and graphical models.
Before touching the demo, predict one visible change that should happen in Graph Theory Basics for GNNs and Graphical Models.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
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.Open the draft below to save one note and next action in this browser.
Graph Theory Basics for GNNs and Graphical Models
What is the smallest example that makes Graph Theory Basics for GNNs and Graphical Models click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- 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
- 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
I am working in Continuous Function's research reading room. Object: concept - Graph Theory Basics for GNNs and Graphical Models Selected item key: recorded for copy. Context: Linear Algebra Page anchor: recorded for copy. Open question: What is the smallest example that makes Graph Theory Basics for GNNs and Graphical Models 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.
concept/concept-notebook/linear-algebra/graph-theory-basics
concept:linear-algebra/graph-theory-basics