Graph Theory for Math Students
Graph Theory for Math Students
Prof. Tesler
Math 154
Winter 2020
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 1 / 42
Related courses
Math 158 and 188: More advanced/theoretical than Math 154 and
184. Recommended only for students with A/A+ in Math 109 or
Math 31CH.
CSE 101: Has some overlap with Math 154, but mostly different.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 2 / 42
Graphs
Computer network Friends
PC1
Irene
Gina Harry
Dan
PC2
Modem ISP Remote server Emily
Frank
PC3 Cindy
Printer
Hard drive Amy Bob
5 2
4 3
G: 1
5 2
4 3
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 5 / 42
Adjacencies
G: 1
5 2
4 3
5 2
4 3
A simple graph is G = (V, E):
V is the set of vertices.
It can be any set; {1, . . . , n} is just an example.
E is the set of edges, of form {u, v}, where u, v ∈ V and u , v.
Every pair of vertices has either 0 or 1 edges between them.
Usually, graph alone refers to simple graph, not to other kinds of
graphs that we will consider.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 7 / 42
Drawings of graphs
1 4
2
5 2
1
4 3 5 3
V = {1, 2, 3, 4, 5}
E = {1, 2} , {2, 3} , {2, 5} , {3, 4} , {3, 5} , {4, 5}
Both drawings represent the same graph (even though they look
different) since they have the same vertices and edges in the
abstract representation G = (V, E).
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 8 / 42
Degrees
1
5 2
4 3
5 2
4 3
Sum of degrees = 1 + 3 + 3 + 2 + 3 = 12
Number of edges = 6
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 10 / 42
The Handshaking Lemma
Lemma
The sum of degrees of all vertices
X is twice the number of edges:
d(v) = 2 |E|
v∈V
Proof.
Let S = { (v, e) : v ∈ V, e ∈ E, vertex v is in edge e }
Count |S| by vertices: Each vertex
X v is contained in d(v) edges, so
|S| = d(v).
v∈V
Equating the two formulas for |S| gives the result. This is a
common method in Combinatorics called counting in two ways.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 11 / 42
Number of vertices of odd degree
1
d(1) = 1
d(2) = 3
5 2 d(3) = 3
d(4) = 2
d(5) = 3
4 3
Lemma
For any graph, the number of vertices of odd degree is even.
E.g., this example has four vertices of odd degree.
Proof.
Since the degrees are integers and their sum is even (2|E|), the
number of odd numbers in this sum is even.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 12 / 42
Multigraphs and pseudographs
a h
1
2
g f b
c
4 d 3
e
a h
1
2
g f b
c
4 d 3
e
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 14 / 42
Multigraphs and pseudographs
a h
1 V = {1, 2, 3, 4}
2 E = {a, b, c, d, e, f , g, h}
g f b φ(a) = {1, 2}
c φ(b) = {2, 3}
4 d 3 φ(c) = φ(d) = φ(e) = {3, 4}
φ(f ) = φ(g) = {1, 4}
e φ(h) = {2}
Represent a multigraph or pseudograph as G = (V, E, φ), where:
V is the set of vertices. It can be any set.
E is the set of edge labels (with a unique label for each edge).
φ is a function from the edge labels to the pairs of vertices:
φ : E → {u, v} : u, v ∈ V
φ(L) = {u, v} means the edge with label L connects u and v.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 15 / 42
Adjacency matrix of a multigraph or pseudograph
Let n = |V|
The adjacency matrix is an n × n matrix A = (auv ).
Entry auv is the number of edges between vertices u, v ∈ V.
a h 1 2 3 4
1
2 1 0 1 0 2
g f b 2 1 2 1 0
A=
c 3 0 1 0 3
4 3 4 2 0 3 0
d
e
In a simple graph:
All entries of the adjacency matrix are 0 or 1 (since there either is
or is not an edge between each pair of vertices).
The diagonal is all 0’s (since there are no loops).
1 1 2 3 4 5
1 0 1 0 0 0
2 1
0 1 0 1
5 2 A= 3 0
1 0 1 1
4 0 0 1 0 1
4 3 5 0 1 1 1 0
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 17 / 42
Directed graph (a.k.a. digraph)
1
5 2
4 3
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 18 / 42
Directed graph (a.k.a. digraph)
1
V = {1, 2, 3, 4, 5}
5 2
E = {(1, 5), (2, 1), (3, 2), (3, 4), (4, 5), (5, 2), (5, 4)}
4 3
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 19 / 42
Degrees in a directed graph
1
5 2
4 3
For a vertex v, the indegree d− (v) is the # edges going into v, and
the outdegree d+ (v) is the # edges going out from v.
v indegree(v) outdegree(v)
1 1 1
2 2 1
3 0 2
4 2 1
5 2 2
Total 7 7
Sum of indegrees = sum of outdegrees = total # edges = |E|
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 20 / 42
Neighborhoods in a directed graph
5 2
4 3
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 21 / 42
Adjacency matrix of a directed graph
1
1 2 3 4 5
1
0 0 0 0 1
5 2 2 1 0 0 0 0
A= 3 0 1 0 1 0
4 0 0 0 0 1
4 3 5 0 1 0 1 0
Let n = |V|
The adjacency matrix of a directed graph is an n × n matrix
A = (auv ) with u, v ∈ V.
Entry auv is the number of edges directed from u to v.
auv and avu are not necessarily equal, so A is usually not symmetric.
The sum of entries in row u is the outdegree of u.
The sum of entries in column v is the indegree of v.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 22 / 42
Directed multigraph
c
1 2 3 4 5
b a
1
e
1 0 0 0 1
5 2 2 1 0 0 0 0
f A= 3 0 1 0 1 0
h
i d 4
0 0 0 0 1
g 5 0 2 0 1 0
4 3
a 20
b n m
c j k
5 2
i h
g e d 10
4 f 3 50 l 30
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 25 / 42
Application: Polyhedra
http://commons.wikimedia.org/wiki/File:Dodecahedron.svg
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 26 / 42
Basic combinatorial counting methods
See appendix. Covered in more detail in Math 184.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 27 / 42
Multiplication rule
Example
How many outcomes (x, y, z) are possible, where
x = roll of a 6-sided die;
y = value of a coin flip;
z = card drawn from a 52 card deck?
(6 choices of x) × (2 choices of y) × (52 choices of z) = 624
Multiplication rule
The number of sequences (x1 , x2 , . . . , xk ) where there are
n1 choices of x1 , n2 choices of x2 , . . . , nk choices of xk
is n1 · n2 · · · nk .
This assumes the number of choices of xi is a constant ni that doesn’t
depend on the other choices.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 28 / 42
Number of subsets of an n-element set
Include 1? ;
No Yes
; {1}
Include 2?
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 29 / 42
Set partitions
How many pairs (m, d) are there where
m = month 1, . . . , 12;
d = day of the month?
Assume it’s not a leap year.
The # days/month varies, so can’t use multiplication rule 12 × .
Split dates into Am = { (m, d) : d is a valid day in month m }:
A = A1 ∪ · · · ∪ A12 = whole year
|A| = |A1 | + · · · + |A12 |
= 31 + 28 + · · · + 31 = 365
Set partition
Let A be a set. A partition of A into blocks A1 , . . . , An means:
A1 , . . . , An are nonempty sets.
A = A1 ∪ · · · ∪ An .
The blocks are pairwise disjoint: Ai ∩ Aj = ∅ when i , j.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 30 / 42
Addition rule
Addition rule
For pairwise disjoint sets A1 , . . . , An :
n
[ X
n
Ai = |Ai |
i=1 i=1
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 31 / 42
Permutations of distinct objects
Here are all the permutations of A, B, C:
ABC ACB BAC BCA CAB CBA
There are 3 items: A, B, C.
There are 3 choices for which item to put first.
There are 2 choices remaining to put second.
There is 1 choice remaining to put third.
Thus, the total number of permutations is 3 · 2 · 1 = 6.
1st letter A B C
2nd letter B C A C A B
3rd letter C B C A B A
Convention: 0! = 1
For integer n > 1, n! = n · (n − 1) · (n − 2) · · · 1
= n · (n − 1)!
so (n − 1)! = n!/n.
E.g., 2! = 3!/3 = 6/3 = 2.
Extend it to 0! = 1!/1 = 1/1 = 1.
0! 1
Doesn’t extend to negative integers: (−1)! = 0 = 0 = undefined.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 33 / 42
Partial permutations of distinct objects
How many ways can you deal out 3 cards from a 52 card deck,
where the order in which the cards are dealt matters?
E.g., dealing the cards in order (A♣, 9♥, 2♦) is counted differently
than the order (2♦, A♣, 9♥).
52 · 51 · 50 = 132600. This is also 52!/49!.
This is called an ordered 3-card hand, because we keep track of
the order in which the cards are dealt.
How many ordered k-card hands can be dealt from an n-card deck?
n!
n(n − 1)(n − 2) · · · (n − k + 1) = = n Pk
(n − k)!
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 34 / 42
Combinations
In an unordered hand, the order in which the cards are dealt does
not matter; only the set of cards matters. E.g., dealing in order
(A♣, 9♥, 2♦) or (2♦, A♣, 9♥) both give the same hand. This is
usually represented by a set: {A♣, 9♥, 2♦}.
How many 3 card hands can be dealt from a 52-card deck if the
order in which the cards are dealt does not matter?
The 3-card hand {A♣, 9♥, 2♦} can be dealt in 3! = 6 different
orders:
(A♣, 9♥, 2♦) (9♥, A♣, 2♦) (2♦, 9♥, A♣)
(A♣, 2♦, 9♥) (9♥, 2♦, A♣) (2♦, A♣, 9♥)
Every unordered 3-card hand arises from 6 different orders.
So 52 · 51 · 50 counts each unordered hand 3! times; thus there are
52 · 51 · 50 52!/49! 52 P3
= =
3·2·1 3! 3!
unordered hands.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 35 / 42
Combinations
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 36 / 42
How many simple graphs are there on n vertices?
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 38 / 42
Complete graph Kn
K5
n
How many edges are in Kn ?
2
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 39 / 42
Bipartite graph
A B
K4,2
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 41 / 42
Path graph and cycle graph
1 2 3 4
P4
2
1 3
C6
6 4
5
Pk (k-path, for k > 1): vertices 1, . . . , k and edges
{1, 2} , {2, 3} , . . . , {k − 1, k}
Ck (k-cycle, for k > 3): vertices 1, . . . , k and edges
{1, 2} , {2, 3} , . . . , {k − 1, k} , {k, 1}
These are specific examples of paths and cycles.
Paths and cycles will be discussed in more generality soon.
Prof. Tesler Ch. 1. Intro to Graph Theory Math 154 / Winter 2020 42 / 42