If one road near Galway closes, can you always find another way home?
If one road near Galway closes, can you always find another way home? On a small road map, some closures just mean a detour. Others cut off a whole group of junctions. How can you tell which is which?
Each junction is a vertex, or node, and each road is an edge. With no arrows, the roads are two-way and the graph is undirected. If you model a one-way road in a directed graph, draw it as an arrow called an arc. The four kilometres on C D is that edge's weight.
Trace A to B, back to A, then on to C and D. Every move follows a road, so that's a walk, even though A appears twice. Now trace A to B to C to D. Each junction appears just once. That's a simple path.
The roads join A to B, B to C, C to A, and C to D. Which route gets you from A to D without visiting any junction twice? Pick one and check each move.
Follow the road from A to B, then from B to C. The road from C back to A closes the loop. That makes a cycle: you return to your starting junction, with no other junction repeated and no road used twice.
B and E share no road. You might think that means the graph is disconnected. Trace B through C and D to E. Each triangle is connected, and C D links them, so every pair has a path. Remove C D and the triangles separate. C D is a bridge.
Take just roads A B and B C. In the adjacency matrix, use A, B, C in order for rows and columns. From each row to each column, write one for a direct road and zero otherwise. To redraw this two-way map, use the ones above the diagonal: A B and B C.
Multiply row A by column C, pairing entries and adding the products. Each product tests one possible middle junction, in order: A, B, C. Only B works, so there's one walk of exactly two roads from A to C. Use the same rule for each row and column to fill the square.
Now the only roads are A B, B C, C D and D A, all two-way. Count walks from A to C that use exactly two roads. What goes in row A, column C of the squared adjacency matrix? Pick a number.
For the original six-junction map, enter its adjacency matrix in columns A to F, rows one to six, in letter order. Use the spreadsheet function M MULT to square it. In an exam, interpret row two, column four: one walk of exactly two roads, from B through C to D.