0% found this document useful (0 votes)
19 views54 pages

Discrete Chapter 10

Chapter 10 of Discrete Structures focuses on graphs, defining simple graphs, directed graphs, and various types of graph models. It discusses graph terminology, including concepts like adjacency, degree, and special types of graphs such as complete graphs and bipartite graphs. The chapter also covers operations on graphs and methods for representing them, including the use of adjacency matrices.

Uploaded by

workairdrop92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views54 pages

Discrete Chapter 10

Chapter 10 of Discrete Structures focuses on graphs, defining simple graphs, directed graphs, and various types of graph models. It discusses graph terminology, including concepts like adjacency, degree, and special types of graphs such as complete graphs and bipartite graphs. The chapter also covers operations on graphs and methods for representing them, including the use of adjacency matrices.

Uploaded by

workairdrop92
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Discrete Structures

Chapter 10
Graphs

Prof. Dr. Malik Sikander Hayat Khiyal


Faculty of Computer Science,
Preston University, Islamabad Campus,
85, Street 3, Sector H-8/1,
Islamabad, PAKISTAN.
drsikandarhayat@preston.edu.pk
04/17/2025 Discrete Mathematics Chapter 10 1
Discrete Structures Contents
Chapter 1. The Foundations: Logic and Proofs
Chapter 2. Basic Structures: Sets, Functions, Sequences, and Sums
Chapter 3. The Fundamentals: Algorithms, the Integers, and Matrices
Chapter 4. Number Theory and Cryptography
Chapter 5. Induction and Recursion
Chapter 6. Counting
Chapter 7. Discrete Probability
Chapter 8. Advanced Counting Technique
Chapter 9. Relations
Chapter 10. Graphs
Chapter 11. Trees
Chapter 12. Boolean Algebra

04/17/2025 Discrete Mathematics Chapter 10 2


Introduction to Graphs
Definition: A simple graph G = (V, E) consists of V,
a nonempty set of vertices, and E, a set of unordered
pairs of distinct elements of V called edges.
For each eE, e = {u, v} where u, v  V.
An undirected graph (not simple) may contain loops.
An edge e is a loop if e = {u, u} for some uV.
Graphs that may have multiple edges connecting the
same vertices are called multigraphs. When there are
m different edges associated to the same unordered
pair of vertices {u, v}, we also say that {u, v} is an
edge of multiplicity m.
04/17/2025 Discrete Mathematics Chapter 10 3
Introduction to Graphs
Definition: A directed graph G = (V, E) consists of a set V
of vertices and a set E of edges that are ordered pairs of
elements in V.
For each eE, e = (u, v) where u, v  V.
An edge e is a loop if e = (u, u) for some uV.
A simple graph is just like a directed graph, but with no
specified direction of its edges.
Directed graphs that may have multiple directed edges
from a vertex to a second (possibly the same) vertex. We
called such graphs directed multigraphs. When there are m
directed edges, each associated to an ordered pair of vertices
(u, v), we say that (u, v) is an edge of multiplicity m.
04/17/2025 Discrete Mathematics Chapter 10 4
Graph Models
Example I: How can we represent a network of (bi-
directional) railways connecting a set of cities?
We should use a simple graph with an edge {a, b}
indicating a direct train connection between cities a
and b.
Detroit

New York

San Francisco
Chicago
Denver

Washington
Los Angeles

04/17/2025 Discrete Mathematics Chapter 10 5


Graph Models
Detroit

New York
Denver
San Francisco

Chicago

Washington

Los Angeles

Multigraph as multiple links between data centers.

04/17/2025 Discrete Mathematics Chapter 10 6


Graph Models
Example II: In a round-robin tournament, each
team plays against each other team exactly once.
How can we represent the results of the tournament
(which team beats which other team)?
We should use a directed graph with an edge (a, b)
indicating that team a beats team b.

Maple Leafs Bruins

Penguins Lübeck Giants


04/17/2025 Discrete Mathematics Chapter 10 7
Graph Models

Detroit

New York
Denver
San Francisco

Chicago

Washington
Los Angeles

Simple directed graph: A communications


network with one-way communications links.

04/17/2025 Discrete Mathematics Chapter 10 8


