graph theory - lecture 1 (of 2) -...
TRANSCRIPT
MAT 1348b - Discrete Maths for Computing
Graph Theory - Lecture 1 (of 2)
Supartha Podder
April 04, 2018
Graph Theory
Graph Theory
Graph Theory
Graph Theory
Graph Theory
a
bc
de
f gG
e1 e2
e3e4
e5e6
e7
e8
Definition (Graph)
A graph G is an ordered pair (V ,E ), where
V = V (G ) is a non-empty set of vertices – The vertex set of G ;
E = E (G ) is a set of edges the edge set of G ; and the two sets arerelated through a function
fG : E → {{u, v} : u, v ∈ V }
called the incidence function, assigning to each edge the unorderedpair of its end-points. 1/21
Graph Theory - Example
za
bc
de
f gG
e1 e2
e3e4
e5e6
e7
e8
The drawing above represents a graph with vertex setV = {a, b, c , d , e, f , g}, edge set E = {e1, e2, · · · , e8}, and incidencefunction defined by
f (e1) = {a, b} f (e2) = {b, c}f (e3) = {b, d} f (e4) = {b, e}f (e5) = {c , e} f (e6) = {d , f }f (e7) = {e, f } f (e8) = {c , g}
2/21
Graph Theory - Loop and Parallel Edges
Definition
An edge e in a graph G is called a
loop if fG (e) = {u} for some vertex u ∈ V (G ) (that is, if itsendpoints coincide)
link if fG (e) = {u, v}for distinct vertices u, v ∈ V (G ).
Distinct edges e1 and e2 in a graph G are called parallel or multipleif fG (e1) = fG (e2),that is, if they have the same endpoints. 3/21
Graph Theory - Loop and Parallel Edges
In this example, edges e1 ande7 are loops,and all other edges are links.Edges e3, e4, and e5 are pairwise parallel.
Definition (Simple Graph)
A simple graph is a graph without loops and without multiple edges.
4/21
Graph Theory - Loop and Parallel Edges
In this example, edges e1 ande7 are loops,and all other edges are links.Edges e3, e4, and e5 are pairwise parallel.
Definition (Simple Graph)
A simple graph is a graph without loops and without multiple edges.
4/21
Graph Theory - Directed Graph
Definition
A directed graph (or digraph) D is an ordered pair (V ,A), where
V = V (D) is a non-empty set of vertices – the vertex set of D;
A = A(D) is a set of arcs or directed edges the arc set of D; and
the two sets are related via an incidence function fD :→ V × V ,assigning to each arc the ordered pair of its endpoints.
5/21
Graph Theory - Directed Graph Example
We have a digraph with vertex set V = {v1, v2, v3, v4} and arc setA = {a1, a2, ..., a9}. The incidence function returns
fD(a1) = {v1, v1} fD(a2) = {v1, v2}fD(a3) = {v3, v2} fD(a4) = {v2, v3}fD(a5) = {v2, v3} fD(a6) = {v2, v4}fD(a7) = {v3, v3} fD(a8) = {v3, v4}fD(a9) = {v4, v3}
6/21
Graph Theory - Directed Graph Example
If a ∈ A(D) and u, v ∈ V (D) are such that fD(a) = (u, v), then u is calledthe initial and v is called the terminal vertex of the arc a.
7/21
Graph Terminology
Graph Theory - Graph Terminology
Adjacent: Let G = (V ,E ) be a graph. Vertices u, v ∈ V are calledadjacent or neighbours in G if uv is an edge of G .
Incident An edge uv is said to be incident with each of its end pointsu and v .
Degree The degree of a vertex u ∈ V , denoted by degG (u), is thenumber of edges of G incident with vertex u, each loop countingtwice.
– A vertex of degree 0 is called isolated, and a vertex of degree 1 iscalled pendant (or a leaf in the context of trees).
8/21
Graph Theory - Graph Terminology
Adjacent: Let G = (V ,E ) be a graph. Vertices u, v ∈ V are calledadjacent or neighbours in G if uv is an edge of G .
Incident An edge uv is said to be incident with each of its end pointsu and v .
Degree The degree of a vertex u ∈ V , denoted by degG (u), is thenumber of edges of G incident with vertex u, each loop countingtwice.
– A vertex of degree 0 is called isolated, and a vertex of degree 1 iscalled pendant (or a leaf in the context of trees).
8/21
Graph Theory - Graph Terminology
Adjacent: Let G = (V ,E ) be a graph. Vertices u, v ∈ V are calledadjacent or neighbours in G if uv is an edge of G .
Incident An edge uv is said to be incident with each of its end pointsu and v .
Degree The degree of a vertex u ∈ V , denoted by degG (u), is thenumber of edges of G incident with vertex u, each loop countingtwice.
– A vertex of degree 0 is called isolated, and a vertex of degree 1 iscalled pendant (or a leaf in the context of trees).
8/21
Graph Theory - Graph Terminology
Adjacent: Let G = (V ,E ) be a graph. Vertices u, v ∈ V are calledadjacent or neighbours in G if uv is an edge of G .
Incident An edge uv is said to be incident with each of its end pointsu and v .
Degree The degree of a vertex u ∈ V , denoted by degG (u), is thenumber of edges of G incident with vertex u, each loop countingtwice.
– A vertex of degree 0 is called isolated, and a vertex of degree 1 iscalled pendant (or a leaf in the context of trees).
8/21
Graph Theory - Handshaking Theorem
9/21
Graph Theory - Handshaking Theorem
Theorem (The Handshaking Theorem)
In any graph G = (V ,E ), we have∑u∈V
degG (u) = 2|E |
Proof.
In the sum∑
u∈V degG (u):
each loop incident with vertex u counts 2 towards degG (u), and
each link uv counts 1 towards degG (u) and 1 towards degG (v).
Hence each edge is counted twice in∑
u∈V degG (u), and the result follows.
10/21
Graph Theory - Handshaking Theorem
Theorem (The Handshaking Theorem)
In any graph G = (V ,E ), we have∑u∈V
degG (u) = 2|E |
Proof.
In the sum∑
u∈V degG (u):
each loop incident with vertex u counts 2 towards degG (u), and
each link uv counts 1 towards degG (u) and 1 towards degG (v).
Hence each edge is counted twice in∑
u∈V degG (u), and the result follows.
10/21
Graph Theory - Handshaking Theorem
Theorem (The Handshaking Theorem)
In any graph G = (V ,E ), we have∑u∈V
degG (u) = 2|E |
Corollary
Every graph has an even number of vertices of odd degree.
Proof.
Let G = (V ,E ) be a graph, V1 the subset of V containing all vertices of odddegree,and V2 = V − V1. Then, by the Handshaking Theorem,
2|E | =∑u∈V
degG (u) =∑u∈V1
degG (u) +∑u∈V2
degG (u)
∑u∈V1
degG (u) = 2|E | −∑u∈V2
degG (u)
11/21
Graph Theory - Handshaking Theorem
Theorem (The Handshaking Theorem)
In any graph G = (V ,E ), we have∑u∈V
degG (u) = 2|E |
Corollary
Every graph has an even number of vertices of odd degree.
Proof.
Let G = (V ,E ) be a graph, V1 the subset of V containing all vertices of odddegree,and V2 = V − V1. Then, by the Handshaking Theorem,
2|E | =∑u∈V
degG (u) =∑u∈V1
degG (u) +∑u∈V2
degG (u)
∑u∈V1
degG (u) = 2|E | −∑u∈V2
degG (u)
11/21
Some Useful Graphs
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}
12/21
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}
12/21
Graph Theory - Complete Bi-partite 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 }
13/21
Graph Theory - Complete Bi-partite 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 }13/21
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 }
14/21
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 }
14/21
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 1) is a graph with n vertices that are linked in acircular way, creating n edges. That is,
V (Cn) = {u1, u2, · · · , un}
E (Cn) = {u1u2, u2u3, u3u4, · · · , un−1un, unu1}
Note that any cycle Cn for n ≥ 3 is a simple graph, while for n = 2, theedge set E (Cn) consists of a pair of parallel edges.
15/21
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 1) is a graph with n vertices that are linked in acircular way, creating n edges. That is,
V (Cn) = {u1, u2, · · · , un}
E (Cn) = {u1u2, u2u3, u3u4, · · · , un−1un, unu1}
Note that any cycle Cn for n ≥ 3 is a simple graph, while for n = 2, theedge set E (Cn) consists of a pair of parallel edges.
15/21
Graph Theory - Cycle
Cycle
A cycle Cn (of length n ≥ 1) is a graph with n vertices that are linked in acircular way, creating n edges. That is,
V (Cn) = {u1, u2, · · · , un}
E (Cn) = {u1u2, u2u3, u3u4, · · · , un−1un, unu1}
Note that any cycle Cn for n ≥ 3 is a simple graph, while for n = 2, theedge set E (Cn) consists of a pair of parallel edges.
15/21
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}
16/21
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}
16/21
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 ).
But is it induced subgraph? What is that by the way?
17/21
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 ).
But is it induced subgraph? What is that by the way?
17/21
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)
18/21
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 .
19/21
Graph Theory - Adjacency Matrix Representation
20/21
Thank you for your attention!!
Lecture 2 (of 2) on April 09, 2018.
21/21