- How do I write the adjacency matrix of a graph?
- An adjacency matrix has entry a_ij equal to the number of edges from vertex i to vertex j, with the vertices listed in the same fixed order for rows and columns. For an undirected graph with edges PQ, PR, QR and RS, row P is (0, 1, 1, 0). Each edge works both ways, so the matrix is symmetric about the leading diagonal.
- How do I count the walks of a given length between two vertices?
- The (i, j) entry of boldsymbolA^(k) is the number of walks of length k from i to j. Read the row for the start vertex and the column for the end vertex. For the same graph, the walks of length 3 from P to R are row P of boldsymbolA² times column R of boldsymbolA, which is (2, 1, 1, 1) · (1, 1, 0, 1) = 4 walks.
- What is the difference between walks of at most k edges and walks of fewer than k edges?
- For walks of at most k edges, add the matrices boldsymbolA + boldsymbolA² + ⋯ + boldsymbolA^(k), because "at most 3" includes length 3. For walks of fewer than k edges, stop one power earlier, at boldsymbolA^(k-1). Read the wording carefully. Walks of fewer than 3 edges from Q to Q total 0 + 2 = 2 walks.
- How do I find the total weight of a walk in a weighted graph?
- The weight of a walk is the sum of the weights of the edges it uses. Set out the graph as a weighted adjacency table, with a dash where there is no edge and each weight mirrored across the leading diagonal for an undirected graph. For depots A, B, C and D with AB = 4, BC = 2 and CD = 5, the walk A, B, C, D has total distance 4 + 2 + 5 = 11 km.
- How do I write the transition matrix for a walker moving around a graph?
- The transition matrix boldsymbolT has entry T_ij equal to the probability of moving from vertex j to vertex i, so every column adds to 1. If d edges leave vertex j, each non-zero entry in column j is 1/d. For the walker on PQ, PR, QR and RS, column R is (1/3, 1/3, 0, 1/3), because R has three edges.
- What mistake do students make when they use powers of an adjacency matrix?
- The (i, j) entry of boldsymbolA³ is not the (i, j) entry of boldsymbolA cubed. It is the number of 3 length walks from i to j, found by matrix multiplication. Likewise, a weighted table must have each weight replaced by 1 to give the adjacency matrix before any powers are taken, because powers of a weighted table do not count walks.