Leaving Certificate Applied Mathematics2.3 Representing a network: adjacency matrices

All books

2.3 Representing a network: adjacency matrices — Learn

Prerequisites: Section 2.1 — degree; Section 2.2 — directed networks.

Objectives: write a network as an adjacency matrix; read a network back out of one; use row sums for degree and out-degree, and column sums for in-degree.

By the end of this section you can turn any network into a table of numbers and back again, so that a computer can work on it.

A picture is not a list of numbers

A drawing of a network is quick for you to read and hard for a computer. A table of numbers is the opposite. The adjacency matrix is the table, and it holds exactly the same information as the drawing.

Number the vertices, in a fixed order, 1,2,…,n1, 2, \dots, n. Then build an n×nn \times n table. The entry in row ii, column jj is:

That is all. The matrix is adjacent vertices that are joined, which is where the name comes from.

Example 1. A network has vertices A,B,C,DA, B, C, D and edges ABAB, ACAC, BCBC, CDCD. Write its adjacency matrix, in the order A,B,C,DA, B, C, D.

Go through the rows one at a time.

  • Row AA: joined to BB and to CC, not to AA or DD → 0,1,1,00, 1, 1, 0
  • Row BB: joined to AA and to CC → 1,0,1,01, 0, 1, 0
  • Row CC: joined to AA, BB and DD → 1,1,0,11, 1, 0, 1
  • Row DD: joined to CC only → 0,0,1,00, 0, 1, 0
(0110101011010010)\begin{pmatrix} 0&1&1&0\\ 1&0&1&0\\ 1&1&0&1\\ 0&0&1&0 \end{pmatrix}

The order of the vertices matters. Write it down before you start, because a different order gives a different matrix for the same network.

Reading the network back out

Every entry tells you about a pair of vertices, so the matrix contains the whole network.

Example 2. Use the matrix above to find the number of edges.

Each row sums to the degree, so the degrees are 2,2,3,12, 2, 3, 1, adding to 88. The sum of all the entries is 88, so

E=82=4E = \frac{8}{2} = 4

where EE is the number of edges. That matches the four edges listed.

Directed networks

For a directed network the entry in row ii, column jj is 11 when there is an arrow from ii to jj. The matrix need not be symmetric, because an arrow one way does not imply an arrow the other way.

Example 3. A directed network has arrows A→BA \to B, A→CA \to C, B→CB \to C and C→AC \to A, with the vertices in the order A,B,CA, B, C.

(011001100)\begin{pmatrix} 0&1&1\\ 0&0&1\\ 1&0&0 \end{pmatrix}

Row AA is 0,1,10,1,1, so the out-degree of AA is 22. Column AA is 0,0,10,0,1, so the in-degree of AA is 11. Notice the matrix is not symmetric: the entry in row AA, column CC is 11, but the entry in row CC, column AA is also 11 here — check the other pair. The entry in row BB, column AA is 00 while row AA, column BB is 11, and that pair is what breaks the symmetry.

Weighted networks

If the edges carry weights, put the weight in the matrix instead of 11. A 00 still means there is no edge.

Example 4. A weighted network has PQ=5PQ = 5 km, PR=2PR = 2 km and QR=7QR = 7 km. With the order P,Q,RP, Q, R the matrix is

(052507270)\begin{pmatrix} 0&5&2\\ 5&0&7\\ 2&7&0 \end{pmatrix}

This is called the weighted adjacency matrix. In a weighted network the row sum is the sum of the weights of the edges at that vertex, not the degree — the degree still counts edges, which is a different question.

Progress check

Back to the chapter problem. Take your seven-room network and number the rooms 11 to 77 in some fixed order. Write down its adjacency matrix, then use it to answer two questions without looking at the drawing.

What is the degree of each room? Read the row sums. How many possible cable runs are there in total? Halve the sum of all the entries. Both answers came out of the numbers alone, which is the point of the matrix: Section 2.4 multiplies it, and Section 2.8 searches it.

You should now be able to

Settings

Colour scheme

Light or dark pages. Your colour and layout stay the same.

Colour

The paper, ink and lettering. Your layout stays the same.

Quiet colours
Bold colours
Layout

How pages are arranged. Your colours stay the same.

Reading offline

Keep this book on this device and read it offline.