0% found this document useful (0 votes)
30 views

UNIT 5 Graph Theory

The document discusses graph theory and graph terminology. It defines different types of graphs such as simple graphs, multigraphs, pseudographs, directed graphs and their properties. It also defines graph terminology including degree, adjacency and regular graphs. Several examples of special graphs such as complete graphs, cycles, wheels and hypercubes are provided.

Uploaded by

Dishika Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

UNIT 5 Graph Theory

The document discusses graph theory and graph terminology. It defines different types of graphs such as simple graphs, multigraphs, pseudographs, directed graphs and their properties. It also defines graph terminology including degree, adjacency and regular graphs. Several examples of special graphs such as complete graphs, cycles, wheels and hypercubes are provided.

Uploaded by

Dishika Yadav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

Graph Theory

Outline
 Graph and Graph Models
 Graph Terminology and Special Types of
Graphs
 Representing Graphs and Graph Isomorphism
 Connectivity
 Euler and Hamiltonian Paths
 Shortest-Path Problems
 Planar Graphs
 Graph Coloring
2
Introduction to Graphs
Def 1. 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.
eg. G=(V, E), where
v1 V={v1,v2,…, v7}
v5
E={{v1,v2}, {v1,v3}, {v2,v3}
v3 v4 {v 3 ,v 4 }, {v 4 ,v 5 }, {v 4 ,v 6 }
v6
{v4,v7}, {v5,v6}, {v6,v7}}
v2 v7
3
Def A graph in which each edge connects two
different vertices and where no two edges connect
the same pair of vertices is called a simple graph.
Def Multigraph:
simple graph + multiple edges (multiedges)
(Between two points to allow multiple edges)
eg.
V1 V5

V3 V4
V6

V2 V7
4
Def. Pseudograph:
simple graph + multiedge
+ loop
(a loop: )

eg.

5
Def 2. Directed graph (digraph):
simple graph with each edge directed

Note: is allowed in a directed graph


Note:
u v u v

The two edges (u,v),(u,v) The two edges (u,v),


are multiedges. (v,u) are not multiedges.

Def. Directed multigraph: digraph+multiedges


6
Table 1. Graph Terminology
Type Edges Multipl Loops
e
Edges
(simple) graph undirected 🗴 🗴
edge: {u,v}
Multigraph 🗸 🗴
Pseudograph 🗸 🗸
Directed graph directed 🗴 🗸
Directed multigraph edge: (u,v) 🗸 🗸
7
Example 2. (Acquaintanceship graphs)
We can use a simple graph to represent whether
two people know each other. Each person is
represented by a vertex. An undirected edge is used
to connect two people when these people know each
other.
Jan Paula Todd Kamlesh

eg
Amy
Lila Lizd Steve

8
Example 3. (Influence graphs)
In studies of group behavior it is observed that
certain people can influence the thinking of others.
Simple digraph  Each person of the group is
represented by a vertex. There is a directed edge
from vertex a to vertex b when the person a
influences the person b.

eg Linda Brian

Deborah Fred Yvonne


9
Graph Terminology
Def 1. Two vertices u and v in a undirected graph G

are called adjacent (or neighbors) in G if {u, v}

is an edge of G.
Def 2. The degree of a vertex v, denoted by deg(v),
in an undirected graph is the number of edges
incident with it.

(Note : A loop adds 2 to the degree.)


11
Example 1. What are the degrees of the
vertices in the graph H ?

a b Solution :
c
deg(a)=4, deg(b)=6,
deg(c)=1, deg(d)=5,
deg(e)=6, and deg(f)=0
e d f
H
Def. A vertex of degree 0 is called isolated.
Def. A vertex is pendant if and only if it has degree
one.
12
1. Because of the analogy between an edge having two
endpoints and a handshake involving two hands. 2. Each
edge contributes two to the sum of the degrees of the
vertices because an edge is incident with exactly two
(possibly equal) vertices. This means that the sum of the
degrees of the vertices is twice the number of edges.
13
eg. The graph H has 11
a b c
edges, and

 deg( v)  22
vV
e d f
H

Example 3. How many edges are there in a


graph with 10 vertices each of
degree six?

Solution : 10  6 = 2e  e=30
14
THEOREM 2: An undirected graph has an even number of
vertices of odd degree.
Proof: Let V1 and V2 be the set of vertices of even degree
and the set of vertices of odd degree, respectively, in an
undirected graph G = (V, E) with m edges.Then

2m  deg(v)  deg(v)   deg(v)


