<<

Non-negative matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity Non-negative matrices and graphs MAA704 and the adjacency

Distance Christopher Engstr¨om matrix Shortest and Dijkstra’s algorithm

Degree matrix November 20, 2018 of a graph

Markov chains

1 / 50 Non-negative MAA704 Applied matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity and the Todays lecture: I Non-negative matrices and introduction to . matrix

I Connectivity and Irreducibility. Shortest path and Dijkstra’s I The of a graph algorithm matrix of a graph

Markov chains

2 / 50 Non-negative Non-negative matrices matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity A non-negative matrix is a matrix A where all elements and the I adjacency ai,j ≥ 0. matrix Distance I A positive matrix is a matrix A where all elements ai,j > 0. matrix Remark. Be careful to distinguish between Shortest path I and Dijkstra’s positive/non-negative matrices and positive algorithm > definite/semi-definite matrices (recall x Ax). of a graph

Markov chains

3 / 50 Non-negative Non-negative matrices in Graph-theory matrices and graphs MAA704

A graph is a collection of vertices (nodes) and edges (links) Christopher such as the one below. Engstr¨om

lecture 2

Connectivity and the adjacency B matrix

Shortest path and Dijkstra’s algorithm A C Degree matrix of a graph

Markov chains

D

4 / 50 Non-negative Non-negative matrices in Graph-theory matrices and graphs MAA704

Christopher Engstr¨om There are many types of graphs those we will work with are: lecture 2 I Simple graphs, where we only allow a single edge from Connectivity and the one to another. adjacency matrix Undirected graphs, where edges do not have a direction I Distance so we are only interested in if there is a edge between two matrix Shortest path vertices. and Dijkstra’s algorithm I Directed graphs, where edges do have a direction, a edge Degree matrix A → B does not necessary mean there is a edge B → A. of a graph I Weighted graph, where we assign (positive) weights as Markov chains scalars to every edge.

5 / 50 Non-negative Non-negative matrices in Graph-theory matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity and the How can we represent a (simple) graph using a matrix? adjacency matrix Multiple ways such as the adjacency matrix, degree matrix, I Distance distance matrix, matrix, Laplacian matrix, etc. matrix Shortest path I Which graph type and which matrix representation you and Dijkstra’s use depend on your application. algorithm Degree matrix of a graph

Markov chains

6 / 50 Non-negative Application, road network and connectivity matrices and graphs MAA704

Christopher We consider a road network between different cities where we Engstr¨om want to know if we can drive from one city to another, or if we lecture 2 need to go by for example air/boat. Connectivity and the I We represent the road network using a undirected graph adjacency by letting the vertices represent the cities, and a edge matrix Distance between two cities means there is a road between the two matrix

cities. Shortest path and Dijkstra’s I If there is a edge between, say, two cities A, B we know algorithm there is a road and we can take the car. However if there Degree matrix of a graph

isn’t we might still be able to take the car for example by Markov chains passing city C which is both connected to cities A and B. I To solve this problem we define connectivity for graphs, and irreducibility for matrices.

7 / 50 Non-negative Connectivity matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity I Two vertices are said to be connected if by traversing and the adjacency the edges there exists a path from both of the nodes to matrix

the other one. Distance matrix A graph is said to be connected if it is connected for all I Shortest path pair of nodes in the undirected graph. and Dijkstra’s algorithm

I A is said to be strongly connected if it is Degree matrix connected for all pair of nodes in the directed graph. of a graph Markov chains

8 / 50 Non-negative Connectivity: connected components matrices and graphs MAA704

Christopher A connected component in an undirected graph is a Engstr¨om

maximal part of the graph where all nodes are connected with lecture 2

each other. Connectivity and the adjacency matrix

Distance matrix

Shortest path and Dijkstra’s algorithm

Degree matrix of a graph

Markov chains

Figure: A undirected graph with 3 connected components

9 / 50 Non-negative Connectedness: strongly connected components matrices and graphs MAA704

Christopher A strongly connected component is a part of the graph Engstr¨om

which is strongly connected. lecture 2

Connectivity and the adjacency matrix

Distance matrix

Shortest path and Dijkstra’s algorithm

Degree matrix of a graph

