Matrix Representation of Graphs
Core Titles
Key headlines and terms for quick recall- Adjacency matrix (size , if edge)
- Incidence matrix ()
- Circuit matrix
- Cut-set matrix
- Path matrix
- counts walks of length from to
Basic Idea
What it is, why it matters, how it worksWhy represent a graph as a matrix?
Matrices let us apply linear algebra to graphs — count walks, find connected components, study spectra, run algorithms.
Adjacency matrix
For a graph on vertices, is the matrix where For undirected graphs, is symmetric. For weighted graphs, store the weight instead of 1.
Key fact. counts the number of walks of length from to .
Incidence matrix
Rows = vertices, columns = edges. For undirected graph: if is incident to edge , else 0. For digraph: for tail, for head.
Circuit (cycle) matrix
Rows = fundamental circuits, columns = edges. Entry is 1 if the edge is in the circuit. Useful in network analysis.
Cut-set matrix
Rows = fundamental cut-sets, columns = edges. Entry 1 if the edge crosses the cut.
Path matrix
if there is a path from to (the transitive closure of ). Computed by repeatedly OR-ing or by Warshall's algorithm.
Why this matters in Data Science
Graph neural networks operate on adjacency matrices. PageRank, spectral clustering and recommender systems use eigenvectors of or the Laplacian .
Mind Map
Visual structure of the conceptMATRIX REPRESENTATIONS
├── Adjacency A (n × n)
│ ├── Aᵢⱼ = 1 if edge
│ ├── Undirected ⇒ symmetric
│ ├── Aᵏ counts walks of length k
│ └── Laplacian L = D − A
├── Incidence B (n × m)
│ ├── Undirected: 1 if vertex on edge
│ └── Directed: −1 tail / +1 head
├── Circuit matrix
├── Cut-set matrix
└── Path matrix (transitive closure of A)
Exam Q&A
Part A (2 marks) and Part B (20 marks) style questionsPart A (2 marks each)
Q1. Define adjacency matrix of a graph. For a graph on vertices, the matrix with if there is an edge between and , else 0.
Q2. What does represent? The number of walks of length 2 from to .
Q3. Difference between incidence and adjacency matrix. Adjacency is vertex × vertex; incidence is vertex × edge.
Q4. For an undirected graph, what property does have? is symmetric.
Part B (20 marks)
Q. Describe the matrix representations of a graph — adjacency, incidence, circuit and path matrix. Take the graph with and edges and write its adjacency and incidence matrices. Use to count walks of length 2 from vertex 1.
(i) Adjacency matrix. × . Entry if is an edge.
(Vertex 1 is adjacent to 2, 3, 4; vertex 2 to 1, 3; vertex 3 to 1, 2, 4; vertex 4 to 1, 3.)
(ii) Incidence matrix. × . Label edges .
(iii) Circuit matrix — rows index fundamental circuits (cycles), columns index edges. For each cycle, mark the edges in it. The cycle uses , giving row , and so on.
(iv) Path matrix is the transitive closure of (here all entries become 1 since is connected).
Walks of length 2 from vertex 1. Compute the first row of :
(walks , , ).
(walk ).
(walks and ).
(walk ).
So from vertex 1 there are 3 closed, 1 to vertex 2, 2 to vertex 3, 1 to vertex 4 — total of 7 walks of length 2.