vV vV1 vV2

2m - deg(v) = deg(v)
vV1 vV2

deg(v) is even.
vV2

Thus, there are an even number of vertices of odd degree. 15


Definition 3:
G = (V, E): directed graph,
e = (u, v)  E : u is adjacent to v The initial vertex and
terminal vertex of a
v is adjacent from u loop are the same u
u : initial vertex of e
v : terminal (end) vertex of e

u v
Def 4.
G = (V, E) : directed graph, vV
deg-(v) : # of edges with v as a terminal.
(in-degree)
deg+(v) : # of edges with v as a initial vertex
(out-degree)
Example 4.
b deg-(a)=2, deg+(a)=4
a c deg-(b)=2, deg+(b)=1
deg-(c)=3, deg+(c)=2
deg-(d)=2, deg+(d)=2
deg-(e)=3, deg+(e)=3
e d f deg-(f )=0, deg+(f )=0
17
Thm 3. Let G = (V, E) be a digraph. Then

18
Regular Graph
A simple graph G=(V, E) is called regular if
every vertex of this graph has the same
degree. A regular graph is called n-regular if
deg(v)=n , vV.
eg. K4 is 3-regular.

19
Some Special Simple Graphs
Example 5: 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

Note. Kn is (n-1)-regular, |V(Kn)|=n,

20
Example 6. 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

Note Cn is 2-regular, |V(Cn)| = n, |E(Cn)| = n

21
Example 7. We obtained 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 Cn, by new edges.
W6
W5

Note. |V(Wn)| = n + 1, |E(Wn)| = 2n,


Wn is not a regular graph if n  3. 28
Example 8. The n-dimensional hypercube, or
n-cube, denoted by Qn, is the 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 differ in exactly one
bit position.
110 111
10 11
0 1 100 101

Q1 010
00 01 011
Q2
000 001
Q3

Note. Qn is n-regular, |V(Qn)| = 2n, |E(Qn)| = (2nn)/2 =2n-1n


29
Some Special Simple Graphs
Def 5. A simple graph G=(V, E) is called bipartite if
V can be partitioned into V1 and V2, V1∩V2=,
such that every edge in the graph connect a
vertex in V1 and a vertex in V2.
Example 9.

v1 v2

∴ C6 is bipartite.
v3 v4

v5 v6

V1 V2 30
Example 10. Is the graph G bipartite ?
a b a
c

g
c e
b

f
f d d
g
e

G Yes !
25
Thm 4. A simple graph is bipartite if and only if it is
possible to assign one of two different colors to
each vertex of the graph so that no two adjacent
vertices are assigned the same color.
Example 12. Use Thm 4 to show that G is bipartite.
1a 1b

2g 2
c
2
f 1
d
2
e
G
26
Definition: 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.

27
Example 11: Complete Bipartite graphs (Km,n)

K2,3 K3,3

Note: |V(Km,n)| = m+n, |E(Km,n)| = mn,


Km,n is regular if and only if m=n.

28
EXERCISE
For which values of n are these graphs bipartite?
a) Kn
b) Cn
c) Wn
d) Qn
New Graphs from Old
Def 6. A subgraph of a graph G=(V, E) is a
graph H=(W, F) where W  V and F  E.
Example 14. A subgraph of K5
a a

e b b
e

d c c
K5 subgraph of K5
36
Def 7. The union of two simple graphs
G1=(V1, E1) and G2=(V2, E2) is the simple graph
G1𝖴G2=(V1𝖴V2, E1𝖴E2)
Example 15.
a b c a b c

G1 G2

d e d f
a b c

G1𝖴G2

37
d e f
Adjacency and Terminal vertices

Example 1. Use adjacency lists to describe the


simple graph given below.

b
Sol : Vertex Adjacent Vertices
a b,c,e
a c b a
c a,d,e
d c,e
e d
e a,c,d
36
Example 2. (digraph)

b
Initial vertex Terminal vertices
c a b,c,d,e
a
b b,d
c a,c,e
d
e b,c,d
e d

37
Adjacency Matrices
Def. G=(V, E) : simple graph, V={v1,v2,…,vn}.
A matrix A is called the adjacency matrix of G
if A=[aij]nn , where aij = 1, if {vi,vj}E,
0, otherwise.
Example 3.
a b

c d

Note:
1.There are n! different adjacency matrices for a graph with n vertices.
2.The adjacency matrix of an undirected graph is symmetric.
3. aii = 0 (simple matrix has no loop) 44
Example 5. (Pseudograph) (Matrix may not be 0,1 matrix.)

