Download presentation
Presentation is loading. Please wait.
1
Graphs, relations and matrices
Section 7.4
2
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.
3
One representation for a graph
4
Example
5
Practice Problem 1 Write 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?
6
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.
7
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.
8
More definitions and terms
A walk in a directed graph is a sequence v1e1v2e 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.
9
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:
10
Questions Why is it important to use a directed graph in modeling this game? Find the adjacency matrix for this directed graph.
11
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.
12
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.
13
Matrix multiplication
To compute the (2,3)-entry in M2, we multiply Row 2 of M times Column 3 of M as follows:
14
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?
15
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.
16
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.
17
Example
18
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!!
19
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.
20
Examples
21
Solutions
22
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:
23
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!
24
Boolean matrix multiplication
Take a moment to find the composition R ◦ R, and write the adjacency matrix for this new relation. Compare to A(2)!
25
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.