2.3 Representing a network: adjacency matrices — Practise
Work independently. The questions and answers are shown together at the end.
State the vertex order before you write any matrix. A different order is a different matrix for the same network, and it is the commonest way to lose marks here.
- A network has vertices , , , and edges , , , . Write down its adjacency matrix, with the vertices in the order .
- For the matrix in the previous question, find the degree of by adding the entries in its row.
- In an undirected network's adjacency matrix, the entry in row , column is . What is the entry in row , column , and why?
- For the network with adjacency matrix , how many edges has it, and what is the sum of all the entries?
- A directed network has arrows , , and , with vertices in the order . Write its adjacency matrix.
- For that directed network, find the out-degree of and the in-degree of from its adjacency matrix.
- A weighted network has vertices with km, km and km. Write down the weighted adjacency matrix.
- A network has no loops. Explain how to read the degree of a vertex from the adjacency matrix, and state what changes if the network has a loop.
Answers and concise solutions
1. Show the answer
1. Adjacency matrix
Answer: . The entry in row , column is when the two vertices are joined and when they are not.
2. Show the answer
2. Degree of C
Answer: Row is , which adds to . In an adjacency matrix the sum of a row is the degree of that vertex.
3. Show the answer
3. The mirrored entry
Answer: It is also . An edge in an undirected network runs both ways, so if is joined to then is joined to . The adjacency matrix is therefore symmetric: the entry in row , column always equals the entry in row , column .
4. Show the answer
4. Number of edges, then the entry sum
Answer: Every row sums to , so each vertex has degree . Then : it is the triangle on three vertices. The sum of all the entries is , which is twice the number of edges — the same handshake lemma read off the matrix.
5. Show the answer
5. Adjacency matrix
Answer: . The entry in row , column is when there is an arrow from to , so the matrix is not symmetric: there is an arrow but not .
6. Show the answer
6. Out-degree, then in-degree
Answer: Row is and adds to , so the out-degree is . Column is and adds to , so the in-degree is . A row gives the out-degree; a column gives the in-degree.
7. Show the answer
7. Weighted adjacency matrix
Answer: . The entry is the weight of the edge, not , and still means there is no edge. A weighted adjacency matrix is symmetric for an undirected network, exactly as the unweighted one is.
8. Show the answer
8. Reading the degree
Answer: With no loops, the degree of a vertex is the sum of its row (or, in an undirected network, its column, since the matrix is symmetric). A loop changes this: it appears on the diagonal as a , but it contributes to the degree because it leaves and arrives. So in a network with loops, the row sum is not the degree — add the diagonal entries separately.