Graph - cs.toronto.edustacho/public/combinatorics-2011-10-31-and-1β¦Β Β· Graph β’ graph is a pair...
Transcript of Graph - cs.toronto.edustacho/public/combinatorics-2011-10-31-and-1β¦Β Β· Graph β’ graph is a pair...
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+ +
β’ Notation: β we write πΊ = (π, πΈ) for a graph with vertex set π and edge set πΈ
β π(πΊ) is the vertex set of πΊ, and πΈ(πΊ) is the edge set of πΊ
1
2
3 4
drawing of πΊ
1 2 3 4
1 1 1
2 1 1
3 1 1 1
4 1
1 2 3 4
1 1 1
2 1
3 1 1
4
1 2 3 4
1 1 3
2 1 2
3 3 2 4
4 4
1 2 3 4
1 1 1
2 1 1 1
3 1 1 1 1
4 0 1
Types of graphs
β’ Undirected graph
πΈ(πΊ) = set of unordered pairs
β’ Pseudograph (allows loops)
loop = edge between vertex and itself
1
2
3 4
β’ Directed graph
πΈ(πΊ) = set of ordered pairs
β’ Multigraph
πΈ(πΊ) is a multiset
(IRREFLEXIVE) RELATION SYMMETRIC & IRREFLEXIVE
SYMMETRIC ?
1
2
3 4
1
2
3 4
1
2
3 4
πΈ = *(1,2), (2,3), (1,3), (3,1), (3,4)+
πΈ = **1,2+, *1,3+, *1,3+, *1,3+, 2,3 , 2,3 , *3,4+, *3,4+, *3,4+, *3,4++
πΈ = **1,2+, *1,3+, *2,3+, *3,4++
πΈ = **1,2+, *1,3+, *2,2+, *2,3+, *3,3+, *3,4++
β’ simple graph (undirected, no loops, no parallel edges)
for edge *π’, π£+πΈ(πΊ) we say:
β π’ and π£ are adjacent
β π’ and π£ are neighbours
β π’ and π£ are endpoints of *π’, π£+
β we write π’π£πΈ πΊ for simplicity
β’ N(π£) = set of neighbours of π£ in G
β’ deg (π£) = degree of v is the number of its neighbours, ie. |N(π£)|
1
2
3
More graph terminology
1
2
3 4 N(1) = *2,3+ N(2) = *1,3+ N(3) = *1,2,4+ N(4) = *3+
1 is adjacent to 2 and 3
deg (3) = 3 deg 4 = 1 deg (1) = deg (2) = 2
1
2
3 = β
πΊ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)
β π(1) = 2 π(2) = 3 π(3) = 1
1
2
3
1
2
3
1
Isomorphism
2 3
4 5 6
4
5
6
1
2
3
4
6
5
1
3
2
(3,3,3,3,3,3) (3,3,3,3,3,3) (3,3,3,3,3,3)
(3,3,3,3,2,2,2,2) (3,3,3,3,2,2,2,2)
3 3 3
3 3 3
β
if π is an isomorphism
deg (π’) = deg (π(π’))
β β
degree sequence
i.e., isomorphic graphs have same degree sequences only necessary not sufficient!!!
Isomorphism How many pairwise non-isomorphic graphs on π vertices are there?
the complement of πΊ = (π, πΈ) is the graph πΊ = (π, πΈ ) where
πΈ = π’, π£ *π’, π£+πΈ+
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
1
2
3
2
1
3
4
5
πΊ
2
1
3
4
5
πΊ
πΈ(πΊ) = **1,2+, *2,3+, *3,4+, *4,5++
πΈ(πΊ ) = **1,3+, *1,4+, *1,5+, *2,4+, *2,5+, *3,5++
all graphs (labeled)
non-isomorphic graphs (without labels)
Isomorphism
How many pairwise non-isomorphic graphs on π vertices are there?
β self-complementary graph
Isomorphism
β’ Are there self complementary graphs on 5 vertices ?
β’ ... 6 vertices ?
No, because in a self-complementary graph πΊ = (π, πΈ)
|πΈ| = |πΈ | and πΈ + πΈ =|π|2
but 62= 15 is odd
β’ ... 7 vertices ?
β’ ... 8 vertices ?
2
1
3
4
5
2
1
3
4
5
4
1
5
8 7
6
2
3 1 β 4, 2 β 6, 3 β 1, 4 β 7 5 β 2, 6 β 8, 7 β 3, 8 β 5
No, since 72= 21
1 β 1, 2 β 4, 3 β 2 4 β 5, 5 β 3
1 β 2, 2 β 5, 3 β 3 4 β 1, 5 β 4
Yes, there are 10
Yes, 2
Handshake lemma
Lemma. Let πΊ = (π, πΈ) be a graph with π edges.
deg π£ = 2π
π£βπ
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.
How many edges has a graph with degree sequence:
- (3,3,3,3,3,3) ?
- (3,3,3,3,3) ?
- (0,1,2,3) ?
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.
4
5
6
1
2
3
1
2
3 4
deg (1) = 2 deg (2) = 2 deg (3) = 3 deg 4 = 1
π = 4
Handshake lemma
Is it possible for a self-complementary graph with 100 vertices to have exactly one vertex of degree 50 ?
Answer. No N(π’)
50
π(πΊ)\N(π’)
49
NπΊ (π’)
49
π isomorphism between πΊ and πΊ
π£ is a unique vertex of degree 49 in πΊ
the degree seq. of πΊ and πΊ (β¦ ,β¦ ,β¦ , 50,49, β¦ ,β¦ ,β¦ )
π£
βπ£, π(π£) = π’
we conclude π(π’) = π£
π’
πΊ
π’
πΊ
definition of isomorphism definition of complement
π’π£ β πΈ(πΊ) π(π’)π(π£) β πΈ(πΊ ) but π(π’)π(π£) = π£π’ β πΈ(πΊ ) π’π£ β πΈ(πΊ)
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
2
3 4
1
2
3 4
2
3 4
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
2
3 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
β’ ππ path on π vertices
β’ πΆπ cycle on π vertices
β’ πΎπ complete graph on π vertices
β’ π΅π hypercube of dimension π
π π΅π = 0,1π
(π1, β¦ , ππ) adjacent to π1, β¦ , ππ if ππβs and ππβs differ in exactly once
(0,1,0,0) adjacent to (0,1,0,1) not adjacent to (0,1,1,1)
ππ β ππ = 1
π
π=1
2
1
3
4
5
2 1 3 4 5 π5
πΆ5
2
1
3
4
5
πΎ5
π΅3
000
100 010
001
110 111
011 101
Connectivity
β’ a graph πΊ is connected if for any two vertices π’, π£ of πΊ there exists a path (walk) in πΊ starting in π’ and ending in π£
β’ a connected component of πΊ is a maximal connected subgraph of πΊ
1
2
3 4
1
2
3 4
connected not connected = disconnected
no path from 1 to 4
connected components 1,{1,3},3,{3,4},4 path from 1 to 4 1
3 4
Connectivity
β’ Show that the complement of a disconnected graph is connected !
β’ What is the maximum number of edges in a disconnected graph ?
β’ What is the minimum number of edges in a connected graph ?
π’ π£
π’
π£
πΊ πΊ
π2
π β π2
maxπ
π2+π β π2=π β 12
maximum when π = 1
2 1 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
β’ 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 π£
β’ if no path exists define π π’, π£ = β
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, β¦ , π£π
1
2
3 4
π(1,2) = 1 π(1,4) = 2
π(π’, π£) 1 2 3 4
1 0 1 1 2
2 1 0 1 2
3 1 1 0 1
4 2 2 1 0
matrix of distances in πΊ distance matrix
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
π£πππ(π£)
Find radius and diameter of graphs ππ, πΆπ, πΎπ, π΅π Prove that πππ(πΊ) β€ ππππ(πΊ) β€ 2 β πππ(πΊ)
1
2
3 4
πππ(1) = 2 πππ(2) = 2 πππ(3) = 1 πππ(4) = 2
πππ(πΊ) = 1 (as witnessed by 3
called a centre)
ππππ(πΊ) = 2 (as witnessed by 1,4
called a diametrical pair)
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 indepen-dent set in πΊ
Find πΌ(ππ), πΌ(πΆπ), πΌ πΎπ , πΌ(π΅π) π(ππ), π(πΆπ), π(πΎπ), π(π΅π)
1
2
3 4 πΌ πΊ = 2 π πΊ = 3
*1,2,3+ is a clique
*1,4+ is an independent set
2 1 3 4 5
π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
2
3 4
1
2
3 4
1 2
3 4
bipartite not bipartite
π2 π1 1
2
3 4
1 β π1
3 β π2 but now π2 is not an independent set because *2,3+ β πΈ(πΊ)
2 β π2
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
πΎ3,3
πΎ4,4 πΎπ,π = complete bipartite graph
π πΎπ,π = *π1β¦ππ , π1β¦ππ+ πΈ πΎπ,π = ππππ π β 1. . π , π β 1. .π +
Which of these graphs are bipartite:
ππ, πΆπ, πΎπ, π΅π ? πΎ2,2
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
ββ 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 = π)
2
1
3 4
5
π
2
1
3
2
1
3
4
5
2
1
3 4
5 6
2
3
4
1
π’
?
π odd