2.3 Representing a network: adjacency matrices — Practise with help
Warm-up: remember
- A network has edges , , . What is the degree of each vertex?
- Is that network connected, and has it an Eulerian trail?
Answers and feedback
- Every vertex has degree — it is the triangle.
- It is connected, and all degrees are even, so it has an Eulerian circuit.
Practise with help
1. A network has vertices and edges , . Write its adjacency matrix in the order .
Hint
Three vertices, so a matrix. Row has a only in column .
Next step
and are the only edges, so row is and row is .
Full working
Row has two s because is joined to both and . The matrix is symmetric, as an undirected network's must be.
2. For the matrix , find the degree of each vertex.
Hint
Add each row.
Next step
Row 1 is , row 2 is .
Full working
- Vertex 1:
- Vertex 2:
- Vertex 3:
- Vertex 4:
Check the handshake lemma: , so . The matrix has four s in each triangle above and below the diagonal, which is entries in total, so . Both agree.
3. A directed network has arrows , , and . Write its adjacency matrix and find the out-degree of each vertex.
Hint
Row records the arrows leaving .
Next step
Row 1 has arrows to 2 and to 3, so row 1 is .
Full working
Out-degrees are the row sums: . The matrix is not symmetric — the entry in row 1, column 3 is , but row 3, column 1 is while row 2, column 1 is against row 1, column 2 being . Check the in-degrees as a cross-check: the column sums are , and they must add to the same total as the out-degrees, , which they do.
4. A network's adjacency matrix has row sums . How many edges has the network?
Hint
The row sums are the degrees.
Next step
Add them and halve.
Full working
The degrees are , adding to . So
Here is the number of edges.
You did not need the matrix itself — only its row sums. That is the handshake lemma, and it is the quickest way to count edges from a matrix.
5. A weighted network has vertices with , , , . Write the weighted adjacency matrix and find the sum of the weights at .
Hint
Put the weight in the matrix where the would go.
Next step
Row has in column and in column .
Full working
The weights at are . This is the sum of the weights, not the degree of : the degree is , because only two edges meet . Keeping the two ideas apart matters whenever a weighted network is used to answer a route question.
6. A student writes down the adjacency matrix for a network with no loops. Say what is wrong and give the correct matrix.
Hint
What does the diagonal entry represent?
Next step
The diagonal is the vertex joined to itself.
Full working
The in the top-left is on the diagonal, and a diagonal entry means a loop — the vertex joined to itself. The network has no loops, so every diagonal entry must be . The correct matrix is
A diagonal entry is the easiest thing to get wrong when filling a matrix in a hurry, because it is the one entry that is never in a simple network.
A question from Section 2.2
7. The adjacency matrix of a network is symmetric and every row sums to . Is the network connected? Does it have an Eulerian trail?
Hint
The matrix tells you the degrees, not the shape.
Next step
Every degree is , so every degree is even.
Full working
Every vertex has degree , so there are odd-degree vertices. If the network is connected, it has an Eulerian circuit.
But the matrix does not tell you whether it is connected. Two separate triangles each have every row summing to and a symmetric matrix, and neither is connected. The Eulerian test needs connectedness as well, and connectedness is a property of the shape that the adjacency matrix holds only implicitly — you have to read it back out to check.
8. Explain how the handshake lemma appears in an adjacency matrix.
Hint
Count all the s two ways.
Next step
Each edge puts two s in the matrix, one in row column and one in row column .
Full working
An edge between and puts a at and a at — two entries. So the total number of s in the whole matrix is twice the number of edges.
But the total of all the entries is also the total of all the row sums, and a row sum is a degree. So
where is a vertex. This is exactly the handshake lemma. The lemma is not a fact about drawings; it is a fact about the matrix, and that is why it is always true.