graphs, relations and matrices section 7.4. overview graph structures are valuable because they can...

25
Graphs, relations and matrices Section 7.4

Upload: dwight-crawford

Post on 23-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Graphs, relations and matrices

Section 7.4

Page 2: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Overview

Graph structures are valuable because they can represent relationships among pairs of objects, and they remain simple in structure even when the number of objects is large. In application problems, it becomes important to use a computer to analyze graph properties, so we need a representation of a graph that a computer can understand.

Page 3: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

One representation for a graph

Page 4: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Example

Page 5: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Practice Problem 1Write the adjacency matrices of each of the following graphs. Make clear

which vertex corresponds to which row/column. In each graph, what is the value of M12? Of M34? Of M21?

Page 6: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Directed Graphs

Note that all of our examples involve “symmetric” matrices because the number in Mab and Mba must be the

same for any graph. However, in some applications, this is not the case.

Page 7: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Directed Graphs

A directed graph, like a graph, consists of a set V of vertices and a set E of edges. Each edge is associated with an ordered pair of vertices called its endpoints. In other words, a directed graph is the same as a graph, but the edges are described as ordered pairs rather than unordered pairs.

If the endpoints for edge e are a and b in that order, we say e is an edge from a to b, and in the diagram we draw the edge as a straight or curved arrow from a to b.

For a directed graph, we use (a, b) rather than [a, b] to indicate an edge from a to b. This emphasizes that the edge is an ordered pair, by using the usual notation for ordered pairs.

Page 8: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

More definitions and terms

A walk in a directed graph is a sequence v1e1v2e2 . . .

vnenvn+1 of alternating vertices and edges that begins

and ends with a vertex, and where each edge in the list lies between its endpoints in the proper order. If there is no chance of confusion, we omit the edges when we describe a walk.

The adjacency matrix for a directed graph with vertices {v1, v2, . . . , vn} is the n × n matrix where Mij (the entry

in row i , column j) is the number of edges from vertex vi to vertex vj.

Page 9: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Example

Consider a two-player game where there is a single pile of 10 stones and each player may remove one or two stones at a time on his or her turn. If we use a node for each state of the game and an edge to denote a move, we get the directed graph below:

Page 10: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Questions

1. Why is it important to use a directed graph in modeling this game?

2. Find the adjacency matrix for this directed graph.

Page 11: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Matrix arithmetic

Matrices can be multiplied and added using some standard mathematical rules. The surprising thing is that these standard operations, when applied to the adjacency matrix of a graph, have a real interpretation in terms of the graph properties we already know.

Page 12: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

What does M2 represent?

Given the adjacency matrix M for a directed graph G, the arithmetic operation M × M has an interpretation in G. Let’s see if we can figure out what it is in this example.

Page 13: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Matrix multiplication

To compute the (2,3)-entry in M2, we multiply Row 2 of M times Column 3 of M as follows:

Page 14: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Matrix multiplication

If we complete the multiplication (every row times every column), we get the result at the right. What do these numbers mean in terms of the original graph?

Page 15: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Interpretation of Mk

Theorem. Let M be the adjacency matrix of a directed graph G with vertex set {1, 2, 3, . . . , n}. The row i, column j entry of Mk counts the number of k-step walks from node i to node j in the graph G.

Page 16: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Interpretation of the sum M + M2 + … + Mk

We find the sum of two matrices by adding entries in the same position. This gives us the following extension of our theorem.

Corollary. Let M be the adjacency matrix of a directed graph G with vertex set {1, 2, 3, . . . , n}. The row i, column j entry of M + M2 + … + Mk counts the number of walks from node i to node j in the graph G of length k or less.

Page 17: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Example

Page 18: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Connection to Relations

Note that a directed graph looks exactly the same as a one-set arrow diagram for a relation R on a set A. This is no coincidence!!

Page 19: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Binary Relations, Directed Graphs, and Adjacency Matrices

For a relation R on the set A = {1, 2, 3, . . . , n}, the following statements are equivalent for all a, b A:

(a, b) R (which we write sometimes as aRb). There is a directed edge from node a to node

b in the graph of R. There is a 1 in the row a, column b entry of the

adjacency matrix for R.

Page 20: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Examples

Page 21: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Solutions

Page 22: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Boolean Operations and Composition of Relations

We can find a connection between matrix arithmetic and composition of relations as long as we use “Boolean arithmetic” in our computations:

Page 23: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Boolean matrix multiplication

In this example, we multiply A × A in the same way as before, except we use the Boolean addition and multiplication among the entries. To distinguish this from A2, we denote this A(2). Try it before checking the next slide for the answer!

Page 24: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Boolean matrix multiplicationTake a moment to find

the composition R ◦ R, and write the adjacency matrix for this new relation. Compare to A(2)!

Page 25: Graphs, relations and matrices Section 7.4. Overview Graph structures are valuable because they can represent relationships among pairs of objects, and

Composition and Boolean matrix multiplication

Theorem. If R is a binary relation on a set A with adjacency matrix M, then the matrix M(2) is the adjacency matrix for the relation R ◦ R on the set A.