Markov chains

Figure: A directed graph with 3 strongly connected components

10 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 So if our two cities belong to the same connected component, Connectivity and the there is a path between them and we can take the car. adjacency matrix I But how do we find the connected components? Distance Especially if we have a large graph it might even be hard matrix Shortest path to visualize the graph. and Dijkstra’s algorithm To solve the problem we use a matrix representation called I Degree matrix the adjacency matrix. of a graph Markov chains

11 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Definition Connectivity and the The adjacency matrix A of a graph G with n vertices is a adjacency matrix square n × n matrix with elements ai,j such that: Distance  matrix 1, if there is a link from vertex i to vertex j Shortest path ai,j = and Dijkstra’s 0, otherwise algorithm

Degree matrix If the graph is undirected we consider every edge between two of a graph vertices as linking in both directions. Markov chains

12 / 50 Non-negative Non-negative matrices in graph theory matrices and graphs MAA704

Christopher Example of an undirected graph and corresponding adjacency Engstr¨om matrix (vertices ordered A,B,C,D). lecture 2

Connectivity and the adjacency B matrix Distance matrix   Shortest path 0 1 1 1 and Dijkstra’s algorithm 1 1 1 0 A C   Degree matrix 1 1 0 0 of a graph 1 0 0 0 Markov chains

D

13 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 We note that the adjacency matrix is not unique in itself, we Connectivity and the need to choose in what order we put our vertices in the matrix! adjacency matrix I Sometimes changing the order of the vertices (essentially Distance re-labeling the graph) can make certain structures more matrix Shortest path obvious. and Dijkstra’s algorithm For example we could group vertices in the same I Degree matrix connected component together. of a graph Markov chains

14 / 50 Non-negative Adjacency matrix, other applications matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity and the A undirected or directed graph and it’s adjacency matrix could adjacency also be used to represent other things such as: matrix Distance I Links between homepages, and PageRank. matrix Shortest path I Electrical or water flow networks. and Dijkstra’s algorithm Linguistic relations between words or phrases. I Degree matrix of a graph

Markov chains

15 / 50 Non-negative Path, cycle and length matrices and graphs MAA704

Christopher Engstr¨om

Definition lecture 2 Connectivity Given a weighted or unweighted graph: and the adjacency I A path in a graph is a sequence of vertices e1, e2,..., en matrix such that for every vertex in the sequence there is an edge Distance matrix to the next vertex in the sequence. Shortest path and Dijkstra’s I If the first vertex in a path is the same as the last vertex algorithm we call it a cycle. Degree matrix of a graph The length of a path is the number of edges in the path I Markov chains (counting multiple uses of the same edge).

16 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 Returning to our road network example, while a 1 at element Connectivity a means there is a road between those two cities, we still and the ij adjacency don’t know how to find the connected components using the matrix adjacency matrix. Distance matrix k I We take a look at the powers A of the adjacency matrix. Shortest path and Dijkstra’s I A non-zero element of A1 means there is a path of algorithm Degree matrix ”length” 1 between the two vertices. (length as in number of a graph

of edges) Markov chains

17 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om 2 2 We look at A and when a single element aij > 0. lecture 2 2 Connectivity I For ai,j > 0 we need that at least one of and the adjacency ai,k ak,j > 0, k = 1, 2,..., n. matrix a = 1 if there is an edge between i, k and a = 1 if Distance I i,k k,j matrix

there is an edge between k, j. Shortest path 2 and Dijkstra’s I So for ai,j > 0 we need at least one path of exactly length algorithm 2 between i, j. Degree matrix of a graph

I It’s easy to see using for example induction that the same Markov chains is true for Ak , k > 0 as well.

18 / 50 Non-negative Theorem matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 Theorem Connectivity (k) and the If element ai,j of the adjacency matrix A to the power of k is adjacency non zero, there is a path from vertex i to vertex j of exactly matrix Distance length k. In other words: matrix

Shortest path and Dijkstra’s algorithm (k) k ai,j ∈ A ⇒ There is a path of length k from vertex i to vertex j Degree matrix of a graph

Markov chains

19 / 50 Non-negative Application, road network and adjacency matrix matrices and graphs MAA704

