Download presentation
Presentation is loading. Please wait.
1
Matrix Representation of Graphs
Lecture 53 Section 11.3 Thu, Apr 27, 2006
2
The Adjacency Matrix Let G be a directed graph with n vertices v1, …, vn. The adjacency matrix of G is an n n matrix A with entries aij, where aij = the number of edges from vi to vj.
3
Example v1 v2 v3 v4 v5 v6 1 A =
4
Example v1 v2 v3 v4 v5 v6 1 A =
5
Example v1 v2 v3 v4 v5 v6 1 A =
6
Indegree and Outdegree
How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 A =
7
Indegree and Outdegree
How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 = 2 = out(v3) A =
8
Indegree and Outdegree
How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 A = = 1 = in(v3)
9
Undirected Graphs If G is an undirected graph, then aij = the number of edges between vi and vj. The number of edges between vi and vj is the same as the number of edges between vj and vi. Therefore, the adjacency matrix is symmetric: aij = aji.
10
Example v1 v2 v3 v4 v5 v6 1 A =
11
Example v1 v2 v3 v4 v5 v6 1 A =
12
Matrix Multiplication
Let A be an m n matrix and B an r s matrix. The product AB is defined only if n = r. In that case, the product is an m s matrix. The ij-entry of the product equals row i of A times column j of B.
13
Matrix Multiplication
20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 =
14
Matrix Multiplication
20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 = (1 20) + (2 15) + (3 10) + (4 5) = 100
15
Matrix Multiplication
20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 = (1 40) + (2 35) + (3 30) + (4 25) = 300
16
Matrix Multiplication
20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 = (5 20) + (6 15) + (7 10) + (8 5) = 300
17
Matrix Multiplication
20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 = (5 40) + (6 35) + (7 30) + (8 25) = 820
18
The Identity Matrix The n n identity matrix I consists of all 0s except for 1s on the main diagonal. That is ij-entry = 0 if i j. ij-entry = 1 if i = j.
19
The Identity Matrix The identity matrix is like the number 1 with regards to multiplication. AI = A. IA = A. for all compatible matrices A.
20
Powers of Square Matrices
If a matrix is square, then we can raise it to a power. A0 = I. A1 = A. An = A An – 1.
21
Counting Walks Consider again the graph and its adjacency matrix. v1
1 A =
22
Counting Walks How many walks of length 2 are there from v5 to v4?
In the adjacency matrix, multiply row 5 by column 4. 1 = 2 1 row 5 col 4
23
Counting Walks We see that the number of walks of length 2 from vertex vi to vertex vj is given by the product of row i times column j. It follows that the ij-entry of A2 is the number of walks of length 2 from vi to vj.
24
Counting Walks 1 2 A2 =
25
Counting Walks Verify the indicated entries by counting walks. A2 = 1
1 2 A2 =
26
Counting Walks Theorem: Let A be the adjacency matrix of a graph G and let vi and vi be two vertices of G. The number of walks of length k from vi to vj is given by the ij-entry of Ak.
27
Counting Walks 2 1 A3 =
28
Counting Walks 4 1 2 A4 =
29
Counting Walks 1 4 2 8 A5 =
30
Counting Walks 8 2 6 4 A6 =
31
Counting Walks 16 6 2 8 4 12 20 A7 =
32
Counting Walks Verify the indicated entry by counting walks. A7 = 16 6
16 6 2 8 4 12 20 A7 =
33
Counting Walks How many closed walks of length 7 are there? A7 = 16 6
16 6 2 8 4 12 20 A7 =
34
Counting Walks What does the following matrix tell us?
11 23 12 28 7 15 17 13 14 24 10 37 A + A2 + A3 + … + A7 =
35
Circuits How could the adjacency matrix be used to determine whether a graph (or directed graph) contains a circuit?
36
Circuits If a graph with n vertices contains a circuit, then it contains a circuit of length at most n. Therefore, among the matrices A2, A3, …, An, there would be one with a nonzero entry in a diagonal position. Thus, the matrix A2 + A3 + … + An would contain at least one nonzero diagonal entry.
37
Connected Components Consider the following graph and its adjacency matrix. v1 v2 v3 v4 v5 v6 v7 1 A =
38
Connected Components Note the “block” nature of the matrix. v1 v3 v7
1 A =
39
Connected Components This tells us that the graph has two connected components, with vertices {v1, v2, v3, v4} and {v5, v6, v7}. What would we expect the matrix A + A2 + A3 + A4 to look like?
40
Connected Components 11 12 6 16 4 10 A + A2 + A3 + A4 =
41
Connected Components 11 12 6 16 4 10 A + A2 + A3 + A4 =
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.