W elcome to D iscrete M athematics
PRESENTATION
Topics:GraphTheory
Introduction
What is a graph G?
It is a pair G = (V, E),
where
V = V(G) = set of vertices
E = E(G) = set of edges
Example:
V = {s, u, v, w, x, y, z}
E = {(x,s), (x,v), (x,v), (x,u),
(v,w), (s,v), (s,u), (s,w), (s,y),
(w,y), (u,y), (u,z),(y,z)}
Special edges
Parallel edges
Two or more edges
joining a pair of vertices
in the example, a and b
are joined by two parallel
edges
Loops
An edge that starts and
ends at the same vertex
In the example, vertex d
has a loop
Special graphs
Simple graph
A graph without loops
or parallel edges.
Weighted graph
A graph where each
edge is assigned a
numerical label or
“weight”.
Directed graphs (digraphs)
G is a directed graph or
digraph if each edge
has been associated
with an ordered pair
of vertices, i.e. each
edge has a direction
Terminology – Undirected graphs
u and v are adjacent if {u, v} is an edge, e is called incident with u and
v. u and v are called endpoints of {u, v}
Degree of Vertex (deg (v)): the number of edges incident on a vertex.
A loop contributes twice to the degree (why?).
Pendant Vertex: deg (v) =1
Isolated Vertex: deg (v) = 0
Representation Example: For V = {u, v, w} , E = { {u, w}, {u, w}, (u,
v) }, deg (u) = 2, deg (v) = 1, deg (w) = 1, deg (k) = 0, w and v are
pendant , k is isolated
Terminology – Directedgraphs
For the edge (u, v), u is adjacent to v OR v is adjacent from u, u –
Initial vertex, v – Terminal vertex
In-degree (deg- (u)): number of edges for which u is terminal vertex
Out-degree (deg+ (u)): number of edges for which u is initial vertex
Note: A loop contributes 1 to both in-degree and out-degree (why?)
Representation Example: For V = {u, v, w} , E = { (u, w), ( v, w), (u, v) },
deg- (u) = 0, deg+ (u) = 2, deg- (v) = 1,
deg+ (v) = 1, and deg- (w) = 2, deg+ (u) = 0
Theorems: Undirected Graphs
Theorem 1
The Handshaking theorem:
2e v
vV
(why?) Every edge connects 2 vertices
Theorems: Undirected Graphs
Theorem 2:
An undirected graph has even number of vertices
with odd degree
Pr oof V1is the set of even degree vertices and V2 refers to odd degree vertices
2e deg(v) deg(u) deg(v)
vV u V1 vV2
deg (v) is even for v V1,
The first term in the right hand side of the last inequality is even.
The sum of the last two terms on the right hand side of
the last inequality is even since sum is 2e.
Hence second term is also even
second term deg(v) even
vV2
Definitions – Graph Type
Simple graphs – special cases
Wheels: Wn, obtained by adding additional
vertex to Cn and connecting all vertices to
this new vertex by new edges.
Representation Example: W3, W4
Complete graph K n
Let n > 3
The complete graph Kn is
the graph with n vertices
and every pair of vertices
is joined by an edge.
The figure represents K5
Bipartite graphs
A bipartite graph G is a
graph such that
V(G) = V(G1) V(G2)
|V(G1)| = m, |V(G2)| = n
V(G1) V(G2) =
No edges existbetween
any two vertices in the
same subset V(Gk), k =
1,2
Complete bipartite graph Km,n
Abipartite graph is the
complete bipartite graph Km,nif
every vertex in V(G1) is joined
to a vertex in V(G2) and
conversely,
|V(G1)| = m
|V(G2)| = n
Connected graphs
A graph is connected if
every pair of vertices
can be connected by a
path
Each connected
subgraph of a non-
connected graph G is
called a component of G
Paths and cycles
A path of length n is a
sequence of n + 1
vertices and n
consecutive edges
A cycle is a path that
begins and ends at
the same vertex
Euler cycles
An Euler cycle in a graph G is a
simple cycle that passes through
every edge of G only once.
The Konigsberg bridge problem:
Starting and ending at the same point, is it
possible to cross all seven bridges just
once and return to the starting point?
This problem can be represented
by a graph
Edges represent bridges and
each vertex represents a region.
Degree of a vertex
The degree of a vertex
v, denoted by (v), is
the number of edges
incident on v
Example:
(a) = 4, (b) = 3,
(c) = 4, (d) = 6,
(e) = 4, (f) = 4,
(g) = 3.
Sum of the degrees of a graph
Theorem : If G is a graph with m edges and n
vertices v1, v2,…, vn, then
n
(vi) = 2m
i =1
In particular, the sum of the degrees of all the
vertices of a graph is even.
Shortest Path Problems
• Directed weighted graph.
• Path length is sum of weights of edges on path.
• The vertex at which the path begins is the source
vertex.
• The vertex at which the path ends is the
destination vertex.
t x
6
3 9
3
4
2 1
s 0 2 7
5 3
5 6
11
y z
Example
8 6
1
2 3
3 1
16
6 7 4 5 10
4
2 4 7
5 3
14
• A shorter path will cost only 11
Representations of graphs
Adjacency matrix
Rows and columns are v w x y
labeled with ordered
vertices v 0 1 0 1
write a 1 if there is an edge
between the row vertex w 1 0 1 1
and the column vertex
x 0 1 0 1
and 0 if no edge exists
between them y 1 1 1 0
Euler’s formula
If G is planar graph,
v = number of vertices
e = number of edges
f = number of faces,
including the exterior face
Then: v – e + f = 2