Christopher Engstr¨om While we can compute all of A, A2, A3,..., Ak for some large lecture 2 k and see if any ai,j > 0 for any k, there is a better way. Connectivity We notice that if we let every vertex link to itself, and if and the I adjacency there is a path of length k from one vertex to another, matrix then there is a path of length k + 1 as well, simply by Distance matrix

looping in the last vertex once. Shortest path and Dijkstra’s I Additionally the longest possible path is n − 1, since after algorithm traveling to n − 1 new vertices we need to return to one Degree matrix we have already visited. of a graph Markov chains I Looking at the elements of (I + A)n−1 we can thus see if there is at least one path between any two vertices.

20 / 50 Non-negative Irreducible non-negative matrices. matrices and graphs MAA704

Christopher Engstr¨om

Theorem lecture 2 Connectivity A non-negative square n × n matrix A is said to be irreducible and the adjacency if any of the following equivalent properties is true: matrix 1. The graph corresponding to A is strongly connected. Distance matrix

2. For every pair i, j there exists a natural number m such Shortest path m and Dijkstra’s that ai,j > 0. algorithm n−1 3.( I + A) is a positive matrix. Degree matrix of a graph

4. A cannot be conjugated into a block upper triangular Markov chains matrix by a P.

21 / 50 Non-negative Irreducible non-negative matrices matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity and the Irreducible non-negative matrices and their properties are used adjacency extensively in for example: matrix Distance I Perron-Frobenius theory. matrix Shortest path I processes. and Dijkstra’s algorithm Markov chains and monte carlo. I Degree matrix of a graph

Markov chains

22 / 50 Non-negative Vertex and edge connectivity matrices and graphs MAA704

Christopher Engstr¨om

Even if the graph is strongly connected it might not be very lecture 2 Connectivity well connected or it might be interesting to see how easy it is and the adjacency to divide the graph in two disjoint parts. matrix I The vertex connectivity of a graph is the minimum Distance matrix number of vertices removal which makes the graph not Shortest path strongly connected anymore. and Dijkstra’s algorithm I The edge connectivity of a graph is the minimum Degree matrix number of edges removal which makes the graph not of a graph strongly connected anymore. Markov chains

23 / 50 Non-negative Distance matrix matrices and graphs While good to know whether there exists a path between two MAA704 Christopher vertices, the adjacency matrix says nothing of the length of Engstr¨om those paths. lecture 2 To do this we introduce (positive) weights on the edges I Connectivity representing the distance between two cities. and the adjacency I This gives weighted graph such as: matrix Distance B matrix Shortest path and Dijkstra’s 0.5 algorithm 1 Degree matrix of a graph A C Markov chains 2 1

D

24 / 50 Non-negative Distance matrix matrices and graphs MAA704

Christopher To represent this weighted graph we only need to make a short Engstr¨om modification of the adjacency matrix: lecture 2 Definition Connectivity and the The distance matrix D of a graph G with n vertices and adjacency matrix weighted edges E is a square n × n matrix with elements di,j Distance such that: matrix Shortest path  and Dijkstra’s Ei,j , if there is a link from vertex i to vertex j, di,j = algorithm 0, otherwise, Degree matrix of a graph Where Ei,j is the weight of the edge from vertex i to vertex j. Markov chains As with the adjacency matrix, if the graph is undirected we consider every edge between two vertices as linking in both directions.

25 / 50 Non-negative Distance matrix matrices and graphs MAA704

Christopher Engstr¨om Here is an example of the previous graph and corresponding distance matrix. lecture 2 Connectivity B and the adjacency matrix 0.5 Distance 1   matrix 0 0.5 2 1 Shortest path A C 0.5 0 1 0 and Dijkstra’s 2 D =   algorithm  2 1 0 0 Degree matrix 1 1 0 0 0 of a graph Markov chains

D

26 / 50 Non-negative Weighted graphs and applications matrices and graphs MAA704

Christopher Engstr¨om A weighted graph and it’s distance matrix can for example be used to represent: lecture 2 Connectivity I Distance between physical objects or some other defined and the adjacency distance, or time needed to travel from one vertex to matrix another. Distance matrix I Electrical networks, where the weights represent the Shortest path and Dijkstra’s resistance over the wires. algorithm Water flow network with capacities represented by the Degree matrix I of a graph weights. Markov chains I Markov processes and random walks where the weights represent a to move from one state to another.

