3.5.3Graphs

Incidence matrix

1,780 words8 min readdifficulty · medium

WHAT is an incidence matrix?


HOW to build it from scratch (derivation by construction)

We don't memorise a formula — we generate the matrix.

  1. List every vertex → these label the rows.
  2. List every edge as the pair of vertices it joins → these label the columns.
  3. For each column (edge), put a mark in the rows of its two endpoints.
Figure — Incidence matrix

Worked Example 1 — Undirected

Graph: vertices {1,2,3}\{1,2,3\}, edges e1=(1,2), e2=(2,3), e3=(1,3)e_1=(1,2),\ e_2=(2,3),\ e_3=(1,3) (a triangle).

e1e_1 e2e_2 e3e_3
11 1 0 1
22 1 1 0
33 0 1 1
  • Why row 1 = 1 0 1? Vertex 1 is in edges e1e_1 and e3e_3 only. → Why this step? We scan each edge and ask "is vertex 1 an endpoint?"
  • Check degrees: each row sums to 2 → every vertex has degree 2. Correct for a triangle. ✔

Worked Example 2 — Directed

Edges: e1:12e_1: 1\to 2, e2:23e_2: 2\to 3, e3:13e_3: 1\to 3.

e1e_1 e2e_2 e3e_3
11 1-1 0 1-1
22 +1+1 1-1 0
33 0 +1+1 +1+1
  • Why B1,1=1B_{1,1}=-1? Edge e1e_1 leaves vertex 1 (vertex 1 is the tail). → Why this step? Convention: tail negative, head positive.
  • Check: every column sums to 0. ✔

Worked Example 3 — Self-loop

Edge e1e_1 is a loop at vertex 1 (an edge 111\to1).

e1e_1
11 2
  • Why 2 (in undirected) instead of 1? A loop touches vertex 1 with both its endpoints, so it contributes 2 to the degree. → Why this step? Keeps the row-sum = degree rule consistent (loops add 2 to degree).




Recall Feynman: explain to a 12-year-old

Imagine a list of friendships. Down the side you write everyone's name. Across the top you write each friendship like "Friendship #1". You put a tick in the box if that person is part of that friendship. Since a friendship always joins exactly two people, every column gets exactly two ticks. Count the ticks in your row and you know how many friends you have. That tick-grid is the incidence matrix — a way to write friendships in pure numbers so a computer can read them.


Flashcards

What are the dimensions of an incidence matrix for a graph with n vertices and m edges?
n×mn \times m (rows = vertices, columns = edges).
In an undirected incidence matrix, how many non-zero entries does each column have?
Exactly two (the two endpoints), or a single "2" for a self-loop.
What does the sum of row ii equal (undirected)?
The degree of vertex viv_i.
In a directed incidence matrix, what values mark the tail and head of an edge?
Tail = 1-1, Head = +1+1.
Why does every column of a directed incidence matrix sum to 0?
Each edge has one tail (1-1) and one head (+1+1); they cancel.
How does a self-loop appear in an undirected incidence matrix?
As a single entry of 22 in that vertex's row (loop adds 2 to degree).
How does the incidence matrix prove the Handshake Lemma?
Total 1's counted by columns = 2m2m; counted by rows = deg(vi)\sum\deg(v_i); so deg=2m\sum\deg = 2m.
What is the graph Laplacian in terms of incidence matrix B (directed)?
L=BBTL = B B^T.

Connections

  • Adjacency matrix — alternative n×nn\times n representation (vertex-to-vertex).
  • Graph Laplacian — built as L=BBTL=BB^T from the oriented incidence matrix.
  • Degree of a vertex — equals a row sum here.
  • Handshake Lemma — falls out of counting incidence marks.
  • Sparse graph representations — incidence lists/CSR for big graphs.

Concept Map

encoded as

dimensions

rows

columns

undirected rule

directed rule

row sum gives

each column has

column sum

leads to

contrast with

Graph vertices and edges

Incidence matrix B

n x m size

Vertices

Edges

1 if endpoint else 0

-1 tail +1 head

Degree of vertex

Exactly two 1s

Sum equals 0

Graph Laplacian L equals BB transpose

Adjacency matrix n x n

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, graph ek picture hai — dots (vertices) aur unko jodne wali lines (edges). Computer ko ye picture samajhane ke liye usko numbers me convert karna padta hai. Incidence matrix bilkul ek attendance register jaisa hai: rows me vertices likho (students), columns me edges likho (classes). Agar koi vertex us edge ka endpoint hai, to wahan mark laga do. Isliye matrix ka size hota hai n×mn \times m — n vertices, m edges. Yaad rakho, ye adjacency matrix ki tarah square nahi hota, kyunki yahan hum vertices ko edges se relate kar rahe hain, vertices ko vertices se nahi.

Undirected graph me har column me bas do 1 hote hain — kyunki har edge ke sirf do endpoints hote hain. Agar tum kisi row ka sum karo, to wo us vertex ka degree ban jaata hai (kitni edges us pe lagi hain). Isi se Handshake Lemma aa jaata hai: total marks ko columns se gino to 2m2m, aur rows se gino to deg\sum \deg — dono barabar, matlab deg=2m\sum\deg = 2m.

Directed graph me thoda twist hai: 0/1 ki jagah hum 1-1 (jahan se edge nikalti hai, tail) aur +1+1 (jahan edge aati hai, head) lagate hain. Isse har column ka sum 0 ho jaata hai, kyunki ek tail aur ek head cancel kar dete hain. Yahi cheez aage graph Laplacian L=BBTL = BB^T banane me kaam aati hai, jo machine learning aur network analysis me bahut use hota hai.

Common galti: log ise square (n×nn\times n) samajh lete hain ya column me 3 marks daal dete hain. Bas yaad rakho — "ek edge ke do hi endpoints hote hain", isliye column me hamesha do hi marks (ya self-loop ke liye ek "2"). Yeh chhota sa rule clear ho gaya to incidence matrix ka pura concept clear ho jaata hai.

Go deeper — visual, from zero

Test yourself — Graphs