1 / 35

Graphs and Matrices

Graphs and Matrices. Four Representations of a Graph. G={V,E}. EDGE List AB AD AE BA BC BD CA CB CD DA DB DC EA. MATRIX. NODE List A B D E B A C D C A B D D A B C E A. E. A. B. D. C. Matrix. COLUMNS. ROWS. The MAIN DIAGONAL. A matrix ELEMENT. SQUARE MATRIX.

aislin
Download Presentation

Graphs and Matrices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphs and Matrices

  2. Four Representations of a Graph G={V,E} EDGE List AB AD AE BA BC BD CA CB CD DA DB DC EA MATRIX NODE List A B D E B A C D C A B D D A B C E A E A B D C

  3. Matrix COLUMNS ROWS The MAIN DIAGONAL A matrix ELEMENT SQUARE MATRIX RECTANGULAR MATRIX

  4. Nomenclature: nrows by mcols 2x4 matrix 3x3 matrix 5x2 matrix 3x1 matrix

  5. Matrix • A table of values arranged in ordered rows and columns • Elements of matrix M referred to by row and column number as subscripts • An unspecified element is referred to generically as being in row i and column j

  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 connectedto 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 • Multiplication • Row of first matrix times column of second • Element by element multiplication • Sum the products

  10. Example: Convert 2-Mode to 1-Mode(s) • Write the rectangular incidence matrix I 1 2 3 GROUPS A B C D PEOPLE A “groups by people” matrix

  11. Example: Convert 2-Mode to 1-Mode(s) • Compute transpose of I, IT 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) APxP 2122 1221 2232 2122 AGxG 313 122 324 I 1011 0110 1111 I 1011 0110 1111 x = x = IT 101 011 111 101 IT 101 011 111 101

  13. Degree • DEF: degree of vertex is number of edges connected to it • Written as • For undirected graph, sum of row i of matrix - 1 0 0 0 1 - 0 1 0 0 0 - 1 1 0 1 1 - 1 0 0 1 1 -

  14. Mean(average) Degree • The mean degree, c, in a graph is the sum of all the vertex degrees divided by the number of vertices:

  15. Degree and Edges • Each of m edges has two ends and so contributes 2 to the total degree in graph. Thus • But • So • Which is just the sum of all the elements of the adjacency matrix (since we run through all the j’s for each i – adding up row by row as we go)

  16. Adjacency Matrix • One row and one column for each vertex • Each matrix element describes link between row vertex and column vertex

  17. Matrix Arithmetic • Addition and Subtraction • Element by element See also: http://www.jtaylor1142001.net/calcjat/Contents/CMatrix.htm#MatrixMult

  18. - 1 0 0 0 0 - 0 1 0 0 0 - 0 0 0 1 1 - 1 0 0 1 0 - Directed Unweighted 1 1 E E E E 2 2 D D D D 5 5 C C C C dichotomize 1 1 symmetrize A A A A 4 4 B B B B Undirected Unweighted Directed Weighted - 1 0 0 0 - 0 1 0 - 1 1 - 1 - - 4 0 0 0 0 - 0 1 0 0 0 - 0 0 0 1 5 - 1 0 0 2 0 - symmetrize dichotomize Undirected Weighted - 4 0 0 0 4 - 0 1 0 0 0 - 5 2 0 1 5 - 1 0 0 2 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 Path A to C? A B C

  20. Put another way • An edge from vertex j to vertex i means Aij=1 • If there is a 2-path from j to i then there is a k such that Aik=1 and Akj=1. j k i

  21. Aik=1 and Akj=1 • That means: if there is a path from vertex j to vertex k to vertex i THENthere is a k such that AikAkj=1 There is an edge from k to i j c b There is an edge from j to k k i a

  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 A2ij is how many times the row version and the column version have 1s in the same place j i

  24. Are there other paths from j to i? • Yes, if there are other k’s such that AikAkj=1 • In fact, we can write • But this is just the number of times that we get 1 and 1 as we look down column j and across row i j k i

  25. Look for vertices between j and i j k i

  26. Example: Convert 2-Mode to 1-Mode(s) • Compute transpose of I, IT 1 2 3 A B C D

  27. Degree Distribution • “Distribution of X” = pattern of different values X takes on • More specifically: the frequency of each value 1 || 2 |||| ||| 3 |||| 4 |||| | 5 ||| 2 2 3 4 4 4 4 5 3 5 2 5 2 3 2 4 2 4 3 2 4 4 3 3 4 2 4 1 5 3 2 2 5 1 2 5 2 3 4 4 2 3 3 2 1 2 2 1

  28. Diagonal Elements of A2 are Vertex Degree

  29. Why? Degree equals number of “out and back” paths of length 2

  30. How about A3?

  31. What do these represent?

  32. PRACTICE:COMPUTE A2 W X Y Z

  33. PRACTICE:COMPUTE A3 W X Y Z

  34. Are there other paths from j to i? • Yes, if there are other k’s such that AikAkj=1 • In fact, we can write • But this is just the number of times that we get 1 and 1 as we look down column j and across row i j k i

More Related