Adjacency Matrices How can you implement a graph using a matrix? 1. Number the nodes from 0 to n-1. 2. Make an n x n matrix of booleans. 3. Put true in a[i][j] if the graph has edge (i,j). What are strengths of the adjacency matrix implementation of graphs? 1. Finding whether an edge exists between two nodes is fast. 2. Good fit for algorithms that loop over every pair of nodes. Classwork You may work with a partner. Give the adjacency matrix for the directed graph. (graph2.pdf) V = { a, b, c, d, e } E = { (b,a), (b,c), (b,d), (b,e), (c,b), (d,c), (d,e), (e,a) } a---b---c \ / \ / e---d Classwork You may work with a partner. Give the adjacency matrix for the undirected graph. (graph1.pdf) V = { a, b, c, d, e } E = { {a,b}, {a,c}, {a,e}, {b,c}, {c,d}, {c,e}, {d,e} } a---e |\ |\ | \ | d | \|/ b---c