27 / 50 Non-negative Distance matrix and applications matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 Using the distance matrix we can do the same analysis as we Connectivity did for the adjacency matrix to for example see if the matrix is and the adjacency irreducible. matrix However the distance matrix can also be used in for example: Distance matrix I Finding the shortest path between two or more vertices. Shortest path and Dijkstra’s I Finding stationary distributions, hitting times, hitting algorithm , and much more for Markov chains. Degree matrix of a graph I Calculating the potential of electrical networks. Markov chains

28 / 50 Non-negative Application: shortest path matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 I A common algorithm to find the shortest distance between Connectivity one source node and one or all other nodes is Dijkstra’s and the adjacency algorithm. matrix

Distance I It works by assigning a distance from the initial node to matrix

every other node and then travel through the graph by Shortest path and Dijkstra’s always choosing the next node among the unvisited nodes algorithm

that minimizes the distance. Degree matrix of a graph At every node it updates the distance to every node linked I Markov chains to by the current node.

29 / 50 Non-negative Application: Dijkstra’s algorithm matrices and graphs MAA704

Christopher More exact the method works through the following steps: Engstr¨om 1. Assign a zero distance to initial node and infinity to all lecture 2 other nodes. Connectivity and the 2. Mark all nodes as unvisited and set the initial node as the adjacency current node. matrix Distance 3. For the current node, calculate the distance to all it’s matrix unvisited neighbors by adding the current distance plus the Shortest path and Dijkstra’s distance to the neighbors. Update these nodes distance if algorithm Degree matrix the newly found distance is lower. of a graph 4. Mark current node as visited. Markov chains 5. If the smallest distance among the unvisited nodes is infinity: stop! Otherwise set the unvisited node with the smallest distance as current node and go to step 3.

30 / 50 Non-negative Application: Dijkstra’s algorithm matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity Think about the following and if or how it effects the and the usefulness of Dijkstra’s algorithm. adjacency matrix What happens if there are negative weight’s in the graph. Distance I matrix I What if the graph is directed? Should a transportation Shortest path and Dijkstra’s network be considered directed? algorithm

Degree matrix I What if the graph is irreducible? What if it isn’t? of a graph

Markov chains

31 / 50 Non-negative Degree matrix of a graph matrices and graphs The Laplacian matrix of a graph is very useful for finding a MAA704 Christopher number of useful properties of a graph. To find the laplacian Engstr¨om matrix we first need to know the degree matrix: lecture 2 I The degree matrix of an undirected graph is a diagonal Connectivity and the matrix where the elements on the diagonal is the number adjacency of edges connected with that node. matrix Distance I In other words given a graph G with n nodes the degree matrix matrix D is a n × n matrix with elements: Shortest path and Dijkstra’s algorithm  deg(i), i = j d := Degree matrix i,j 0, i 6= j of a graph Markov chains Where deg(i) is the number of edges connected with vertex vi . I If there are loops present (nodes linking to itself) we count those twice for the degree. 32 / 50 Non-negative Degree matrix of a graph matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity If the graph is directed we make the following modifications: and the adjacency I We use either in-degree (number of links from other nodes matrix to target node) or out-degree (number of links from node Distance matrix

to other nodes). Shortest path and Dijkstra’s I Which one we use depend on the application. algorithm We do not count loops twice if the graph is directed. Degree matrix I of a graph

Markov chains

33 / 50 Non-negative The degree matrix: undirected graph matrices and graphs MAA704

Christopher Degree matrix of an undirected graph. Engstr¨om

lecture 2

Connectivity and the 2 adjacency matrix

Distance matrix   Shortest path 3 0 0 0 and Dijkstra’s 1 4 0 4 0 0 algorithm D =   Degree matrix 0 0 1 0 of a graph

0 0 0 2 Markov chains

3

34 / 50 Non-negative The degree matrix: directed graph matrices and graphs MAA704

Christopher Degree matrix using in-degree. Engstr¨om

lecture 2

Connectivity and the 2 adjacency matrix