Graph Terminology
Graphs that may include loops, and possibly
multiple edges connecting the same pair of vertices or a
vertex to itself, are sometimes called pseudographs.
Definition: Two vertices u and v in an undirected graph
G are called adjacent (or neighbors) in G if {u, v} is
an edge in G.
If e = {u, v}, the edge e is called incident with the
vertices u and v. The edge e is also said to connect u
and v.
The vertices u and v are called endpoints of the edge
{u, v}.
04/17/2025 Discrete Mathematics Chapter 10 9
Graph Terminology

TABLE 1 Graph Terminology.


Type Edges Multiple Edges Loops
Allowed? Allowed?
Simple graph Undirected No No
Multigraph Undirected Yes No
Pseudograph Undirected Yes Yes
Simple directed graph Directed No No
Directed multigraph Directed Yes Yes

Mixed graph Directed and Yes Yes


undirected

04/17/2025 Discrete Mathematics Chapter 10 10


Graph Terminology

Definition: The degree of a vertex in an undirected


graph is the number of edges incident with it, except
that a loop at a vertex contributes twice to the
degree of that vertex.
In other words, you can determine the degree of a
vertex in a displayed graph by counting the lines
that touch it.
The degree of the vertex v is denoted by deg(v).

04/17/2025 Discrete Mathematics Chapter 10 11


Graph Terminology

A vertex of degree 0 is called isolated, since it is


not adjacent to any vertex.
Note: A vertex with a loop at it has at least degree 2
and, by definition, is not isolated, even if it is not
adjacent to any other vertex.
A vertex of degree 1 is called pendant. It is
adjacent to exactly one other vertex.

04/17/2025 Discrete Mathematics Chapter 10 12


Graph Terminology
Example: Which vertices in the following graph are
isolated, which are pendant, and what is the maximum
degree? What type of graph is it?
f h
d
a e
g
b c f j

Solution: Vertex f is isolated, and vertices a, d and j are


pendant. The maximum degree is deg(g) = 5.
This graph is a pseudograph (undirected, loops).

04/17/2025 Discrete Mathematics Chapter 10 13


Graph Terminology
Let us look at the same graph again and determine
the number of its edges and the sum of the degrees
of all its vertices:
f h
d
a e
g
b c f j

Result: There are 9 edges, and the sum of all degrees is 18.
This is easy to explain: Each new edge increases the sum of
degrees by exactly two.

04/17/2025 Discrete Mathematics Chapter 10 14


Graph Terminology
The Handshaking Theorem: Let G = (V, E) be an
undirected graph with e edges. Then
2e = vV deg(v)

Example: How many edges are there in a graph with


10 vertices, each of degree 6?
Solution: The sum of the degrees of the vertices is
610 = 60. According to the Handshaking Theorem,
it follows that 2e = 60, so there are 30 edges.

04/17/2025 Discrete Mathematics Chapter 10 15


Graph Terminology
Theorem: An undirected graph has an even number of
vertices of odd degree.
Proof: Let V1 and V2 be the set of vertices of even and
odd degrees, respectively (Thus V1  V2 = , and V1
V2 = V).
Then by Handshaking theorem
2|E| = vV deg(v) = vV1 deg(v) + vV2 deg(v)
Since both 2|E| and vV1 deg(v) are even,
vV2 deg(v) must be even.
Since deg(v) if odd for all vV2, |V2| must be even.
QED
04/17/2025 Discrete Mathematics Chapter 10 16
Graph Terminology

Definition: When (u, v) is an edge of the graph G


with directed edges, u is said to be adjacent to v,
and v is said to be adjacent from u.
The vertex u is called the initial vertex of (u, v),
and v is called the terminal vertex of (u, v).
The initial vertex and terminal vertex of a loop are
the same.

04/17/2025 Discrete Mathematics Chapter 10 17


Graph Terminology
Definition: In a graph with directed edges, the in-
degree of a vertex v, denoted by deg-(v), is the
number of edges with v as their terminal vertex.
The out-degree of v, denoted by deg+(v), is the
number of edges with v as their initial vertex.

Question: How does adding a loop to a vertex


change the in-degree and out-degree of that vertex?
Answer: It increases both the in-degree and the out-
degree by one.

04/17/2025 Discrete Mathematics Chapter 10 18


Graph Terminology
Example: What are the in-degrees and out-degrees of
the vertices a, b, c, d in this graph:

deg-(a) = 1 deg-(b) = 4
a
deg+(a) = 2 b deg+(b) = 2

deg-(d) = 2 deg-(c) = 0
d c
deg+(d) = 1 deg+(c) = 2

04/17/2025 Discrete Mathematics Chapter 10 19


Graph Terminology

