3.15 Adjacency matrices and walksIB Maths: Applications and Interpretation HL: Revision notes
Section 1
Adjacency matrices
The adjacency matrix of a graph with vertices is an matrix whose entry in row , column is the number of edges joining vertex to vertex . For a simple undirected graph the entries are 0 or 1, the leading diagonal is all zeros, and the matrix is symmetric. For a directed graph the entry counts edges from to , so the matrix need not be symmetric. Example: routers with links , , , give Each row sum is the degree of that vertex; for a directed graph a row sum is the out-degree and a column sum is the in-degree.
Putting 1s on the leading diagonal of a simple graph. A 1 there would mean a loop.
Section 2
Walks and powers of the matrix
A walk is a sequence of edges in which each edge starts where the previous one ends; edges and vertices may be repeated. Its length is the number of edges. The key result: the entry of is the number of walks of length from vertex to vertex . Use your GDC to find the power. In the router example, has entry 1, the single walk , and has entry 4. For a directed graph read the entry as walks from the row vertex to the column vertex.
For walks of length 3 you need , not . Use the matrix power on your GDC and read the correct row and column.
Section 3
Walks of at most a given length
To count walks of length at most between two vertices, add the matrices: , and read the entry. Example: for the road network with (villages ), the entries of , and are , and , so there are walks of length at most 3 from to . Walks of length 0 are not counted unless the question says so.
Reading only when the question says 'at most '. You must add the lower powers.
Section 4
Weighted adjacency tables
For a weighted graph the table's entry in row , column is the weight of the edge from to (a cost, distance or time). Where there is no direct edge, write a dash, or sometimes 0, as the question states. For two-way roads the table is symmetric. Example: roads , , , , give Powers of a weighted table do not count walks; to count walks use the unweighted matrix with 0s and 1s.
Say what symbol you used for 'no direct road', and check that the table is symmetric for an undirected graph.
Section 5
Transition matrices
A transition matrix describes moving between states with probabilities. In this course the entry in row , column is the probability of moving from to , so every column sums to 1. For a strongly connected graph, build so that column shows the links leaving vertex (the transpose of a row-from adjacency matrix), then divide each column by its sum, so that each link from a vertex is equally likely. If is the starting state, then . A steady state satisfies with entries summing to 1; this links to Markov chains (AHL 4.19). Example: pages to with ; ; ; give Starting at , after 2 clicks the probabilities are .
Writing the probabilities along rows instead of columns. In this convention each column must sum to 1.
Section 6
PageRank
The Google PageRank algorithm treats web pages as vertices and links as directed edges. A surfer follows links at random, so the surfer's movement is described by a transition matrix. In the long run the probability of being on each page settles to the steady state, and the page rank is this probability: the larger it is, the more important the page. For the four pages above, solving gives , so pages and rank highest. If a page adds a new link, the probabilities in its column are shared among more pages: if linked to both and , column would become .
On the GDC, solve together with 'entries sum to 1', or apply a high power of to a starting vector.
That's the notes covered.
Carry on to the next subtopic.
Exam questions on 3.15 Adjacency matrices and walks
- A network has four routers , , and . The links are , , and , and each link works in both directions. The network is modelled as a graph with the routers as vertices and the links as edges. Let be its adjacency matrix with rows and columns in the order , , , .Use your GDC to find the number of walks of length 4 from to .2 marks
- A delivery company has four hubs , , and with one-way routes , , , and . This is modelled as a directed graph. Let be its adjacency matrix, where the entry in row , column is the number of routes from hub to hub , in the order , , , .Use your GDC to find the number of walks of length 5 from to .2 marks
- Four villages , , and are joined by two-way roads, with distances in km: is 12, is 7, is 5, is 9 and is 4. There are no other roads.Write down the weighted adjacency table for the villages, in the order , , , , using where there is no direct road.3 marks
Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).