Distance matrix   Shortest path 2 0 0 0 and Dijkstra’s 1 4 0 3 0 0 algorithm D =   Degree matrix 0 0 1 0 of a graph

0 0 0 0 Markov chains

3

35 / 50 Non-negative Laplacian matrix matrices and graphs MAA704

Christopher Engstr¨om Let L be the matrix of a graph with no self loops. Then the Laplacian matrix is defined by, lecture 2 Connectivity and the L := D − A adjacency matrix

Distance where D is the degree matrix and A is the adjacency matrix. matrix This gives elements li,j ∈ L: Shortest path and Dijkstra’s algorithm  deg(i), i = j Degree matrix  of a graph li,j := −1, i 6= j, vi links to vj  0, otherwise Markov chains

Where deg(i) is the number of edges connected with vertex vi .

36 / 50 Non-negative Permutation matrices. matrices and graphs MAA704

Christopher Engstr¨om

lecture 2 Definition Connectivity and the A permutation matrix is a with exactly one adjacency matrix element equal to 1 in every row and column and 0 elsewhere. Distance matrix

I Permutation matrices are used to flip the position of Shortest path and Dijkstra’s individual rows or columns of a matrix. algorithm What happens when we multiply a permutation matrix Degree matrix I of a graph with another square matrix? Markov chains

37 / 50 Non-negative Permutation matrices. matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity Multiplying P with A from the left permutes the rows of and the I adjacency A according to the rows of P: matrix       Distance 0 1 0 0 a a a a b b b b matrix 0 0 1 0 b b b b c c c c Shortest path PA =     =   and Dijkstra’s 1 0 0 0 c c c c a a a a algorithm 0 0 0 1 d d d d d d d d Degree matrix of a graph

Markov chains

38 / 50 Non-negative Permutation matrices. matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity Multiplying P with A from the right permutes the columns and the I adjacency of A acording to the columns of P: matrix       Distance a b c d 0 1 0 0 c a b d matrix a b c d 0 0 1 0 c a b d Shortest path AP =     =   and Dijkstra’s a b c d 1 0 0 0 c a b d algorithm a b c d 0 0 0 1 c a b d Degree matrix of a graph

Markov chains

39 / 50 Non-negative Permutation matrices. matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity What if we want to permute the same row and column of and the I adjacency a matrix A according to the rows of P? matrix > Distance I We multiply A with P from the left and with P from the matrix > right. Why P ? Shortest path and Dijkstra’s I We need to multiply with P> since multiplying with P algorithm Degree matrix from the right permutes according to the rows of P. of a graph

Markov chains

40 / 50 Non-negative Permutation matrices and graphs matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity and the adjacency If we multiply a graph A with a permutation matrix: PAP> we matrix Distance only change the order of the nodes! The graph itself looks the matrix same, only our matrix representation have changed. Shortest path and Dijkstra’s algorithm

Degree matrix of a graph

Markov chains

41 / 50 Non-negative Permutation matrices and graphs matrices and graphs 0.5 MAA704   Christopher 0 1 1 Engstr¨om A = 0 0.5 0 B 2 0 0 lecture 2 Connectivity 1 and the adjacency matrix

1 Distance A C matrix Shortest path 2 and Dijkstra’s algorithm

Degree matrix of a graph 0 1 0 0.5 0 0 Markov chains > P = 0 0 1 ⇒ PAP =  0 0 2 1 0 0 1 1 0 Both matrices represent the graph but with a different ordering of the vertices. 42 / 50 Non-negative Stochastic matrices matrices and graphs MAA704 We begin with the definition of a . Christopher Engstr¨om I A row stochastic matrix is a non-negative matrix where each row sum to one. lecture 2 Connectivity and the I A column stochastic matrix is a non-negative matrix where adjacency each column sum to one. matrix Distance I If it is both row and column stochastic we say that it is matrix doubly stochastic. Shortest path and Dijkstra’s I We will from now on, only say stochastic matrix when we algorithm Degree matrix in fact mean row stochastic matrix. of a graph

Markov chains

I Permutation matrices are doubly stochastic since only one element in every row and column is non-zero and that element is one.

43 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs MAA704

Christopher Definition Engstr¨om A markov chain is a random process with usually a finite lecture 2 number of states which continually transitions from one state Connectivity and the to another. The transitions are memoryless in that they only adjacency matrix