Theorem: Let G = (V, E) be a graph with directed


edges. Then:
vV deg-(v) = vV deg+(v) = |E|

This is easy to see, because every new edge


increases both the sum of in-degrees and the sum of
out-degrees by one.

04/17/2025 Discrete Mathematics Chapter 10 20


Special Graphs
Definition: The complete graph on n vertices,
denoted by Kn, is the simple graph that contains
exactly one edge between each pair of distinct
vertices.

K1 K2 K3 K4 K5

04/17/2025 Discrete Mathematics Chapter 10 21


Special Graphs
Definition: The cycle Cn, n  3, consists of n
vertices v1, v2, …, vn and edges {v1, v2}, {v2, v3}, …,
{vn-1, vn}, {vn, v1}.

C3 C4 C5 C6

04/17/2025 Discrete Mathematics Chapter 10 22


Special Graphs
Definition: We obtain the wheel Wn when we add an
additional vertex to the cycle Cn, for n  3, and
connect this new vertex to each of the n vertices in C n
by adding new edges.

W3 W4 W5 W6

04/17/2025 Discrete Mathematics Chapter 10 23


Special Graphs
Definition: The n-cube, denoted by Qn, is the graph
that has vertices representing the 2 n bit strings of
length n. Two vertices are adjacent if and only if the
bit strings that they represent differ in exactly one bit
position.
110 111
10 11 100 101
010 011
0 1
00 01 000 001

Q1 Q2 Q3

04/17/2025 Discrete Mathematics Chapter 10 24


Special Graphs
Definition: A simple graph is called bipartite if its
vertex set V can be partitioned into two disjoint
nonempty sets V1 and V2 such that every edge in the
graph connects a vertex in V1 with a vertex in V2 (so
that no edge in G connects either two vertices in V 1 or
two vertices in V2).
For example, consider a graph that represents each
person in a village by a vertex and each marriage by
an edge.
This graph is bipartite, because each edge connects a
vertex in the subset of males with a vertex in the
subset of females (if we think of traditional
marriages).
04/17/2025 Discrete Mathematics Chapter 10 25
Special Graphs
Example I: Is C3 bipartite?
v1 No, because there is no way to partition the
vertices into two sets so that there are no edges
with both endpoints in the same set.
v2 v3

Example II: Is C6 bipartite?


v1 v1
v6 v6
Yes, because we
v5 v2
v2 v5 can display C6 like
this:
v3 v4
v3 v4
04/17/2025 Discrete Mathematics Chapter 10 26
Special Graphs
Definition: The complete bipartite graph Km,n is the
graph that has its vertex set partitioned into two subsets
of m and n vertices, respectively. Two vertices are
connected if and only if they are in different subsets.

K3,2 K3,4

04/17/2025 Discrete Mathematics Chapter 10 27


Operations on Graphs
Definition: A subgraph of a graph G = (V, E) is a
graph H = (W, F) where WV and FE.
Note: Of course, H is a valid graph, so we cannot
remove any endpoints of remaining edges when
creating H.
Example:

subgraph of K5
K5

04/17/2025 Discrete Mathematics Chapter 10 28


Operations on Graphs
Definition: The union of two simple graphs G1 =
(V1, E1) and G2 = (V2, E2) is the simple graph with
vertex set V1  V2 and edge set E1  E2.
The union of G1 and G2 is denoted by G1  G2.

G1 G2 G1  G2 = K5

04/17/2025 Discrete Mathematics Chapter 10 29


Representing Graphs
a a
d
b b
d
c c

Adjacent Initial Terminal


Vertex
Vertices Vertex Vertices
a b, c, d a c
b a, d b a
c a, d c
d a, b, c d a, b, c
04/17/2025 Discrete Mathematics Chapter 10 30
Representing Graphs
Definition: Let G = (V, E) be a simple graph with |V| =
n. Suppose that the vertices of G are listed in arbitrary
order as v1, v2, …, vn.
The adjacency matrix A (or AG) of G, with respect to
this listing of the vertices, is the nn zero-one matrix
with 1 as its (i, j)th entry when v i and vj are adjacent, and
0 otherwise.
In other words, for an adjacency matrix A = [aij],
aij = 1 if {vi, vj} is an edge of G,
aij = 0 otherwise.
04/17/2025 Discrete Mathematics Chapter 10 31
Representing Graphs
Example: What is the adjacency a
matrix AG for the following graph G b
based on the order of vertices a, b, c, d
d?
c
Solution: 0 1 1 1
1 0 0 1
AG 
1 0 0 1
 
