Chap8 Complete
Chap8 Complete
2022
1/71
Outline
Graphs Connectivity
Graphs Paths
Types of Graphs Connectedness In
Graphs Terminology Undirected Graphs
Graphs Terminology How Connected is a
Some Special Simple Graph?
Graphs Connectedness in Directed
Bipartite Graphs Graphs
New Graphs from Old Paths and Isomorphism
Representing Graphs Counting Paths Between
Representing Graphs Vertices
Adjacency Matrices Euler and Hamilton Paths
Incidence Matrices Euler Paths & Circuits
Isomorphism of Graphs Hamilton Paths & Circuits
2/71
Va 24 overtex vI
Graphs
& ,
&
G -
edge
, e ,
23
⑧ · -
v
vs' er
Definition
A graph G = (V , E ) consists of V , a nonempty set of
vertices (or nodes) and E , a set of edges. Each edge has
either one or two vertices associated with it, called its
endpoints. An edge is said to connect its endpoints.
Remark
The set of vertices V of a graph G may be infinite. A graph
with an infinite vertex set or an infinite number of edges is
called an infinite graph, and in comparison, a graph with a
finite vertex set and a finite edge set is called a finite graph.
3/71
Types of Graphs
Suppose that a network is made up of data centers and
communication links between computers. This computer
network can be modeled using a graph in which the vertices of
the graph represent the data centers and the edges represent
communication links.
A graph in which each edge connects two di↵erent vertices
and where no two edges connect the same pair of vertices is
called a simple graph. (no direction)
7
S
S
7
[
4/71
Types of Graphs - undirected
-
multiple edges
5/71
Types of Graphs =
undirected
multiple edges
loops
-
6/71
Types of Graphs
To construct a graph model, we may find it necessary to assign
directions to the edges of a graph.
Definition
A directed graph (or digraph) (V , E ) consists of a nonempty set
of vertices V and a set of directed edges (or arcs) E . Each
directed edge is associated with an ordered pair of vertices. The
directed edge associated with the ordered pair (u, v ) is said to start
at u and end at v .
When a directed graph has no loops and has no multiple directed
edges, it is called a simple directed graph.
7/71
Types of Graphs
8/71
Types of Graphs
9/71
u :
V
Graphs Terminology U a
adjacent
· v
not
adjacent
no edges connect the
> because there is
-
two vertices
.
Definition
Two vertices u and v in an undirected graph G are called
adjacent (or neighbours) in G if u and v are endpoints of an
sebelah-nyebelah
edge e of G . Such an edge e is called incident with the
vertices u and v and e is said to connect u and v .
Definition
The set of all neighbours of a vertex v of G = (V , E ), denoted
by N(v ), is called the neighbourhood of v . If A is a subset
of V , we denote by N(A) the set of all vertices in S
G that are
adjacent to at least one vertex in A. So, N(A) = v 2A N(v ).
10/71
Graphs 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. The
degree of the vertex v is denoted by deg(v ).
D
(a) = 2
&
deg
I 2
(b) = 2
a
L
· deg
2
11/71
Graphs Terminology
Example Solution:
Remark
A vertex of degree zero is called isolated.
A vertex is pendant if and only if it has degree one.
12/71
Graphs Terminology
pseudograph
Example
What are the degrees and
what are the neighborhoods Solution:
of the vertices in the graph
loop brings
a
13/71
Graphs Terminology
THE HANDSHAKING THEOREM
Let G = (V , E ) be an undirected graph with m edges. Then
X
2m = deg(v ).
v 2V
(Note that this applies even if multiple edges and loops are
present.)
Example
How many edges are there in a graph with 10 vertices each of
-
degree
-
six?
Solution:
The sum of the degrees of the vertices is 6 · 10 = 60. Thus,
2m = 60 ) m = 30 edges
14/71
a b
Graphs Terminology
ac
Theorem
An undirected graph has an even number of vertices of odd
degree.
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 or end vertex of (u, v ). The
initial vertex and terminal vertex of a loop are the same.
15/71
Graphs Terminology
Definition
in
one
going
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
that going
the one out
U a sou
dey(u)
=0 Gegt(u) =
+
(v) =
1 deg
deg-(v) =
16/71
Graphs Terminology directed
graph must
two
declare
degrees.
Example
Find the in-degree and out-degree of each vertex in the graph.
Solution:
in
deg (a) = 2, deg (b) = 2, deg (c) = 3,
deg (d) = 2, deg (e) = 3, deg (f ) = 0,
+
deg (a) = 4, +
deg (b) = 1, deg+ (c) = 2, out
deg+ (d) = 2, deg+ (e) = 3, deg+ (f ) = 0.
17/71
Graphs Terminology
Theorem
Let G = (V , E) be a graph with directed edges. Then
X X
deg (v ) = deg+ (v ) = |E |.
v 2V v 2V
In other words, the sum of the in-degrees and the sum of the
out-degrees of all vertices in a graph with directed edges are
the same.
18/71
Some Special Simple Graphs a is number of
vertices
Complete Graphs
A complete graph on n vertices, denoted byO Kn , is a simple
graph that contains exactly one edge between each pair of
distinct vertices. A simple graph for which there is at least one
pair of distinct vertex not connected by an edge is called
noncomplete.
19/71
Some Special Graphs
Cycles
A cycle Cn , n 3, consists of n vertices v1 , v2 , . . . , vn and
edges {v1 , v2 }, {v2 , v3 }, . . . , {vn 1 , vn }, and {vn , v1 }.
20/71
Some Special Graphs
Wheels
We obtain a wheel Wn when we add an additional vertex to a
cycle Cn , for n 3, and connect this new vertex to each of
the n vertices in Cn , by new edges.
21/71
Some Special Graphs
n-Cubes
An n-dimensional hypercube, or n-cube, denoted by Qn , is
a graph that has vertices representing the 2n bit strings of
length n. Two vertices are adjacent if and only if the bit
strings that they represent di↵er in exactly one bit position.
22/71
Bipartite Graphs
Definition
A simple graph G is called bipartite if its vertex set V can be
partitioned into two disjoint sets V1 and V2 such that every edge
in the graph connects a vertex in V1 and a vertex in V2 (so that no
edge in G connects either two vertices in V1 or two vertices in V2 ).
When this condition holds, we call the pair (V1 , V2 ) a bipartition
of the vertex set V of G .
Example
C6 is bipartite since its vertex set
can be partitioned into the two
sets V1 = {v1 , v3 , v5 } and
V2 = {v2 , v4 , v6 } and every edge
of C6 connects a vertex in V1
and a vertex in V2 .
23/71
Bipartite Graphs
Example
K3 is not bipartite. Note that
if we divide the vertex set of
K3 into two disjoint sets, one
of the two sets must contain
two vertices.
If the graph were bipartite,
these two vertices could not be
connected by an edge, but in
K3 each vertex is connected to
every other vertex by an edge.
24/71
Bipartite Graphs
Example
Are the graphs G and H bipartite? v, = (a ,
c)
vz =
&a , b
, d3
O 8 O
O
Solution:
G is bipartite because its vertex set is the union of two disjoint
sets, {a, b, d} and {c, e, f , g }.
H is not bipartite because its vertex set cannot be partitioned into
two subsets so that edges do not connect two vertices from the
same subset. 25/71
Complete Bipartite Graphs
A complete bipartite graph Km,n is a graph that has its
vertex set partitioned into two subsets of m and n vertices,
respectively with an edge between two vertices if and only if
one vertex is in the first subset and the other vertex is in the
second subset.
set
Oh
C
-
secondet
26/71
New Graphs from Old
Definition
A subgraph of a graph G = (V , E ) is a graph H = (W , F )
where W ✓ V and F ✓ E .
Definition
Let G = (V , E ) be a simple graph. The subgraph induced
by a subset W of the vertex set V is the graph (W , F ), where
the edge set F contains an edge in E if and only if both
endpoints of this edge are in W.
27/71
New Graphs from Old
Example
The graph G shown is a subgraph of K5 . If we add the edge
connecting c and e to G , we obtain the subgraph induced by
W = {a, b, c, e}.
28/71
New Graphs from Old
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 .
29/71
Representing Graphs
One way to represent a graph with no multiple edges is to use
adjacency lists, which specify the vertices that are adjacent
to each vertex of the graph.
Example
Use adjacency lists to describe Solution:
the simple graph
Vertex Adjacent Vertices
a b, c, e
b a
c a, d, e
d c, e
e a, c, d
30/71
Representing Graphs
Example
Use adjacency lists to describe Solution:
the directed graph
Vertex Adjacent Vertices
a b, c, d, e
b b, d
c a, c, e
d
e b, c, d
31/71
IMPORTANT
Adjacency Matrices
The adjacency matrix A (or AG ) of G is the n ⇥ n zero-one
matrix, AG = [aij ], where
⇢
1 if {vi , vj } is an edge of G ,
aij =
0 otherwise.
Example
Solution:
Use an adjacency matrix to
We order the vertices as
represent the graph
a, b, c, d. 4x4 vertices
2 3
mirror
0 1 1 1 &
6 1 0 1 0 7b
AG = 6 4 1 1 0 0 5E
7
1 0 0 0 &
ab C d
32/71
Adjacency Matrices
Example
Solution:
Draw a graph with adjacency
matrix
2 3
0 1 1 0
6 1 0 0 1 7
AG = 64 1
7
0 0 1 5
0 1 1 0
Remark
Note that an adjacency matrix of a graph is based on the ordering
chosen for the vertices. Hence, there may be as many as n!
di↵erent adjacency matrices for a graph with n vertices, because
there are n! di↵erent orderings of n vertices. 33/71
Adjacency Matrices
I The adjacency matrix of a simple graph is symmetric.
I Since a simple graph has no loops, each entry
aii , i = 1, 2, 3, . . . , n is 0.
I Adjacency matrices can also be used to represent
undirected graphs with loops and with multiple edges.
I A loop at the vertex vi is represented by a 1 at the (i, i)th
position of the matrix.
I When multiple edges or loops at the same vertex are
present, the adjacency matrix is no longer a zero-one
matrix.
I All undirected graphs, including multigraphs and
pseudographs gave symmetric adjacency matrices.
I The adjacency matrices for a directed graph does not
have to be symmetric because there may be not be an
edge from vj to vi when there is an edge from vi to vj .
34/71
Adjacency Matrices
Example
Use an adjacency matrix to Solution:
represent the pseudograph We order the vertices as
a, b, c, d.
bcd
2a 3
0 1 0 1
· 66 0 1 0 1 7
7
AG = 4
1 1 0 0 5
a 0 1 0 0
35/71
Adjacency Matrices
Example
Use an adjacency matrix to Solution:
represent We order the vertices as
a, b, c, d.
bcd
2A 3
0 3 0 2
:
6 3 0 1 1 7
AG = 6 4 0
7
1 1 2 5
2 1 2 0
36/71
Incidence Matrices
Let G = (V , E ) be an undirected graph. Suppose that
v1 , v2 , . . . , vn are the vertices and e1 , e2 , . . . , em are the edges of G .
Then the incidence matrix with respect to this ordering of V and
E is the n ⇥ m matrix M = [mij ], where
⇢
1 when edge ej is incident with vi ,
mij =
0 otherwise.
Example
2
Represent the following graph Solution:
with an incidence matrix. -
&
E
37/71
Incidence Matrices
Example
Represent the following graph with an incidence matrix.
Solution:
38/71
Isomorphism of Graphs
two graphs
Definition
The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are
isomorphic if there exists a one-to-one and onto function f
from V1 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. Two
simple graphs that are not isomorphic are called
nonisomorphic.
In other words, when two simple graphs are isomorphic, there
is a one-to-one correspondence between vertices of the two
graphs that preserves the adjacency relationship.
39/71
Isomorphism of Graphs
Example
Solution: The function f with
Show that the graphs
f (u1 ) = v1 , f (u2 ) = v4 , f (u3 ) = v3 ,
G = (V , E ) and H = (W , F )
and f (u4 ) = v2 is a one- to-one
are isomorphic.
correspondence between V and W .
↓I
To see that this correspondence
preserves adjacency, note that
adjacent vertices in G are u1 and u2 ,
↑ u1 and u3 , u2 and u4 , and u3 and u4 ,
& and each of the pairs f (u1 ) = v1 and
f (u2 ) = v4 , f (u1 ) = v1 and
↓
f (u3 ) = v3 , f (u2 ) = v4 and
f (u4 ) = v2 , and f (u3 ) = v3 and
f (u4 ) = v2 consists of two adjacent
vertices in H .
40/71
Isomorphism of Graphs
I It is often difficult to determine whether two simple
graphs are isomorphic.
I There are n! possible one-to-one correspondences between
the vertex sets of two simple graphs with n vertices.
I Testing each such correspondence to see whether it
preserves adjacency and nonadjacency is impractical if n
is at all large.
I Sometimes it is not hard to show that two graphs are not
isomorphic. In particular, we can show that two graphs
are not isomorphic if we can find a property only one of
the two graphs has, but that is preserved by isomorphism.
I A property preserved by isomorphism of graphs is called a
graphs invariant.
41/71
Isomorphism of Graphs
42/71
Isomorphism of Graphs
Example
Show that the graphs displayed below are not isomorphic.
2
S Z
I
1
3 4
5 5 Y
6
are not
these isomorphic
Solution:
Both G and H have five vertices and six edges. However, H
has a vertex of degree one, whereas G has no vertices of
degree one. It follows that G and H are not isomorphic.
43/71
Isomorphism of Graphs
Example
Determine whether the graphs shown below are isomorphic.
44/71
Isomorphism of Graphs
Solution:
The graphs G and H both have eight vertices and 10 edges.
They also both have four vertices of degree two and four of
degree three. Because these invariants all agree, it is still
conceivable that these graphs are isomorphic.
However, G and H are not isomorphic. To see this, note that
because deg(a) = 2 in G , a must correspond to either t, u, x,
or y in H, because these are the vertices of degree two in H.
However, each of these four vertices in H is adjacent to
another vertex of degree two in H, which is not true for a in G .
45/71
Isomorphism of Graphs
46/71
Isomorphism of Graphs
Example
Determine whether the graphs shown below are isomorphic.
Solution:
Both G and H have six vertices and seven edges. Both have four
vertices of degree two and two vertices of degree three. Because G
and H agree with respect to these invariants, it is reasonable to try
to find an isomorphism f .
47/71
Isomorphism of Graphs
We now will define a function f and then determine whether it
is an isomorphism. Because deg(u1 ) = 2 and because u1 is not
adjacent to any other vertex of degree two, the image of u1
must be either v4 or v6 , the only vertices of degree two in H
not adjacent to a vertex of degree two. We arbitrarily set
f (u1 ) = v6 . [If we found that this choice did not lead to
isomorphism, we would then try f (u1 ) = v4 .] Because u2 is
adjacent to u1 , the possible images of u2 are v3 and v5 . We
arbitrarily set f (u2 ) = v3 .
Continuing in this way, using adjacency of vertices and degrees
as a guide, we set f (u3 ) = v4 , f (u4 ) = v5 , f (u5 ) = v1 , and
f (u6 ) = v2 . We now have a one-to-one correspondence
between the vertex set of G and the vertex set of H, namely,
f (u1 ) = v6 , f (u2 ) = v3 , f (u3 ) = v4 , f (u4 ) = v5 , f (u5 ) =
v1 , f (u6 ) = v2 .
48/71
Isomorphism of Graphs
49/71
Paths
I A path is a sequence of edges that begins at a vertex of
a graph and travels from vertex to vertex along edges of
the graph.
I A path of length n from u to v in G is a sequence of n
edges e1 , e2 , . . . , en of G .
I When the graph is simple, we denote this path by its
vertex sequence x0 , x1 , . . . , xn .
I The path is a circuit if it begins and ends at the same
vertex.
I The path or circuit is said to pass through the vertices
x1 , x2 , . . . , xn 1 or traverse the edges e1 , e2 , . . . , en .
undirected
I A path or circuit is simple if it does not contain the same
edge more than once.
50/71
Paths
Example
52/71
Connectedness In Undirected Graphs
a diacent
vertices
55/71
How Connected is a Graph?
Example
Find the cut vertices and cut edges in the graph
on its own
Solution:
The cut vertices are b, c, and e. The removal of one of these
vertices (and its adjacent edges) disconnects the graph. The
cut edges are {a, b} and {c, e}. Removing either one of these
edges disconnects the graph. not
major a out subgrags
Vertex to become
56/71
Connectedness in Directed Graphs
& b
S
-
M
L
d L
57/71
Connectedness in Directed Graphs
Example
I There are several ways that paths and circuits can help
determine whether two graphs are isomorphic.
I For example, the existence of a simple circuit of a
particular length is a useful invariant that can be used to
show that two graphs are not isomorphic.
I In addition, paths can be used to construct mappings that
may be isomorphisms.
59/71
Paths and Isomorphism
if it is not isomorphic
then you don't have to find
60/71
Paths and Isomorphism
Solution:
I Both G and H have five vertices
and six edges. Each has two
Example vertices of degree three, three
Determine whether the graphs G vertices of degree two.
and H are isomorphic. I Both have a simple circuit of
length three, a simple circuit of
#*
length four and a simple circuit of
length five. Therefore, G and H
maybe isomorphic.
vide reve-length
, of s
u1 u2 u3 u4 u5 v3 v5 v1 v2 v4
2 3 2 3
u1 0 0 1 1 1 v3 0 0 1 1 1
u2 60 0 1 0 17 v5 60 0 1 0 17
6 7 6 7
AG = u 3 61 1 0 1 07 A H = v1 61 1 0 1 07
6 7 6 7
u4 41 0 1 0 05 v2 41 0 1 0 05
u5 1 1 0 0 0 v4 1 1 0 0 0
62/71
Counting Paths Between Vertices
I The number of paths between two vertices in a graph can be
determined using its adjacency matrix.
I Let G be a graph with adjacency matrix A. The number of
di↵erent paths of length r from vi to vj , where r is a positive
integer, equals the (i, j)th entry of Ar .
Example
How many paths of length four are there from a to d in the simple
b Cd
graph a
T]
I
g
, 0
-
63/71
Counting Paths Between Vertices
Solution:
First, find the adjacency matrix (ordering the vertices as
a, b, c, d, e). Next, find Ar
2 3 2 3
0 1 1 0 8 0 0 8
6 1 0 0 1 7 6 0 8 8 0 7
A=6
4 1
7 A4 = 6 7
0 0 1 5 4 0 8 8 0 5
0 1 1 0 8 0 0 8
64/71
Euler Paths & Circuits E-keyword for Euler
66/71
Euler Paths & Circuits
I A connected multigraph with at least two vertices has an
Euler circuit if and only if each of its vertices has even
degree.
encer circuit.
67/71
Euler Paths & Circuits
I A connected multigraph has an Euler path but not an Euler
circuit if and only if it has exactly two vertices of odd degree.
hamilton-vertex once
edge many times
-
70/71
Hamilton Paths & Circuits
Dirac’s Theorem
If G is a simple graph with n vertices with n 3 such that the
degree of every vertex in G is at least n/2, then G has a
Hamilton circuit.
Ore’s Theorem
If G is a simple graph with n vertices with n 3 such that
deg(u) + deg(v ) n for every pair of nonadjacent vertices u
and v in G , then G has a Hamilton circuit.
71/71