This preview shows pages 1–7. Sign up to view the full content.

Discussion #31 Chapter 7, Section 4 1/12 Discussion #31 Adjacency Matrices

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #31 Chapter 7, Section 4 2/12 Topics Adjacency matrix for a directed graph Reachability Algorithmic Complexity and Correctness Big Oh Proofs of correctness for algorithms Loop invariants Induction
Discussion #31 Chapter 7, Section 4 3/12 Adjacency Matrix Definition: Let G = ( V , E ) be a simple digraph. Let V = { v 1 , v 2 ,… v n } be the vertices (nodes). Order the vertices from v 1 to v n . The n × n matrix A whose elements are given by a ij = 1, if ( v i , v j ) E 0, otherwise is the adjacency matrix of the graph G . Example: { 1 2 3 4 1 0 1 0 v 4 1 0 0 0 v 3 1 1 0 0 v 2 0 0 1 0 v 1 v 4 v 3 v 2 v 1 A =

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #31 Chapter 7, Section 4 4/12 Powers of adjacency matrices: A 2 , A 3 , … Can compute powers Using ordinary arithmetic: Using Boolean arithmetic: a ij = k =1 n a ik a kj Powers of Adjacency Matrices a ij = k =1 n a ik a kj
Discussion #31 Chapter 7, Section 4 5/12 1 2 3 4 Powers Using Ordinary Arithmetic 1 0 1 0 4 1 0 0 0 3 1 1 0 0 2 0 0 1 0 1 4 3 2 1 A = 2 1 1 0 4 1 0 1 0 3 2 0 1 0 2 1 1 0 0 1 4 3 2 1 A 2 = 4 1 2 0 4 2 1 1 0 3 3 1 2 0 2 2 0 1 0 1 4 3 2 1 A 3 = <2,3,4> <2,4,4> <4,2,4> <4,4,4> <1,2,3,4> <1,2,4,4> <2,4,2,4> <2,4,4,4> <2,3,4,4> <3,4,2,4> <3,4,4,4> <4,2,3,4> <4,2,4,4> <4,4,2,4> <4,4,4,4> <1,2,4> <3,4,4>

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #31 Chapter 7, Section 4 6/12 Powers Using Ordinary Arithmetic (continued…) The element in the i th row and the j th column of A n is equal to the number of paths of length n from the i th node to the j th node.
This is the end of the preview. Sign up to access the rest of the document.