a b

d
c

Def. If A=[aij] is the adjacency matrix for the directed


graph, then
1 , if
vi vj (So the matrix is
aij = not necessarily
0 , otherwise symmetrical)

45
EXERCISES
Identify whether
the adjacency
matrix of the
following directed
graphs is
symmetrical or not.
Incidence Matrices
Def. Let G=(V, E) : be an undirected graph. Suppose that
v1,v2,…,vn are the vertices and e1,e2,…,en are the edges of G .
Then the incidence matrix with respect to this ordering of V
and E is the n x m matrix M=[mij], where

m i, j  
1 when edge e j is incident with vi ,
0 otherwise.

Example 7.
Example 6.

41
Isomorphism of Graphs
u1 u2 v1 v2
G is isomorphic to H
u3 u4 v3 v4
G H

Def 1. The simple graphs G1=(V1, E1) and G2=(V2,


E2) are isomorphic if there is an one-to-one
and onto function f from V1 to V2 with the
property that a~b in G1 iff f(a)~f(b) in G2,
a,bV1. f is called an isomorphism.

42
Example 8. Show that G and H are isomorphic.
u1 u2 v1 v2

u3 u4 v3 v4
G H
Sol. The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3,
and f(u4) = v2 is a one-to-one correspondence
between V(G) and V(H).
※Isomorphism graphs there will be:
(1) The same number of points (vertices)
(2) The same number of edges
(3) The same number of degree
43
Given figures, judging whether they are isomorphic in
general is not an easy task.

Example 9. Show that G and H are not isomorphic.

G H

Sol :
G has a vertex of degree = 1 , H don’t

44
Example 10.
Determine whether G and H are isomorphic.
a b s t
e w x
f
g
h z y
d c
v u
G H
Sol : ∵ In G, deg(a)=2, which must correspond to either t, u,
x, or y in H degree
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
∴ G and H are not isomorphic.
45
Example 11. Determine whether the graphs G and H
are isomorphic.

G v1 H
u1 u2 v3

u5 v2
u6 v6
v5
u4 u3 v4

Sol:
f(u1)=v6, f(u2)=v3, f(u3)=v4, f(u4)=v5, f(u5)=v1, f(u6)=v2
Yes

46
Connectivity
Def. 1 :
In an undirected graph, a path of length n from u
to v is a sequence of n + 1 adjacent vertices going
from vertex u to vertex v.
(e.g., P: u=x0, x1, x2, … , xn=v.) ( P has n edges.)
Def. 2:
path: Points and edges in unrepeatable
trail: Allows duplicate point (path not repeatable)
walk: Allows duplicate point and duplicate path
Example 1:
v w
path: u, v, y
trail: u, v, w, y, v, x, y
u
walk: u, v, w, v, x, v, y
x y 58
53
Def:
cycle: path with u=v
circuit: trail with u=v
closed walk: walk with u=v

Example
G v w
cycle: u, v, y, x, u
trail: u, v, w, y, v, x, u
u
walk: u, v, w, v, x, v, y, x, u
x y

54
Paths in Directed Graphs
The same as in undirected graphs, but the path
must go in the direction of the arrows.

Connectedness in Undirected Graphs


Def. 3:
An undirected graph is connected if there is a
path between every pair of distinct vertices in the
graph.

55
EXAMPLE 6: The graph G1 in Figure 2 is connected,
because for every pair of distinct vertices there is a path
between them (the reader should verify this). However,
the graph G2 in Figure 2 is not connected. For instance,
there is no path in G2 between vertices a and d.

56
Connectedness in Directed Graphs
Def. 4: (a) A 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.

For a directed graph to be strongly connected there


must be a sequence of directed edges from any vertex
in the graph to any other vertex. A directed graph can
fail to be strongly connected but still be in “one piece.”

57
(b) A directed graph is weakly connected if there is a
path between every two vertices in the underlying
undirected graph.

That is, a directed graph is weakly connected if and only


if there is always a path between two vertices when the
directions of the edges are disregarded. Clearly, any
strongly connected directed graph is also weakly
connected.

Ch9-66
Example 9 Are the directed graphs G and H strongly
connected or weakly connected?

a b a b

G c H c

e d e d
strongly connected weakly connected

67
Paths and Isomorphism
Note that connectedness, and the existence of a
circuit or simple circuit of length k are graph
invariants with respect to isomorphism.

Example 12. Determine whether the graphs G and


