Lecture 2 Updated
Lecture 2 Updated
Info: A theorem is usually of the form A ) B , where A ( the hypothesis) is the given
i
conditions for which you can logically deduce the condition B (the conclusion). Please
note the numbering of theorems should not be used in referencing them. Learn the the-
orem statements.
Theorem 1. The graph G = (V; E ), where V = fv1; v2; :::; v g and E = fe1; e2; :::; e g
n m
satises n
d eg (vi ) = 2m:
X
i =1
You can see you have a condition of a graph of order n and size m ( Part A). And if you
have that you can deduce that the sum of all the degrees in the graph will be twice the
size of the graph (Part B). Get into the habit of noting what part of the theorem state-
ment ts the A part and what part ts the B part as this will help you as we progress.
Now lets try proving. Note proving for one example is not a proof ( It is however su-
cient to show the statement is not correct). The proof must provide evidence it holds
for every graph that has the properties of A.
i
Info: This is known as a direct proof. That is given all the conditions provided in part
A, we will get (no matter what) the outcome of part B. Nothing fancy just using the prop-
erties of A and doing some maths to produce the outcome of B. ( Nothing fancy can
include math tricks, the fancy in this situation refers to the technique we use to prove.
We will introduce other techniques soon where you will get more context.)
1
Proof. Let e be any edge in G , say e = v v . k t
Therefore the summation of the degree's is twice the number of edges in the graph.
n
d eg (vi ) = 2m:
X
i=1
Info: A proof shows that the theorem statement you make holds for all possibilities with
those conditions. We will further explore proof types and techniques as we build up skills.
The square block you see at the end is saying the proof is nished. Q.E.D. is also used
for this purpose (it's Latin ).
Info: Note in mathematics in general it is very important to understand the theorem con-
ditions, and the authors denitions used in the conditions. Don't take it for granted that
every mathematician uses the same denitions and theorem statement.
This theorem holds for nite graphs only. This theorem can also be written slightly dif-
ferently remembering one of our denitions.
Theorem 2. If G is a graph having or d er (G ) = n and si z e (G ) = m then
n
i =1
Info: A Corollary is a proposition that follows one that has already been proved.
Proof. If the vertices v1 ; :::; v have odd degrees and the vertices v +1 ; :::; v have even
k k n
2
Example 1. Looking at the theorem and corollary with a graph we have seen before
2si z e (G ) = 2m:
Check : The sum of the degrees is 1 + 2 + 0 + 2 + 5 = 10 = 2(5), the size of the graph
is 5.
Every graph has an even number of vertices of odd degree.
Check: There are two vertices of odd degree, namely v1 and v5 . 2 is an even number.
Connectedness
One of the most important properties of a graph (and therefore a system) is how con-
nected it is. Therefore there are various ways to describe dierent types of connection,
as usual we will look at the basics.
Walk
In other words a walk is a nite sequence of the form v1 e1 v2 e2 :::e n vn+1 , which consists
of alternating vertices and edges of G.
i
Info: Note that you need a labelled graph in order to dene a walk.
3
Example 2. All of the examples below in green below are indicating walks that can be
found in the main graph G.
Figure 2.1: G
Figure 2.3: W al k2 = ed c
Figure 2.4: W al k3 = ed ce
4
i
Info: An easier way is to just state the vertices you visit, there is no ambiguity in re-
gards to simple graphs, there will be ambiguity if the graph has multiple edges.
Denition 2 (length of walk). The length of a walk is the number of edges in the walk.
Example 3. All examples below are taken from the main example
Remembering that you can always relabel your vertices. You can relabel them such that
vertex v1 is the initial vertex of the walk and v +1 the terminal vertex. Then n is the
n
A walk is allowed to visit a vertex and go through an edge more than once.
5
Question 1
Go back to the examples and identify closed walks.
Trail
6
Denition 5 (Circuit). A closed trail is called a circuit.
A closed walk that does not contain repeated edges.
Example 5. Walk 3 and 5 from the main example are examples of circuits.
Figure 5.2: W al k3 = ed ce
Figure 5.1: G
Path
Denition 6 (Path). A walk in which no vertex is repeated, except possibly the initial
and terminal vertex, is called a path.
7
Example 6. Walk 2 and 3 from the main example are examples of Paths.
Figure 6.1: W al k2 = ed c
Figure 6.2: W al k3 = ed ce
Figure 7.1: G
Figure 7.2: W al k3 = ed ce
8
Question 2
9
Every u-v walk contains a u-v path
Theorem 4. If u v is a walk; then you can nd a u v path within the walk.
Proof. Let u v be a walk. If u = v ( closed), then the trivial path is the desired path.
It u 6= v then there are two possibilities.
no repeated vertices
Then the walk is a path.
repeated vertices
If say x is repeated, and x 6= v then let b be the rst vertex on the walk after the
last visitation to vertex x . [For example u:::x :::x b:::v ]
Shorten the walk by skipping to the last time the vertex is repeated.
Producing a shorter walk. u:::x b:::v
You now have a shorter walk in which the analysis and process can be repeated. (
no repeated vertices or repeated vertices)
As the original walk is of nite length you must end with a walk with no repeated
edges.
vertices.Therefore a path.
Example 8.
1 4 3
" #
A=
9 7 5
The rows are horizontal and the columns are vertical. We say A is a 2 3 matrix. We
represent various matrices related terminology by indicating row rst then column.
So individual terms in a matrix are called elements, and they are usually indicated by a ,
ij
where the i is a place holder indicating the row position in the matrix, and j indicating
the column position in the matrix.
10
Example 9.
1 4 3
" #
A=
9 7 5
a1;2 = 4 and a2 3 = 5.
;
When we talk about the size of a matrix we refer to the number of rows and columns.
Example 10. si z e (A) = 2 3
Adjacency Matrix
An adjacency Matrix is a way of describing the graph, the elements of the matrix will
indicate if there is an edge connecting the vertices or not. 1 for there is , 0 for there
isn't. ( With a special note that if parallel edges exist then instead of 1 the number of
edges is used, and the adjacency matrix has two denitions for loops, used depending on
the properties the author wishes to consider)
Example 11.
0 1
A(G ) =
1 0
G
1 (v v ) 2 E (G )
(
if
A(G ) = (a ) = i j
w her e ai j
ij n n
0 other w i se
Note : We tend to arrange vertices in ascending placement in the alphabet and increas-
ing numerical indexing.
i
Info: Technically the rules are slightly dierent for directed vs undirected however the
denition the way it is written here accounts for both.
A nite undirected graph has a symmetric adjacency matrix.
11
Example 12.
0 0 1 1
0 0 0 0
A(G ) =
1 0 0 1
1 0 1 0
G
Question 3
Give the adjacency matrix for the graph shown
The adjacency matrix allows you to determine the order of the graph, size of the graph
and degree of vertices without drawing the graph rst.
Since each row and column is representing a vertex, either the number of rows or
columns will indicate order.
Since the number is indicating that there is a edge connecting vertices, technically
if you add up all the numbers you counting edges twice. To prevent this you can
just count either the upper or lower triangle of the matrix.
Since the numbers are indicating the edge connecting to that vertex adding up
the row (or column) provides the degree of the vertex. That is the row sum is the
degree of that vertex, and the column sum is the degree of that vertex.
Example 13.
12
0 0 1 1
0 0 0 0
A(G ) =
1 0 0 1
1 0 1 0 G
or d er (G ) = 4 , si z e (G ) = 3 , d eg (v2) = 0
Question 4
Determine the order, size, degree of all the vertices, (G ) and (G ) for the graph de-
scribed by the following adjacency matrix :
0 1 1 1
1 0 1 0
A(G ) =
1
1 0 1
1 0 1 0
Finding How many walks of specic length exist using Adjacency Matrix
Theorem 5. Let A(G ) be the adjacency matrix for the graph G . Let k 2 N. Then k 2
N. Then A (G ) = (z ; ) will have z ; representing the number of dierent walks of length
k
i j i j
k from vertex v to v .
i j
Info: Note this theorem requires the adjacency denition to utilise the idea that loops
count 1, technically 2 does not break the theorem as you would have a path from i to
i and a path back from i to i, however in most situations this isn't wanted information,
and thus the denition of an adjacency matrix with loop represented by 1 is used.
Example 14.
13
0 1 1 1 0 0
1 0 1 0 0 0
1 1 0 1 0 0
A(G ) =
1 0 1 0 1 1
0 0 0 1 0 1
0 0 0 1 1 0
4 5 5 7 2 2
5 2 5 2 2 2
5 5 4 7 2 2
3
A (G ) =
7 2 7 4 5 5
2 G
2 2 5 2 3
2 2 2 5 3 2
z2;6 = 2 ( That is the second row and sixth column has an entry of 2). Based on the
denition of powers of the adjacency matrix, it means there are 2 distinct (dierent)
walks from v2 to v6 of length 3. They are v2 ; v3 ; v4 ; v6 and v2 ; v1 ; v4 ; v6 .
Question 5
From the example above, determine the number of walks of length 3 ( and then list the
distinct walks) of :
(a) v4 to v1
(b) v3 to v2
Info: For the purposes of this module the raised power matrices will be given to you due
to the fact math will handle them at a later stage.
14
Question 6
3 2 2 2
2 3 2 2
A2 (G ) =
2
0
1 1 1
2 3 2
1
1 1 0
2 2 2 3
Given : A(G ) =
1
1 0 1 6
7 7 7
1 0 1 1 7
7 7 6
A3 (G ) =
7
7 6 7
7 6 7 7
Find the following :
(a) si z e (G )
(b) d eg (v3 )
Info: Utilising the 2 for a loop, and how it will eect the number of walks of length (al-
tering the question directly above):
3 3 2 3
3 6 3 2
A2 (G ) =
2 3 3 3
0 1 1 1
3 2 3 6
1 2 1 0
A(G ) =
1 1 0 1
8 11 9 11
1 0 1 2
11 18 11 10
A3 (G ) =
9
11 8 11
11 10 11 18
NB: Undirected graphs should be symmetric. Also note from the above why why some
authors will prefer using 1 for a loop in this situation. Look at how drastically the num-
ber of possible walks increase using the two in comparison to the one. In realistic prob-
lems that can make you believe you have tons of options, even though you walking the
same walk.
15
Finding out if a graph is connected using Adjacency Matrix
How can we tell if a graph is connected without drawing it ?
So the raised power of the adjacency matrix tells us how many walks we have of that
length. A connected is a graph where there is a walk between any two vertices. We can
use this to determine if a graph is connected.
We can begin by the adjacency matrix and check for walks of length one, then length 2,
then 3. Adding the matrices together. If we get a matrix with no zero elements we have
a connected graph.
If there exists k 2 N so that A(G ) + A2 (G ) + A3 (G ) + ::: + A (G ) = (b ; ) with b ; =
k
6 0
i j i j
8i ; j then G is connected.
Question 7
Create 3 dierent connected graphs. Write down their adjacency matrix. Then test the
above statement regarding checking connectedness without drawing it. You can use Mat-
lab or any on-line matrix calculator for raising the adjacency matrix to a power. You are
not expected to be able to do this without computational help at this point in your math-
ematical career. PS newer scientic calculators can input up to 4 by 4 matrices. Check
your manuals!
Incidence Matrix
A incidence matrix is a way of describing the graph, the elements of the matrix will in-
dicate if the vertex is connected to the edge. Note with the adjacency matrix the rows
and columns represented the vertices. With an incidence matrix the rows are the ver-
tices, the columns the edges. The 1 is if that vertex is connected to that edge, 0 if it is
not.
Denition 10. Incidence matrix
Let G be a labelled simple undirected graph of order n. Then the incidence matrix I(G)
is
1
(
i f vi bel ongs to ej
I (G ) = (a ) w her e ai j =
ij n m
0 other w i se
16
i
Info: There are a few dierences in the denition if you have a directed graph (which
we haven't gotten to yet), the denition will change a bit. For example, the steps for
setting up the incidence matrix (including direction) :
If a given k th
node has outgoing edge, then we will write +1
If a given k th
node has incoming edge, then we will write -1
Rest other branches will be considered 0
The incidence matrix allows you to determine the order of the graph,the size of the
graph and the degree of the vertices without drawing the graph rst.
The size of the matrix is dependent on the number of vertices and the number
of edges. The n will give the order of the graph. The m will give the size of the
graph. ( Note the dierence between size of graph and size of matrix)
Adding up the row provides the degree of the vertex. ( Note only the row sum pro-
duces this now)
Adding up the column should equal 2. ( Think about the why !)
Example 15.
e1
1 1 0
e2 e3
0 0 0
I (G ) =
1 0 1
0 1 1
G
or d er (G ) = 4 , si z e (G ) = 3 , d eg (v2) = 0, d eg (v3) = 2
17
Question 8
Give the incidence matrix for the graph shown
Info: FYI an online tool I like to use sometimes, which is great for creating your own prob-
lems to conrm concepts (or gain a bit more clarity) can be found at https://graphonline.ru/en/
, it's pretty straight forward to use. Obviously some individuals would not use it to boost
their understanding but cheat, that's literally just hurting yourself so I'm going to share
it anyway for those who want to understand and play with the content.
18