Download presentation
Presentation is loading. Please wait.
Published byCurtis Simpson Modified over 8 years ago
1
Graphs and Matrices Spring 2012 Mills College Dan Ryan Lecture Slides by Dan Ryan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.Dan RyanCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
2
Four Representations of a Graph G={V,E} NODE List A B D E B A C D C A B D D A B C E A EDGE List AB AD AE BA BC BD CA CB CD DA DB DC EA A C B D E MATRIX
3
Matrix 10001 11220 12000 30100 01111 ROWSCOLUMNS A matrix ELEMENT The MAIN DIAGONAL SQUARE MATRIX RECTANGULAR MATRIX
4
Nomenclature: nrows by mcols 10 11 12 30 01 1000 1122 100 112 120 1 3 0 5x2 matrix 2x4 matrix 3x1 matrix 3x3 matrix
5
Matrix
6
Sometimes we say “Vector” Each row (or column) in a matrix can be thought of as an ordered set of numbers describing an object. For a graph matrix, a row or a column is a “vector” of a vertex’s connections The fourth vertex is connected to the first, second, and third, but not the fifth
7
Transpose The transpose of a matrix is a swapping of its rows and columns
8
Transposing a Matrix transpose i j
9
Matrix Arithmetic
10
Example: Convert 2-Mode to 1-Mode(s) 1.Write the rectangular incidence matrix I A 123 BDC ABCD 11011 20110 31111 GROUPS PEOPLE A “groups by people” matrix
11
Example: Convert 2-Mode to 1-Mode(s) 2.Compute transpose of I, I T ABCD 11011 20110 31111 123 A101 B011 C111 D101 A “groups by people” matrix A “people by groups” matrix
12
When we multiply matrices… Columns of first factor = rows of second factor (People x Groups) X (Groups x People) = (People x People) (Groups x People) X (People x Groups) = (Groups x Groups) I T 101 011 111 101 I 1011 0110 1111 A GxG 313 122 324 I T 101 011 111 101 I 1011 0110 1111 A PxP 2122 1221 2232 2122 =x = x
13
Degree - 1 0 0 0 1 - 0 1 0 0 0 - 1 1 0 1 1 - 1 0 0 1 1 -
14
Mean(average) Degree
15
Degree and Edges
16
Adjacency Matrix
17
Matrix Arithmetic See also: http://www.jtaylor1142001.net/calcjat/Contents/CMatrix.htm#MatrixMulthttp://www.jtaylor1142001.net/calcjat/Contents/CMatrix.htm#MatrixMult
18
Directed Unweighted Undirected Weighted Undirected Unweighted Directed Weighted dichotomize symmetrize E A B C D 2 4 5 1 1 - 4 0 0 0 0 - 0 1 0 0 0 - 0 0 0 1 5 - 1 0 0 2 0 - E A B C D E A B C D 2 4 5 1 1 E A B C D - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 0 1 1 - 1 0 0 1 0 - - 4 0 0 0 4 - 0 1 0 0 0 - 5 2 0 1 5 - 1 0 0 2 1 - - 1 0 0 0 - 0 1 0 - 1 1 - 1 -
19
Paths If there is a path from vertex A to vertex B… …then there is a sequence of edges connecting them E.g., if there is a 2-path from A to C then there is some vertex B such that there is an edge AB and an edge BC AC B Path A to C?
20
Put another way An edge from vertex j to vertex i means A ij =1 If there is a 2-path from j to i then there is a k such that A ik =1 and A kj =1. …i…j…k… 0011000 i01110 1 0 0110100 j0110100 0000000 k001 1 001 0100000 j i k
21
A ik =1 and A kj =1 That means: if there is a path from vertex j to vertex k to vertex i THEN there is a k such that A ik A kj =1 …i…j…k… -000000 i0-100 1 0 00-1010 j000-000 0010-00 k100 1 0-0 010000- j i k a b c There is an edge from k to i There is an edge from j to k
22
Another way to see it… If vertex j is connected to vertex k AND Vertex I is connected to k THEN Row I will have a 1 in position k AND Column j will have a 1 in position k
23
Elements of Product Matrix are Vector Products 21101 = 13110 11201 01010 10102 01100 10101 11000 00001 01010 01100 X 10101 11000 00001 01010 i j A 2 ij is how many times the row version and the column version have 1s in the same place
24
…i…j…k… -000000 i0-100 1 0 00-1010 j000-000 0010-00 k100 1 0-0 010000- Are there other paths from j to i? j i k
25
Look for vertices between j and i …i…j……… 0011000 i0111010 0110100 j0110100 0000000 0011001 0100000 j i k
26
Example: Convert 2-Mode to 1-Mode(s) 2.Compute transpose of I, I T A 123 BDC ABCD 11011 20110 31111
27
Degree Distribution “Distribution of X” = pattern of different values X takes on More specifically: the frequency of each value 4 2 3 3 5 1 2 4 4 4 4 4 5 5 2 2 2 2 2 2 1 3 3 3 1 || 2 |||| ||| 3 |||| 4 |||| | 5 ||| 3 5 1 2 4 4 4 4 4 5 5 2 2 2 2 2 2 2 1 3 3 3 3 4
28
Diagonal Elements of A 2 are Vertex Degree 01100 A= 10101 11000 00001 01010 21101 A2=A2= 13110 11201 01010 10102
29
Why? 21101 = 13110 11201 01010 10102 A2A2 01100 10101 11000 00001 01010 A 01100 X 10101 11000 00001 01010 A Degree equals number of “out and back” paths of length 2
30
How about A 3 ? 24311 = 42404 34211 10102 14120 A3A3 01100 X 10101 11000 00001 01010 A 21101 13110 11201 01010 10102 A2A2
31
What do these represent? 24311 = 42404 34211 10102 14120 A3A3 01100 X 10101 11000 00001 01010 A 21101 13110 11201 01010 10102 A2A2
32
PRACTICE:COMPUTE A 2 FROM WXYZ W -100 TO X 0-11 Y 10-0 Z 0010 A W Z X Y FROM WXYZ W 0011 TO X 1010 Y 0100 Z 1000 A2A2
33
PRACTICE:COMPUTE A 3 FROM WXYZ W -100 TO X 0-11 Y 10-0 Z 0010 A W Z X Y FROM WXYZ W 0011 TO X 1010 Y 0100 Z 1000 A2A2 FROM WXYZ W 1010 TO X 1100 Y 0011 Z 0100 A3A3
35
…i…j…k… -000000 i0-100 1 0 00-1010 j000-000 0010-00 k100 1 0-0 010000- Are there other paths from j to i? j i k
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.