Graph Theory - Lecture 2 (of 2) -...
Transcript of Graph Theory - Lecture 2 (of 2) -...
MAT 1348b - Discrete Maths for Computing
Graph Theory - Lecture 2 (of 2)
Supartha Podder
April 09, 2018
Graph Theory
a
bc
de
f gG
e1 e2
e3e4
e5e6
e7
e8
1/31
Graph Theory - Loop and Parallel Edges
2/31
Some Useful Graphs
Graph Theory - Path
Path
A path Pn (of length n ≥ 0) is a graph with n + 1 vertices that are linkedin a linear way. More precisely,
V (Pn) = {u1, u2, · · · , un}
E (Pn) = {u1u2, u2u3, u3u4, · · · , un−1un}
3/31
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 0) is a graph with n vertices that are linked in alinear way. More precisely,
V (Pn) = {u1, u2, · · · , un}
E (Pn) = {u1u2, u2u3, u3u4, · · · , un−1un, unu1}
4/31
Graph Theory - Bipartite Graph
Bipartite Graph
A bipartite graph Km,n (for m, n ≥ 1) is a simple graph with m + nvertices. The vertex set partitions into sets X and Y of cardinalities m andn. And edges are only of the form xy , where x ∈ X , y ∈ Y :
V (Km,n) = {x1, x2, · · · , xm} ∪ {y1, y2, · · · , yn}
E (Km,n) ⊆ {xiyj : xi ∈ X , yj ∈ Y }5/31
Graph Theory - Complete Graph
Complete Graph
A complete graph Kn (for n ≥ 1) is a simple graph with n vertices inwhich every pair of distinct vertices are adjacent. More formally
V (Kn) = {u1, u2, · · · , un}
E (Kn) = {xy : x , y ∈ V , x 6= y}
6/31
Graph Theory - Complete Bipartite Graph
Complete Bi-partite Graph
A complete bipartite graph Km,n (for m, n ≥ 1) is a simple graph withm + n vertices. The vertex set partitions into sets X and Y of cardinalitiesm and n, and each pair of vertices from distinct parts are adjacent. Thatis:
V (Km,n) = {x1, x2, · · · , xm} ∪ {y1, y2, · · · , yn}
E (Km,n) = {xiyj : xi ∈ X , yj ∈ Y }7/31
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Theorem
The following are equivalent:
1 G is bipartite.
2 G admits a proper 2-vertex-colouring; that is, the vertices of G canbe coloured with 2 colours (say, red and blue) so that the endpointsof each edge receive distinct colours.
3 G has no subgraph that is a cycle of odd length.
1 2
3 4
5 6
78G
1
8/31
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Theorem
The following are equivalent:
1 G is bipartite.
2 G admits a proper 2-vertex-colouring; that is, the vertices of G canbe coloured with 2 colours (say, red and blue) so that the endpointsof each edge receive distinct colours.
3 G has no subgraph that is a cycle of odd length.
1 2
3 4
5 6
78G
1
8/31
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Theorem
The following are equivalent:
1 G is bipartite.
2 G admits a proper 2-vertex-colouring; that is, the vertices of G canbe coloured with 2 colours (say, red and blue) so that the endpointsof each edge receive distinct colours.
3 G has no subgraph that is a cycle of odd length.
1 2
3 4
5 6
78G
1
8/31
Bipartite Graph, 2-Coloring and No Odd-length Cycle
Proof.
(1)→ (2) :Assume the graph G is bipartite with bipartition {X ,Y }. Colour thevertices in X red and the vertices in Y blue.Since each edge has one endpoint in X and the other in Y , theendpoints of each edge receive distinct colours.
(2)→ (1) :Assume that G admits a proper 2-vertex-colouring.Let X be the set of all vertices in V (G ) coloured red, and Y be theset of all vertices in V (G ) coloured blue.Since the endpoints of each edge receive distinct colours, each edgemust have one endpoint in X and the other in Y .
9/31
Graph Theory - Subgraph
a
b c
d e
f gG H
h
i j
k
Subgraph
Let G and H be simple graphs. We say that H is a subgraph of G ifV (H) ⊆ V (G ) and E (H) ⊆ E (G ).
10/31
Graph Theory - Subgraph
a
b c
d e
f gG H
h
i j
k
Subgraph
Let G and H be simple graphs. We say that H is a subgraph of G ifV (H) ⊆ V (G ) and E (H) ⊆ E (G ).
10/31
Matrix Representation of Graphs
Graph Theory - Incident Matrix Representation
Incident Matrix Representation
Let G be a graph with V (G ) = {u1, u2, · · · , un},E (G ) = {e1, e2, · · · , em},and incidence function fG . We define:
the incidence matrix of G : an n ×m matrix M = [mij ] such that
mij =
2, if fG (ej) = {vj}1, if fG (ej) = {ui , uk} for some k 6= i
0 otherwise.
(1)
11/31
Graph Theory - Adjacency Matrix Representation
Adjacency Matrix Representation
Let G be a graph with V (G ) = {u1, u2, · · · , un},E (G ) = {e1, e2, · · · , em},and incidence function fG . We define:
the adjacency matrix of G : an n × n matrix A = [aij ] such that
aij = |{ek : fG (ek) = {ui , uj}}|
= number of edges with end points ui and uj .
12/31
Graph Theory - Adjacency Matrix Representation
13/31
Graph Isomorphism
Graph Isomorphism Problem is one of the most interesting problems incomputer science.
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78G H
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78
f (a) = 5 f (b) = 2
f (c) = 3 f (d) = 7
f (g) = 1 f (h) = 6
f (i) = 8 f (j) = 4
An Isomorphismbetween G and H
Click here for an animated example
14/31
Graph Isomorphism
Graph Isomorphism Problem is one of the most interesting problems incomputer science.
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78G H
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78
f (a) = 5 f (b) = 2
f (c) = 3 f (d) = 7
f (g) = 1 f (h) = 6
f (i) = 8 f (j) = 4
An Isomorphismbetween G and H
Click here for an animated example
14/31
Graph Isomorphism
Graph Isomorphism Problem is one of the most interesting problems incomputer science.
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78G H
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78
f (a) = 5 f (b) = 2
f (c) = 3 f (d) = 7
f (g) = 1 f (h) = 6
f (i) = 8 f (j) = 4
An Isomorphismbetween G and H
Click here for an animated example
14/31
Graph Isomorphism
Graph Isomorphism Problem is one of the most interesting problems incomputer science.
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78G H
a
b
c
d
g
h
i
j
1 2
3 4
5 6
78
f (a) = 5 f (b) = 2
f (c) = 3 f (d) = 7
f (g) = 1 f (h) = 6
f (i) = 8 f (j) = 4
An Isomorphismbetween G and H
Click here for an animated example
14/31
Graph Isomorphism
Are these two graph isomorphic?
Definition (Graph Isomorphism)
Let G and H be simple graphs. An isomorphism from G to H is abijection ϕ : V (G )→ V (H) such that
u ∼G v ⇔ ϕ(u) ∼H ϕ(v)
for all u, v ∈ V (G ). Graphs G and H are called isomorphic (denotedG ∼= H) if there exists an isomorphism from G to H.
15/31
Graph Isomorphism
Definition (Graph Invariant)
A graph invariant is a graph property or parameter that is preserved underisomorphisms; that is, isomorphic graphs must agree on this property orparameter. Many graph properties are invariants; for example:
Number of vertices
Number of edges
Degree Sequence (all the degrees of the vertices of the graph insorted order)
Being bipartite
Containing specific subgraph etc.
16/31
Graph Isomorphism
Observation
To prove that graphs G and H are isomorphic, we must find anisomorphism from G to H.
To prove that graphs G and H are not isomorphic, it suffices to findan invariant in which G and H differ.
17/31
Graph Isomorphism -Example 1
Are these two graph isomorphic?
Solution:
No. They have the same degree sequence. But these two graphs are notisomorphic. H has a subgraph isomorphic to C3, while G does not (it is, infact, bipartite and isomorphic to K3,3).
18/31
Graph Isomorphism -Example 1
Are these two graph isomorphic?
Solution:
No. They have the same degree sequence. But these two graphs are notisomorphic. H has a subgraph isomorphic to C3, while G does not (it is, infact, bipartite and isomorphic to K3,3).
18/31
Graph Isomorphism -Example 2
Are these two graph isomorphic?
Solution:
Yes, these two graphs are isomorphic. An isomorphism ϕ : (G )→ V (H) isgiven by
ϕ(1) = a ϕ(2) = dϕ(3) = b ϕ(4) = eϕ(5) = c ϕ(6) = f
19/31
Graph Isomorphism -Example 2
Are these two graph isomorphic?
Solution:
Yes, these two graphs are isomorphic. An isomorphism ϕ : (G )→ V (H) isgiven by
ϕ(1) = a ϕ(2) = dϕ(3) = b ϕ(4) = eϕ(5) = c ϕ(6) = f
19/31
Graph Isomorphism -Example 3
Are these two graph isomorphic?
Solution:
No, these two graphs are not isomorphic. They have the same degreesequence, however, graph H contains no pair of adjacent vertices of degree3, while G does.
20/31
Graph Isomorphism -Example 3
Are these two graph isomorphic?
Solution:
No, these two graphs are not isomorphic. They have the same degreesequence, however, graph H contains no pair of adjacent vertices of degree3, while G does.
20/31
Walks, Trails, Paths, Cycle
Walks, Trails, Paths, Cycles
Definition
Walk Let G = (V ,E ) be a graph with the incidence function fG . Letx , y ∈ V and k ∈ N. An (x , y)-walk of length k in G is an alternatingsequence of vertices and edges.
A (v1, v3)-walk of length 4
W = v1e2v2e6v4e8v3e7v3
21/31
Walks, Trails, Paths, Cycles
Definition
Walk Let G = (V ,E ) be a graph with the incidence function fG . Letx , y ∈ V and k ∈ N. An (x , y)-walk of length k in G is an alternatingsequence of vertices and edges.
A (v1, v3)-walk of length 4
W = v1e2v2e6v4e8v3e7v321/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3
is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3
is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3
is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 1a2h6n5f 1a2b3is a (1,3)-walk of length 6 that is not a trail.
W = 1e4d4c3is a (1,3)-trail of length 3 that is not a path.
W = 1f 5m8k3is a (1,3)-path of length 3.
22/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2
is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4 is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2 is a cycle of length 4containing vertex 2.
23/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2 is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4 is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2 is a cycle of length 4containing vertex 2.
23/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2 is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4
is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2 is a cycle of length 4containing vertex 2.
23/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2 is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4 is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2 is a cycle of length 4containing vertex 2.
23/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2 is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4 is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2
is a cycle of length 4containing vertex 2.
23/31
Walks, Trails, Paths, Cycles
Definition
A walk W = v0e1v1e2v2 · · · vk1ekvk is called
closed if v0 = vk , and open otherwise;
a trail if its edges are pairwise distinct;
a path if its vertices are pairwise distinct; and
a cycle if v0 = vk while its internal vertices v1, · · · , vk are pairwisedistinct.
W = 2b3j7i2h6o7i2 is a closed walk of length6 that contains vertex 2 and is not a trail:.
W = 4d4l8k3c4 is a closed trail of length4 that contains vertex 4 and is not a cycle.
W = 2b3j7o6h2 is a cycle of length 4containing vertex 2.
23/31
Trees and Forests
Trees and Forests
Warm up: Connected Graph
Connected Graph
A graph G = (V ,E ) is called connected if for any x , y ∈ V there exists an(x , y)-path (or equivalently, (x , y)-walk) in G . A graph that is notconnected is called disconnected.
24/31
Trees
Tree and Forest
A graph without cycles is called acyclic or a forest. A tree is a connectedacyclic graph ,that is, a connected forest.
25/31
Trees
Theorem 1
Let G be a graph. Then G is a tree if and only if for any two verticesu, v ∈ V (G ), there exists a unique (u, v)-path in G .
Theorem 2 and 3
Every tree with at least 2 vertices has at least 2 vertices of degree 1(called leaves).
Any tree with n vertices has exactly n − 1 edges.26/31
Rooted Trees
Rooted Tree
A tree with a vertex designated as the root is called a rooted tree.
27/31
Rooted Trees
Similar terminologies for rooted trees?
28/31
Rooted Trees
Terminology for rooted trees:
Let T = (V ,E ) be a rooted tree with root r and u, v ∈ V .
If u lies on the unique (v , r)-path, then u is called anancestor of v ,and v is called a descendant to u.
If u lies on the unique (v , r)-path and uv has an edge, then u is calledthe parent of v , and v is called a child of u.
If u and v have the same parent, then they are called siblings.
If vertex u has a child, then it is called an internal vertex; if it hasno children, thenit is called a leaf.
29/31
Rooted m-ary Trees
A Rooted m-ary Tree:
an m-ary tree if every internal vertex has at most m children; and
a full m-ary tree if every internal vertex has exactly m children.
A Binary is a 2-ary tree.A Ternary is a 3-ary tree.
30/31
Thank you for your attention!!
31/31