1 1 1 0

Note: Adjacency matrices of undirected graphs are always


symmetric.
04/17/2025 Discrete Mathematics Chapter 10 32
Representing Graphs
Definition: Let G = (V, E) be an undirected graph
with |V| = n. Suppose that the vertices and edges of
G are listed in arbitrary order as v1, v2, …, vn and e1,
e2, …, em, respectively.
The incidence matrix of G with respect to this
listing of the vertices and edges is the nm zero-one
matrix with 1 as its (i, j)th entry when edge e j is
incident with vi, and 0 otherwise.
In other words, for an incidence matrix M = [mij],
mij = 1 if edge ej is incident with vi
mij = 0 otherwise.
04/17/2025 Discrete Mathematics Chapter 10 33
Representing Graphs
Example: What is the incidence a 1
matrix M for the following graph G 2
based on the order of vertices a, b, b
d 3
c, d and edges 1, 2, 3, 4, 5, 6? 5
4 c
Solution:
 1 1 0 0 1 0 6
 1 0 1 0 0 0
M  
 0 0 0 1 1 1
 
 0 1 1 1 0 0 
Note: Incidence matrices of directed graphs contain two 1s per
column for edges connecting two vertices and one 1 per column
for loops.
04/17/2025 Discrete Mathematics Chapter 10 34
Isomorphism of Graphs
Definition: The simple graphs G1 = (V1, E1) and G2 =
(V2, E2) are isomorphic if there is a bijection (an one-
to-one and onto function) f from V 1 to V2 with the
property that a and b are adjacent in G1 if and only if
f(a) and f(b) are adjacent in G2, for all a and b in V1.
Such a function f is called an isomorphism.
In other words, G1 and G2 are isomorphic if their
vertices can be ordered in such a way that the
adjacency matrices MG1 and MG2 are identical.

04/17/2025 Discrete Mathematics Chapter 10 35


Isomorphism of Graphs
From a visual standpoint, G1 and G2 are isomorphic
if they can be arranged in such a way that their
displays are identical (of course without changing
adjacency).
Unfortunately, for two simple graphs, each with n
vertices, there are n! possible isomorphisms that we
have to check in order to show that these graphs are
isomorphic.
However, showing that two graphs are not
isomorphic can be easy.

04/17/2025 Discrete Mathematics Chapter 10 36


Isomorphism of Graphs
For this purpose we can check invariants, that is,
properties that two isomorphic simple graphs must both
have.
For example, they must have
the same number of vertices,
the same number of edges, and
the same degrees of vertices.
Note that two graphs that differ in any of these
invariants are not isomorphic, but two graphs that
match in all of them are not necessarily isomorphic.
04/17/2025 Discrete Mathematics Chapter 10 37
Isomorphism of Graphs
Example I: Are the following two graphs isomorphic?
a a

b e e
b
c d c d

Solution: Yes, they are isomorphic, because they can be


arranged to look identical. You can see this if in the right graph
you move vertex b to the left of the edge {a, c}. Then the
isomorphism f from the left to the right graph is: f(a) = e, f(b) =
a, f(c) = b, f(d) = c, f(e) = d.

04/17/2025 Discrete Mathematics Chapter 10 38


Isomorphism of Graphs
Example II: How about these two graphs?
a a
b
e e
b
c c
d d

Solution: No, they are not isomorphic, because they differ in


the degrees of their vertices.
Vertex d in right graph is of degree one, but there is no such
vertex in the left graph.

04/17/2025 Discrete Mathematics Chapter 10 39


Connectivity
Definition: A path of length n from u to v, where n
is a positive integer, in an undirected graph is a
sequence of edges e1, e2, …, en of the graph such that
e1 = {x0, x1}, e2 = {x1, x2}, …, en = {xn-1, xn}, where
x0 = u and xn = v.
When the graph is simple, we denote this path by its
vertex sequence x0, x1, …, xn, since it uniquely
determines the path.
The path is a circuit if it begins and ends at the same
vertex, that is, if u = v.

04/17/2025 Discrete Mathematics Chapter 10 40


Connectivity
Definition (continued): The path or circuit is said
to pass through or traverse x1, x2, …, xn-1.
A path or circuit is simple if it does not contain the
same edge more than once.

04/17/2025 Discrete Mathematics Chapter 10 41