H are isomorphic.
u1 v1
v2 v6
u2 u6
v3 v5
u3 u5
v4
G
u4 H
Sol: No, Because G has no simple circuit of length three, but H does 68
Example 13. Determine whether the graphs G and
H are isomorphic.
u2 v1
G H
u1 u3 v5 v2

u5 u4 v4
Sol. v3

Both G and H have 5 vertices, 6 edges, two vertices of


deg 3, three vertices of deg 2, a 3-cycle, a 4-cycle, and
a 5-cycle.  G and H may be isomorphic.
The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3,
f(u4) = v2 and f(u5) = v5 is a one-to-one correspondence
between V(G) and V(H).  G and H are isomorphic.

69
Counting Paths between Vertices

Theorem 2:
Let G be a graph with adjacency matrix A with respect to
the ordering v1, v2, … , vn. The number of walks of length r
from vi to vj is equal to (Ar)i,j.

74
Example 14. How many walks of length 4 are
there from a to d in the graph G?
a b
Sol.
The adjacency matrix of G G
(ordering as a, b, c, d) is d c
8 0 0 8
0 8 8 0
 A4   8
0 8 8 0
 
8 0 0 8

a-b-a-b-d, a-b-a-c-d, a-c-a-b-d, a-c-a-c-d,


a-b-d-b-d, a-b-d-c-d, a-c-d-b-d, a-c-d-c-d 75
An Euler circuit in a graph G is a simple circuit containing
every edge of G.
An Euler path in G is a simple path containing every edge
of G.
A connected graph G is Eulerian graph if there exist
Eulerian circuit in it.
Thm. 1: A connected multigraph with at least two
vertices has an Euler circuit if and only if
each of its vertices has even degree.
Thm. 2: A connected multigraph has an Euler path
(but not an Euler circuit) if and only if it has
exactly 2 vertices of odd degree.
67
Example 1. Which of the following graphs
have an Euler circuit or an Euler
path?
a a b G3
a b b

G1 e G2 e

d c d c c d e

Euler circuit none none

68
A simple path in a graph G that passes through every
vertex exactly once is called a Hamilton path, and a
simple circuit in a graph G that passes through every
vertex exactly once is called a Hamilton circuit(Hamilton
cycle).
A connected graph G is Hamiltonian graph if there exist
Hamiltion circuit in it.
Example 1. Which of the following graphs have
a Hamilton circuit or a Hamilton path?
a b a b
G1 G2
e c
d c
d

Hamilton circuit: G1 Hamilton path: G1,G2 78


Thm. 3 (Dirac’s Thm.):
If G is a simple graph with n  3 vertices such
that the degree of every vertex in G is at least
n/2, then G has a Hamilton circuit.

Example
b a
each vertex has deg  n/2 =3.5
c
g Hamilton circuit exists
Such as: a, c, e, g, b, d, f, a
f
d
e
70
Thm. 4 (Ore’s Thm.):
If G is a simple graph with n  3 vertices such that
deg(u) + deg(v)  n for every pair of nonadjacent
vertices u and v, then G has a Hamilton circuit.

Example
a
b each nonadjacent vertex pair
has deg sum  n = 7
g
c Hamilton circuit exists
Such as: a, d, f, e, c, b, g, a
f
d
e
71
Shortest-Path Problems
Def:
1. Graphs that have a number assigned
to each edge are called weighted graphs.
2. The length of a path in a weighted graph is
the sum of the weights of the edges of this
path.
3. Short-Path is the path of least sum of the
weights between two vertices in a weighted
graph.

72
Example 1. What is the length of a shortest path
between a and z in the weighted graph G?
b 3 c L=0
2
Sol. (1) a (2)a L=2
4 2
z L=4 b d
a 3
1 b
4
2
(3) 4
G d 3 e a (4)
a
2
2 L=5
d 3
d e
b
(5) a
4 L=6
z
1
length=6
2
d 3 e 82
Example 2. Use Dijkstra’s algorithm to find the
length of a shortest path between a and z in the
weighted graph. 4(a)
b 5 d b 5 d b 5 d
Sol.
4 6 4 6 4 6
a 1
8
z
0
a 1
8 z  0
a 1
8 z
2 2  2 
2 3 2 3 2 3
c 10 e c 10 e c 10 e
 2(a) 

3(c) 10(c) 3(c) 3(c) 8(b)


8(b)
b 5 d b 5 d b 5 d
 4 6  4 6  4 6
