Graph
• graph is a pair (π, πΈ) of two sets where
– π = set of elements called vertices (singl. vertex)
– πΈ = set of pairs of vertices (elements of π) called edges
• Example: πΊ = (π, πΈ) where
π = * 1, 2, 3, 4 +
πΈ = * *1, 2+, *1, 3+,
*2, 3+, *3, 4+ +
1
3
4
2
drawing of πΊ
• Notation:
– we write πΊ = (π, πΈ) for a graph with vertex set π and edge set πΈ
– π(πΊ) is the vertex set of πΊ, and πΈ(πΊ) is the edge set of πΊ
Types of graphs
• Undirected graph
1
πΈ = **1,2+, *1,3+,
*2,3+, *3,4++
3
2
4
1
1
2
1
3
1
2
3
1
1
4
1
1
4
1
1
1
1
1
2
3
1
1
2
3
4
1
1
1
4
(IRREFLEXIVE) RELATION
πΈ(πΊ) = set of ordered pairs
• Multigraph
• Pseudograph (allows loops)
SYMMETRIC
1
2
πΈ(πΊ) = set of unordered pairs
2
πΈ = *(1,2), (2,3),
(1,3), (3,1),
(3,4)+
3
4
1
SYMMETRIC & IRREFLEXIVE
πΈ = **1,2+, *1,3+, *2,2+,
*2,3+, *3,3+,
1
*3,4++
3
4
• Directed graph
2
3
1
1
2
1
1
1
3
1
1
1
4
0
4
1
3
1
1
loop = edge between vertex and itself
πΈ = **1,2+, *1,3+, *1,3+, *1,3+, 2,3 ,
2,3 , *3,4+, *3,4+, *3,4+, *3,4++
2
4
?
πΈ(πΊ) is a multiset
1
1
2
1
3
3
4
2
3
1
3
4
2
2
4
4
More graph terminology
• simple graph (undirected, no loops, no parallel edges)
for edge *π’, π£+οπΈ(πΊ) we say:
1 is adjacent to 2 and 3
– π’ and π£ are adjacent
1
N(1) = *2,3+
– π’ and π£ are neighbours
3
4
N(2) = *1,3+
2
– π’ and π£ are endpoints of *π’, π£+
N(3) = *1,2,4+
deg(3) = 3
N(4) = *3+
– we write π’π£οπΈ πΊ for simplicity
deg 4 = 1
deg(1) = deg(2) = 2
• N(π£) = set of neighbours of π£ in G
• deg(π£) = degree of v is the number of its neighbours, ie. |N(π£)|
1
3
2
=
≠
1
1
3
2
3
2
≅
1
3
2
π(1) = 2
π(2) = 3
π(3) = 1
πΊ1 = (π1 , πΈ1 ) is isomorphic to πΊ2 = (π2 , πΈ2 ) if there exists a bijective
mapping π: π1 → π2 such that π’π£οπΈ(πΊ1 ) if and only if π π’ π(π£)οπΈ(πΊ2 )
Isomorphism
3
3
3
1
2
3
2
4
4
6
≅
5
6
3
3
3
(3,3,3,3,3,3)
degree sequence
2
≅
1
4
3
5
3
5
(3,3,3,3,3,3)
if π is an isomorphism
ο deg(π’) = deg(π(π’))
6
1
(3,3,3,3,3,3)
≅
i.e., isomorphic graphs have
same degree sequences
only necessary not sufficient!!!
(3,3,3,3,2,2,2,2)
(3,3,3,3,2,2,2,2)
Isomorphism
How many pairwise non-isomorphic graphs on π vertices are there?
1
1
3
3
2
2
1
1
1
3
3
2
1
3
2
1
1
3
2
2
3
3
2
2
all graphs
(labeled)
non-isomorphic graphs
(without labels)
the complement of πΊ = (π, πΈ) is the graph πΊ = (π, πΈ ) where
πΈ = π’, π£ *π’, π£+οπΈ+
3
3
πΈ(πΊ) = **1,2+, *2,3+, *3,4+, *4,5++
2
4
2
4
πΈ(πΊ ) = **1,3+, *1,4+, *1,5+, *2,4+,
*2,5+, *3,5++
1
5
1
5
πΊ
πΊ
Isomorphism
How many pairwise non-isomorphic graphs on π vertices are there?
≅
self-complementary graph
Isomorphism
• Are there self complementary graphs on 5 vertices ?
3
3
1 → 1, 2 → 4, 3 → 2
4 → 5, 5 → 3
2
4
2
4
• ... 6 vertices ?
1
5
1
5
1 → 2, 2 → 5, 3 → 3
4 → 1, 5 → 4
No, because in a self-complementary graph πΊ = (π, πΈ)
|π|
|πΈ| = |πΈ | and πΈ + πΈ =
1
2
6
but
= 15 is odd
5
2
7
No,
since
= 21
• ... 7 vertices ?
8
2
• ... 8 vertices ?
Yes, there are 10
1 → 4, 2 → 6, 3 → 1, 4 → 7
5 → 2, 6 → 8, 7 → 3, 8 → 5
Yes, 2
4
2
6
7
3
deg(1) = 2
deg(2) = 2
deg(3) = 3
deg 4 = 1
Handshake lemma
Lemma. Let πΊ = (π, πΈ) be a graph with π edges.
deg π£ = 2π
1
3
2
4
π=4
π£∈π
Proof. Every edge *π’, π£+ connects 2 vertices and contributes to
exactly 1 to deg(π’) and exactly 1 to deg(π£). In other words, in
π£∈π deg(π£) every edge is counted twice. οΏ
2
How many edges has a graph with degree sequence:
- (3,3,3,3,3,3) ?
- (3,3,3,3,3) ?
- (0,1,2,3) ?
4
6
1
3
5
Corollary. In any graph, the number of vertices of odd degree is even.
Corollary 2. Every graph with at least 2 vertices has 2 vertices of the same degree.
Handshake lemma
Is it possible for a self-complementary graph with 100
vertices to have exactly one vertex of degree 50 ?
πΊ
Answer. No
π isomorphism
between πΊ and πΊ
N(π’)
π’
π£ is a unique vertex
of degree 49 in πΊ
the degree seq. of πΊ and πΊ
(… , … , … , 50,49, … , … , … )
π’π£ ∈ πΈ(πΊ) ο π(π’)π(π£) ∈ πΈ(πΊ )
definition of isomorphism
∃π£, π(π£) = π’
π’
50
π£
πΊ
π(πΊ)\N(π’)
49
we conclude π(π’) = π£
but π(π’)π(π£) = π£π’ ∈ πΈ(πΊ ) ο π’π£ ∈ πΈ(πΊ)
definition of complement
NπΊ (π’)
49
οΏ
Subgraphs
Let πΊ = (π, πΈ) be a graph
• a subgraph of πΊ is a graph πΊ′ = (π′, πΈ′) where π ′ ο π and πΈ ′ ο πΈ
• an induced subgraph (a subgraph induced on π΄ο π) is a graph
πΊ,π΄- = (π΄, πΈπ΄ ) where πΈπ΄ = πΈ ∩ π΄ × π΄
1
1
3
2
4
3
2
4
3
4
2
subgraph
induced subgraph
on π΄ = *2,3,4+
Walks, Paths and Cycles
Let πΊ = (π, πΈ) be a graph
• a walk (of length π) in πΊ is a sequence
π£1 , π1 , π£2 , π2, … , π£π−1 , ππ−1 , π£π
where π£1 , … , π£π ∈ π and ππ = *π£π , π£π+1 + ∈ πΈ for all π ∈ *1. . π − 1+
• a path in πΊ is a walk where π£1 , … , π£π are distinct
(does not go through the same vertex twice)
• a closed walk in πΊ is a walk with π£1 = π£π
(starts and ends in the same vertex)
• a cycle in πΊ is a closed walk where π ο³ 3 and π£1 , … , π£π−1 are distinct
1
3
2
4
1,{1,2},2,{2,1},1,{1,3},3
is a walk (not path)
1,{1,2},2,{2,3},3,{3,1},1
is a cycle
Special graphs
•
•
•
•
1
2
ππ path on π vertices
πΆπ cycle on π vertices
πΎπ complete graph on π vertices
π΅π hypercube of dimension π
π π΅π = 0,1
5
π5
2
4
πΆ5
1
5
3
4
3
π
3
(π1 , … , ππ ) adjacent to π1 , … , ππ
if ππ ’s and ππ ’s differ in exactly once
2
4
1
5
πΎ5
π
π=1
(0,1,0,0) adjacent to (0,1,0,1)
not adjacent to (0,1,1,1)
111
110
ππ − ππ = 1
100
000
010
101
001
011
π΅3
Connectivity
• a graph πΊ is connected if for any two vertices π’, π£ of πΊ
there exists a path (walk) in πΊ starting in π’ and ending in π£
1
1,{1,3},3,{3,4},4
path from 1 to 4
3
2
connected components
1
4
3
4
no path
from 1 to 4
2
connected
not connected = disconnected
• a connected component of πΊ is a maximal connected
subgraph of πΊ
Connectivity
• Show that the complement of a disconnected graph is connected !
π’
π’
π’
π£
π£
π€
πΊ
π€
πΊ
πΊ
• What is the maximum number of edges in a disconnected graph ?
π
2
π−π
2
max
π
π−1
π
π−π
+
=
2
2
2
maximum when π = 1
• What is the minimum number of edges in a connected graph ?
1
2
3
4
5
path ππ on π vertices has π − 1 edges
cannot be less, why ? keep removing edges
so long as you keep the graph connected
ο a (spanning) tree which has π − 1 edges
Distance, Diameter and Radius
recall walk (path) is a sequence of vertices and edges
π£1 , π1 , π£2 , π2, … , π£π−1 , ππ−1 , π£π
if edges are clear from context we write π£1 , π£2 , … , π£π
• length of a walk (path) is the number of edges
• distance π(π’, π£) from a vertex π’ to a vertex π£ is the length of
a shortest path in πΊ between π’ and π£
2
3
4
π(π’, π£) 1
• if no path exists define π π’, π£ = ∞
1
3
2
4
π(1,2) = 1
π(1,4) = 2
matrix
of distances in πΊ
distance matrix
1
0
1
1
2
2
1
0
1
2
3
1
1
0
1
4
2
2
1
0
Distance, Diameter and Radius
• eccentricity of a vertex π’ is the largest distance between π’
and any other vertex of πΊ; we write πππ π’ = max π(π’, π£)
π£
• diameter of πΊ is the largest distance between two vertices
ππππ πΊ = max π π’, π£ = max πππ(π£)
π’,π£
π£
• radius of πΊ is the minimum eccentricity of a vertex of πΊ
πππ πΊ = min πππ(π£)
πππ(πΊ) = 1
(as witnessed by 3
called a centre)
π£
1
3
2
4
ππππ(πΊ) = 2
(as witnessed by 1,4
called a diametrical pair)
πππ(1) = 2
πππ(2) = 2
πππ(3) = 1
πππ(4) = 2
Find radius and diameter of graphs ππ , πΆπ , πΎπ , π΅π
Prove that πππ(πΊ) ≤ ππππ(πΊ) ≤ 2 β πππ(πΊ)
Independent set and Clique
•
•
•
•
clique = set of pairwise adjacent vertices
independent set = set of pairwise non-adjacent vertices
clique number π(πΊ) = size of largest clique in πΊ
independence number πΌ(πΊ) = size of largest independent set in πΊ
*1,2,3+ is a clique
1
3
2
πΌ πΊ =2
π πΊ =3
4
*1,4+ is an independent set
Find πΌ(ππ ), πΌ(πΆπ ), πΌ πΎπ , πΌ(π΅π )
π(ππ ), π(πΆπ ), π(πΎπ ), π(π΅π )
1
2
3
π5
4
5
Bipartite graph
• a graph is bipartite if its vertex set π can be partitioned
into two independent sets π1 , π2 ; i.e., π1 ∪ π2 = π
1
1
3
3
4
4
2
2
bipartite
1
2
π1
π2
4
3
not bipartite
1 ∈ π1
1
3 ∈ π2
3
2
2 ∈ π2
4
but now π2 is not
an independent
set because
*2,3+ ∈ πΈ(πΊ)
Bipartite graph
• a graph is bipartite if its vertex set π can be partitioned
into two independent sets π1 , π2 ; i.e., π1 ∪ π2 = π
πΎ1,2
Which of these
graphs are
bipartite:
ππ , πΆπ , πΎπ , π΅π ?
πΎ2,2
πΎ3,3
πΎπ,π = complete bipartite graph
πΎ
4,4
π πΎπ,π = *π1 … ππ , π1 … ππ +
πΈ πΎπ,π = ππ ππ π ∈ 1. . π , π ∈ 1. . π +
Bipartite graph
Theorem. A graph is bipartite ο it has no cycle of odd length.
Proof. Let πΊ = (π, πΈ). We may assume that πΊ is connected.
“ο” any cycle in a bipartite graph is of even length
3
2
4
2
1
3
3
1
2
1
4
5
2
1
3
6
4
5
3
2
4
π odd
1
5
π
“ο” Assume G has no odd-length cycle. Fix a vertex π’ and put it in π1 .
Then repeat as long as possible:
π’
- take any vertex in π1 and put its neighbours in π2 , or
- take any vertex in π2 and put its neighbours in π1 .
Afterwards π1 ∪ π2 = π because πΊ is connected.
If one of π1 or π2 is not an independent set, then
?
we find in πΊ an odd-length closed walk ο cycle, impossible.
So, πΊ is bipartite (as certified by the partition π1 ∪ π2 = π)
οΏ