depend on the current state and not on any previous state. Distance matrix

I Formal definition of a discrete time Markov chain: Shortest path and Dijkstra’s algorithm P(Xn+1 = x|X1 = x1, X2 = x2,..., Xn = xn) Degree matrix of a graph = P(Xn+1 = x|Xn = xn) Markov chains I Every stochastic matrix defines a Markov chain and every Markov chain defines a stochastic matrix.

44 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs MAA704

Christopher As an example of a Markov chain, let us consider this simple Engstr¨om

weather model: lecture 2 I We know the weather on day zero to be sunny. Connectivity and the adjacency I If it’s sunny one day it will be sunny the next with matrix

probability 0.7, cloudy with probability 0.2 and rainy with Distance probability 0.1. matrix Shortest path I If it’s cloudy it will be sunny with probability 0.3, cloudy and Dijkstra’s algorithm with probability 0.4 and rainy with probability 0.3. Degree matrix I If it’s rainy it will be sunny with probability 0.2, cloudy of a graph with probability 0.3 and rainy with probability 0.5. Markov chains I This is quite hard to follow in text, but since it’s a markov chain we can write its graph and stochastic matrix.

45 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs The weather model on the previous slide is written in matrix MAA704 Christopher form, with corresponding directed graph below. Engstr¨om

0.7 0.2 0.1 lecture 2 Connectivity 0.3 0.4 0.3 and the adjacency 0.2 0.3 0.5 matrix

Distance matrix 0.7 0.4 Shortest path and Dijkstra’s algorithm

Degree matrix 0.2 of a graph sunny cloudy 0.3 Markov chains 0.1 0.3 0.2 0.3 rainy 0.5

46 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs MAA704

Christopher If it is cloudy today, what is the probability of rain tomorrow? Engstr¨om I If we want to know this probability we simply multiply lecture 2 Connectivity with our initial distribution (probability 1 to be cloudy) and the > adjacency x0 = [0 1 0] with P and look at the corresponding matrix element. Distance matrix > > Shortest path 0 0.7 0.2 0.1 0.3 and Dijkstra’s algorithm x> = x>P = 1 0.3 0.4 0.3 = 0.4 1 0       Degree matrix 0 0.2 0.3 0.5 0.3 of a graph Markov chains I And we see there is a probability 0.3 that it will be raining tomorrow.

47 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs MAA704

Christopher Engstr¨om I If we wanted the probability of rain a week from now, we > > 7 would repeat the same calculation 7 times (x7 = x0 P ). lecture 2 Connectivity I In some literature they instead work with column and the adjacency stochastic matrices, column vectors and swap the order of matrix > n multiplication (xn = (P ) x0), this gives the exact same Distance results. matrix Shortest path If you need a high power it is often useful to diagonalize P and Dijkstra’s I algorithm

rather to save computation time. Degree matrix of a graph I For larger matrices it is preferred to calculate n vector × Markov chains matrix multiplications over calculating Pn itself since matrix × matrix multiplications are much more computationally expensive.

48 / 50 Non-negative Stochastic matrices: Markov chains matrices and graphs MAA704

Christopher Engstr¨om What if we wanted to know the mean probability that a day is lecture 2 rainy over a long time? Connectivity and the I This is the stationary distribution x such that Ax = λx. adjacency matrix This should be recognised as a eigenvalue λ and its I Distance eigenvector x belonging to A. matrix Shortest path I But since we work with probabilities, how can we and Dijkstra’s guarantee that x is non-negative? algorithm Degree matrix I Can we know if there exists only one stationary of a graph distribution x? Or any at all? Markov chains I What about λ? can we say anything about it?

49 / 50 Non-negative Next lecture matrices and graphs MAA704

Christopher Engstr¨om

lecture 2

Connectivity Next lecture we will look at: and the adjacency I Perron-Frobenius and properties of non-negative matrices. matrix Distance I Markov chains, stochastic matrices and relation to graph matrix theory. Shortest path and Dijkstra’s I Using Perron-Frobenius theory for stochastic matrices and algorithm applications of stochastic matrices. Degree matrix of a graph

Markov chains

50 / 50