0 8 0 8 0 8
a z a z a 1 z 14
1 2  1 2  2 (d)
2 3 2 3 2 3
c 10 e c 10 e c 10 e
2(a) 12(c) 2(a) 12(c) 2(a) 10(d)
83
Contd

3(c) 8(b) 3(c) 8(b)


b 5 d b 5 d
4 6 4 6

0 8 0 8
a 1 z 14(d) a 1 z 13(e)
2 2
2 3 2 3
c 10 e c 10 e
2(a) 10(d) 2(a) 10(d)

3(c) 8(b)
b 5 d
 4 6  path: a, c, b, d, e, z
0 8
a 1 2
z 13(e) length: 13
2 3
c 10 e
2(a) 10(d)
75
76
Planar Graphs
Def 1.
A graph is called planar if it can be drawn in the
plane without any edge crossing. Such a drawing
is called a planar representation of the graph.
Example 1: Is K4 planar?

 K4 is planar

K4
K4 drawn with
no crossings
77
Example 2: Is Q3 planar?

 Q3 is planar

Q3 Q3 drawn with no crossings


Example 3: Show that K3,3 is nonplanar.
v1 v2 v3
Sol. In any planar representation of K3,3, the
vertices v1 and v2 must be connected to both
v4 and v5. These four edges form a closed
v4 v5 v6 curve that splits the plane into two regions,
R1 and R2, as shown in Figure 7(a).
78
The vertex v3 is in either R1 or R2. When v3 is in R2, the inside
of the closed curve, the edges between v3 and v4 and
between v3 and v5 separate R2 into two sub-regions, R21 and
R22, as shown in Figure 7(b).

79
Next, note that there is no way to place the final vertex v6
without forcing a crossing. For if v6 is in R1, then the edge
between v6 and v3 cannot be drawn without a crossing.
If v6 is in R21, then the edge between v2 and v6 cannot be
drawn without a crossing. If v6 is in R22, then the edge
between v1 and v6 cannot be drawn without a crossing.
A similar argument can be used when v3 is in R1. The
completion of this argument is left for the reader. It follows
that K3,3 is not planar.

80
Exercise: Determine whether the given graph is planar.

81
Graph Coloring
Def. 1:
A coloring of a simple graph is the assignment of a
color to each vertex of the graph so that no two
adjacent vertices are assigned the same color.
Example:
2 1 2 3

5 1
1 2 1 1

4 3 3 2
5-coloring 3-coloring
Less the number of colors, the better 99
Def. 2:The chromatic number of a graph is the least
number of colors needed for a coloring of this
graph. (denoted by (G))

Example 2: (K5)=5
1 2 4
2

5 3 1 5

4 3

Note: (Kn)=n
83
Example: (K2,3) = 2.
1 1

2 2 2

Note: (Km,n) = 2
Note: If G is a bipartite graph, (G) = 2.

84
Example 1: What are the chromatic numbers of the
graphs G and H?
b e b e

d d
a a g
g

c f c f
G H

Solution: The chromatic number of G is at least three,


because the vertices a,b, and c must be assigned different
colors. To see if G can be colored with three colors, assign
red to a, blue to b, and green to c. Then, d can (and must)
be colored red because it is adjacent to b and c.
85
Furthermore, e can (and must) be colored green because it
is adjacent only to vertices colored red and blue, and f can
(and must) be colored blue because it is adjacent only to
vertices colored red and green. Finally, g can (and must) be
colored red because it is adjacent only to vertices colored
blue and green. This produces a coloring of G using exactly
three colors. Figure 4 displays such a coloring.
The graph H is made up of the graph G with an edge
connecting a and g. Any attempt to color H using three colors
must follow the same reasoning as that used to color G,
except at the last stage, when all vertices other than g have
been colored. Then, because g is adjacent (in H) to vertices
colored red, blue, and green, a fourth color, say brown,
needs to be used. Hence, H has a chromatic number equal
to 4. A coloring of H is shown in Figure 4.
86
Blue Green Blue Green

Red Red
a g
Red
Red Red
Brown

Green Blue Green Blue


G H

Figure 4: Colorings of the graphs G and H.

87

Example 4: (Cn) = 2 if n is even,
3 if n is odd.

Cn is bipartite 1 2
when n is even.
3 1

Thm 1. (The Four Color Theorem)


The chromatic number of a planar graph is no
greater than four.

88
Corollary
Any graph with chromatic number > 4 is non-planar.

Example 5: K7 is not planar because its chromatic


number is 7 which is greater than 4.

89
90
91
Ch9-92
Ch9-93

You might also like