Connectivity
Let us now look at something new:
Definition: An undirected graph is called connected if
there is a path between every pair of distinct vertices in
the graph.
For example, any two computers in a network can
communicate if and only if the graph of this network is
connected.
Note: A graph consisting of only one vertex is always
connected, because it does not contain any pair of
distinct vertices.

04/17/2025 Discrete Mathematics Chapter 10 42


Connectivity
Example: Are the following graphs connected?
a b a
b
e e
d
d c
c
Yes. No.
a b a
b
e d e
c
d f
c No.
Yes.
04/17/2025 Discrete Mathematics Chapter 10 43
Connectivity
Definition: A graph that is not connected is the union
of two or more connected subgraphs, each pair of
which has no vertex in common. These disjoint
connected subgraphs are called the connected
components of the graph.

04/17/2025 Discrete Mathematics Chapter 10 44


Connectivity
Example: What are the connected components in the
following graph?

f h
d
a e
g
b c f j

Solution: The connected components are the graphs with vertices


{a, b, c, d}, {e}, {f}, {f, g, h, j}.

04/17/2025 Discrete Mathematics Chapter 10 45


Connectivity

Definition: An directed graph is strongly connected


if there is a path from a to b and from b to a
whenever a and b are vertices in the graph.

Definition: An directed graph is weakly connected


if there is a path between any two vertices in the
underlying undirected graph.

04/17/2025 Discrete Mathematics Chapter 10 46


Connectivity
Example: Are the following directed graphs strongly
or weakly connected?

a
b Weakly connected, because, for example,
d there is no path from b to d.

c
a
Strongly connected, because there are
b paths between all possible pairs of
d vertices.
c
04/17/2025 Discrete Mathematics Chapter 10 47
Shortest Path Problems
We can assign weights to the edges of graphs, for
example to represent the distance between cities in
a railway network:
Toronto
650

700 Boston
Chicago
200
600
New York

04/17/2025 Discrete Mathematics Chapter 10 48


Shortest Path Problems
Such weighted graphs can also be used to model
computer networks with response times or costs as
weights.
One of the most interesting questions that we can
investigate with such graphs is:
What is the shortest path between two vertices in the
graph, that is, the path with the minimal sum of
weights along the way?
This corresponds to the shortest train connection or
the fastest connection in a computer network.

04/17/2025 Discrete Mathematics Chapter 10 49


Dijkstra’s Algorithm
Dijkstra’s algorithm is an iterative procedure that
finds the shortest path between to vertices a and z
in a weighted graph.
It proceeds by finding the length of the shortest
path from a to successive vertices and adding these
vertices to a distinguished set of vertices S.
The algorithm terminates once it reaches the
vertex z.

04/17/2025 Discrete Mathematics Chapter 10 50


The Traveling Salesman Problem
The traveling salesman problem is one of the
classical problems in computer science.
A traveling salesman wants to visit a number of
cities and then return to his starting point. Of course
he wants to save time and energy, so he wants to
determine the shortest path for his trip.
We can represent the cities and the distances between
them by a weighted, complete, undirected graph.
The problem then is to find the circuit of minimum
total weight that visits each vertex exactly one.

04/17/2025 Discrete Mathematics Chapter 10 51


The Traveling Salesman Problem
Example: What path would the traveling salesman
take to visit the following cities?
Toronto

650 550
700
700 Boston
Chicago
200
600

New York
Solution: The shortest path is Boston, New York, Chicago,
Toronto, Boston (2,000 miles).
04/17/2025 Discrete Mathematics Chapter 10 52
The Traveling Salesman Problem
Question: Given n vertices, how many different
cycles Cn can we form by connecting these vertices
with edges?
Solution: We first choose a starting point. Then we
have (n – 1) choices for the second vertex in the cycle,
(n – 2) for the third one, and so on, so there are (n –
1)! choices for the whole cycle.
However, this number includes identical cycles that
were constructed in opposite directions. Therefore,
the actual number of different cycles Cn is (n – 1)!/2.

04/17/2025 Discrete Mathematics Chapter 10 53


The Traveling Salesman Problem
Unfortunately, no algorithm solving the traveling
salesman problem with polynomial worst-case time
complexity has been devised yet.
This means that for large numbers of vertices, solving
the traveling salesman problem is impractical.
In these cases, we can use efficient approximation
algorithms that determine a path whose length may
be slightly larger than the traveling salesman’s path,
but

04/17/2025 Discrete Mathematics Chapter 10 54

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy