Matrix Representation of Graphs

Slides:



Advertisements
Similar presentations
CSNB143 – Discrete Structure
Advertisements

Chapter Matrices Matrix Arithmetic
8.3 Representing Relations Connection Matrices Let R be a relation from A = {a 1, a 2,..., a m } to B = {b 1, b 2,..., b n }. Definition: A n m  n connection.
Graph-02.
1 Slides based on those of Kenneth H. Rosen Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus Graphs.
Lecture 17 Path Algebra Matrix multiplication of adjacency matrices of directed graphs give important information about the graphs. Manipulating these.
1 Reduction between Transitive Closure & Boolean Matrix Multiplication Presented by Rotem Mairon.
Introduction to Graphs
Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.
Graphs G = (V,E) V is the vertex set. Vertices are also called nodes and points. E is the edge set. Each edge connects two different vertices. Edges are.
Applied Discrete Mathematics Week 12: Trees
9.3 Representing Graphs and Graph Isomorphism
Graphs, relations and matrices
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
 What is a graph? What is a graph?  Directed vs. undirected graphs Directed vs. undirected graphs  Trees vs graphs Trees vs graphs  Terminology: Degree.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Chapter 4 – Matrix CSNB 143 Discrete Mathematical Structures.
Based on slides by Y. Peng University of Maryland
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
4.5 Inverse of a Square Matrix
CSCI 171 Presentation 9 Matrix Theory. Matrix – Rectangular array –i th row, j th column, i,j element –Square matrix, diagonal –Diagonal matrix –Equality.
Matrices Section 2.6. Section Summary Definition of a Matrix Matrix Arithmetic Transposes and Powers of Arithmetic Zero-One matrices.
How to Multiply Two Matrices. Steps for Matrix Multiplication 1.Determine whether the matrices are compatible. 2.Determine the dimensions of the product.
Data Structures & Algorithms Graphs Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Basic properties Continuation
Chapter 9: Graphs.
2.5 – Determinants and Multiplicative Inverses of Matrices.
Chapter 1 Section 1.6 Algebraic Properties of Matrix Operations.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
1 Lecture 5 (part 2) Graphs II (a) Circuits; (b) Representation Reading: Epp Chp 11.2, 11.3
Graphs and Matrices Spring 2012 Mills College Dan Ryan Lecture Slides by Dan Ryan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike.
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
A very brief introduction to Matrix (Section 2.7) Definitions Some properties Basic matrix operations Zero-One (Boolean) matrices.
Subject Four Graphs Data Structures. What is a graph? A data structure that consists of a set of nodes (vertices) and a set of edges that relate the nodes.
4-2 Multiplying Matrices Warm Up Lesson Presentation Lesson Quiz
13.4 Product of Two Matrices
Applied Discrete Mathematics Week 14: Trees
1.5 Matricies.
Applied Discrete Mathematics Week 13: Graphs
15. Directed graphs and networks
Special Graphs By: Sandeep Tuli Astt. Prof. CSE.
Finding the Inverse of a Matrix
Matrix Multiplication
Multiplication of Matrices
Discrete Structures – CNS2300
Matrix Representation of Graph
Based on slides by Y. Peng University of Maryland
Graphs All tree structures are hierarchical. This means that each node can only have one parent node. Trees can be used to store data which has a definite.
2. Matrix Algebra 2.1 Matrix Operations.
Relations (sections 7.1 – 7.5)
Summary 3 Discrete Probability (sections )
Graph Operations And Representation
Connectivity Section 10.4.
Walks, Paths, and Circuits
Matrices Introduction.
CS100: Discrete structures
Representing Graphs Wade Trappe.
Multiplication of Matrices
Lesson 4: Inverses of Matrices (part 1)
Applied Discrete Mathematics Week 13: Graphs
Based on slides by Y. Peng University of Maryland
Matrix Multiplication Sec. 4.2
Agenda Review Lecture Content: Shortest Path Algorithm
GRAPHS.
Presentation transcript:

Matrix Representation of Graphs Lecture 53 Section 11.3 Thu, Apr 27, 2006

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.

Example v1 v2 v3 v4 v5 v6 1 A =

Example v1 v2 v3 v4 v5 v6 1 A =

Example v1 v2 v3 v4 v5 v6 1 A =

Indegree and Outdegree How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 A =

Indegree and Outdegree How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 = 2 = out(v3) A =

Indegree and Outdegree How can we tell from the matrix what the indegree and outdegree of a vertex are? 1 A = = 1 = in(v3)

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.

Example v1 v2 v3 v4 v5 v6 1 A =

Example v1 v2 v3 v4 v5 v6 1 A =

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.

Matrix Multiplication 20 40 15 35 10 30 5 25 1 2 3 4 5 6 7 8 100 300 820 =

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

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

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

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

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.

The Identity Matrix The identity matrix is like the number 1 with regards to multiplication. AI = A. IA = A. for all compatible matrices A.

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.

Counting Walks Consider again the graph and its adjacency matrix. v1 1 A =

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

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.

Counting Walks 1 2 A2 =

Counting Walks Verify the indicated entries by counting walks. A2 = 1 1 2 A2 =

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.

Counting Walks 2 1 A3 =

Counting Walks 4 1 2 A4 =

Counting Walks 1 4 2 8 A5 =

Counting Walks 8 2 6 4 A6 =

Counting Walks 16 6 2 8 4 12 20 A7 =

Counting Walks Verify the indicated entry by counting walks. A7 = 16 6 16 6 2 8 4 12 20 A7 =

Counting Walks How many closed walks of length 7 are there? A7 = 16 6 16 6 2 8 4 12 20 A7 =

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 =

Circuits How could the adjacency matrix be used to determine whether a graph (or directed graph) contains a circuit?

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.

Connected Components Consider the following graph and its adjacency matrix. v1 v2 v3 v4 v5 v6 v7 1 A =

Connected Components Note the “block” nature of the matrix. v1 v3 v7 1 A =

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?

Connected Components 11 12 6 16 4 10 A + A2 + A3 + A4 =

Connected Components 11 12 6 16 4 10 A + A2 + A3 + A4 =