Chapter 4 (Graph Theory Edited)
Chapter 4 (Graph Theory Edited)
Introduction: Graph theory is a branch of mathematics that deals with arrangements of certain
objects and relationships between these objects. Graph theory is broadly classified into two:
undirected graphs and directed graphs (digraphs). In this chapter we will discuss a number of
important cases of undirected and directed graphs, as well as a few important properties that may
be possessed by graphs, such as planarity and colorability.
1
Transistors: - vertices
Wire: - edges.
2. Telephone communication
Telephones and switching center:-vertices
Telephone lines: -edges
3. Computer flow chart
Instructions:-vertices
Logical flow:-edge
Degree of a vertex: The degree of a vertex V in a graph G is equal to:
1. The number of edges in G which contain V if it has no loops.
2. The number of edges in G which contain V plus twice the number of loop(s) if it has loop(s).
Note: For a graph with loops, each loop contributes 2 to the degree of the corresponding vertex.
Definition: - i) A vertex is said to be even if its degree is even number and odd if its
degree is odd number.
ii) A vertex of degree zero is called isolated vertex.
iii) A vertex of degree one is called pendant vertex.
Minimum and maximum degree
Let G be a graph. The minimum and maximum degrees of G are denoted by (G) and (G)
respectively and given by:
(G)= min deg(v); v V (G)& (G) = max deg v; v V (G)
Example: Find the minimum and maximum degree of G given below.
v1 v2
G:
v3 v4
Solution: (G) =2, i.e., deg(v1)
(G) = 4, i.e., deg(v2)
Directed Graphs
Directed graphs are graphs in which the edges are one way. Such graphs are frequently more
useful in various dynamical systems such as:
▪ Digital computer
▪ Flow system
▪ Communication system
▪ Transportation system
Definition: a digraph D is a graph consisting of two things:
i) A set V whose elements are called vertices, Points or node of D
ii) A set E whose elements are order pairs (u,v) of distinct vertices called arcs or
directed edges of D.
Suppose e = (u,v) is a directed edge in a digraph D. Then the following terminologies are used.
▪ e begins at u and ends at v.
2
▪ u is the origin or initial point of e where as v is destination or terminal point of e.
▪ v is the successor of u and u is the predecessor of v.
▪ u is adjacent to v where as v is adjacent from u
▪ If u = v then e is a loop.
▪ The set of all successor of a vertex u is : suss (u) = {v V : (u, v) E}
Example 1: Let D be the directed graph shown in the following figure.
A e1 D
e4
e3 e6 e7
e2
e5
B
C
e8
▪ e4 = (D,B) (B,D)
▪ e8 is a loop.
▪ Succ(A) = {D}. That is D is adjacent from A.
▪ e6 and e7 are parallel arcs.
Sub diagraph: Let G(V,E) be a diagraph and let V be a subset of vertex set V of G. Suppose E
is a subset of E such that the end points of the edges in E belongs to V . Then H (V , E) is a sub
diagraph of G.
Example 3: Consider the digraph G:
A e1 D e4 C
e4 e6 e7
G: e2 e3 e6 e7 B
e8 e5 D
e8 e5 C
B
Fig. A Fig. B
Let V = {B,C,D} and E = {e4,e7,e5,e6,e8)
Then the sub diagraph H (V , E) of G (V,E) is constructed as in Fig. B above.
Degree: Suppose G is a direct graph. The out degree of a vertex v of G,
outdeg(V), is the number of edges incident from v, and the in degree of v,
indeg(u), is the number of edges incident to u.
Theorem: The sum of the out degrees of the vertices of the diagraph G equals the sum of
the in degrees of the vertices, which equals the number of edges in G.
Note: A vertex u in a diagraph with zero in degree is called a source and a vertex u with zero
outdegree is called a sink.
Example 5: In the digraph given below:
A
• A and D are sources since indeg(A) = indeg(D) =0
C • B and C are sinks since outdeg (B) = outdeg(C)= 0
B
3
The hand shaking lemma
In any undirected graph:
• Each edge has two ends and thus contributes 2 to the sum of vertices degrees.
• In a group of people shaking hands in a party, exactly two hands are involved in each
hand shakes
Theorem: In any undirected graph, the sum of all the vertex degrees is equal to twice the number
n
of edges. That is, deg(v ) = 2 E
i =1
i where E is an edge list.
Example 1: If a graph G has 10 edges with 2 vertices of degree 4 each and all others are of
degree 3 each, and then find the number of vertices V (G) .
Solution: E =10 and 2 vertices have degree 4. Let the other vertices which are of degree 3 each
be k in number.
n
deg(vi) = 2 E , n = 2 + k
i =1
2(4)+k(3)=2(10)
8+3k=20 3k=12 k = 4
Therefore, n = 2+k = 2+4 = 6
Consequences of the hand shaking lemma
1. In any undirected graph the sum of all the vertex-degrees is an even number.
2. In any undirected graph the number of vertices of odd degrees is even
Corollary 1: If k = (G) is the minimum degree of all the vertices degree of a non directed
n
graph G, then k. V deg(vi) = 2 E .
i =1
Example2:
a. Is there a graph with degree sequence (1,2,3,4,5)?
b. Is there a simple graph with degree sequence (1,1,3,3,3,4,6,7)?
Corollary 2: If t = (G) is the maximum degree of all the vertices degrees of a non directed
graph G, then 2 E t. V .
Subgraph
A graph H is called a subgraph of G if every vertex of H is also a vertex of G and every
edge of H is also an edge of G.
Symbolically H is a subgraph of G if V(H) V (G) and E( H ) E(G).
Example: for the graph G, construct some of its sub graphs.
v1 v3
G:
v2 v4 v5
4
Solution: We construct two graphs Below from G.
v3 v1 v3
H2:
H1:
v5 v2 v4
K4: k5:
5
Example 3: Consider the graph given below.
a. b. c.
Example 2: Is the graph given below bipartite? Or complete bipartite?
v2 v3
v1 v4
v6 v5
Solution: Yes it is bipartite since we can partition the vertex set into
M={v1,v3,v5} and N= {v2,v4,v6} such that none of the edges in G connect vertices with in the
same set M or N.
But it is not complete bipartite graph. (why?)
Theorem: In a complete bipartite graph Km,n; the number of edges is given by E =mn.
Corollary: A complete bipartite graph Km,n is not a complete graph except K1,1.
b) Incidence Matrix- A matrix that describes the incidence relationships between vertices
and edges of a graph.
Adjacency Matrix
Definition: Suppose G is a graph with m vertices and suppose the vertices have been ordered,
say v1,v2,- - - ,vm. Then the adjacency matrix A= [aii] of the graph G is the m n matrix defined
by:
6
aij = n, if there are n edges joining vi and vj
0, other wise.
Exercise
1. Draw the adjacency matrix for:
V2 V3
V1
G:
V4 V5
Note: Adjacency matrix of undirected graph is symmetric.
2. Draw the adjacency matrix for:
e1
v1 v2
e2
e3
v3 v4
e4
3. Write out the adjacency matrix A(G) of the following graph.
v1
v2
v4.
v3
Note:-
a. If the entries in a vertex are all zero, then the vertex is isolated.
b. If G is a simple graph, then the adjacency matrix A(G) :
i. Has leading diagonal entries all zero, aii=0 for all i.
ii. Is a Boolean matrix or a (0,1) matrix.
c. In the adjacency matrix of any graph G, the degree of each vertex vi is:
i. The sum of all the entries in the ith row (or jth column) if there is no loop at vi.
ii. Row (or column) sum plus number of loop(s) if there is (are) loop(s) at vi.
Incidence Matrix
Definition: Suppose G is a graph with vertices v1,v2,…,vm. The incidence matrix I= [bij] of the
graph G is given by:
bij = 1,if ej is incident on vi
0, otherwise
Note: 1. The incident matrix of a graph is not necessarily a square matrix.
2 An incident matrix I has a row for each vertex and a column for each edge.
7
Exercise: Find the incidence matrix I for the graph shown below.
v1 e1 v2
e6
v5 . e5 e2
e7
e3
v4 e4 v3
Note: 1. 1 appears in a column only once the edge dominating the column is a loop.
2. All the entries in a row are zero the vertex is isolated.
3. 1 appears twice in a column the edge dominating the column has two end
points.
4. Sum of all the entries in every row is the degree of the vertex leading the row if
there is no loop and the sum plus n if there are n loops at this vertex.
D1:
v3
v5 v6
Solution: Let the vertex set V of D1 is labeled and ordered as V= {v1,v2,v3v4v5}. Thus,
the adjacency matrix for D1is:
V1 V2 V3 V4 V5
V1 0 1 0 1 1
A(D1) = V2 0 0 0 1 0
V3 0 0 0 0 0
V4 0 0 0 0 0
V5 0 1 1 0 0
th
Note: - The sum of entries in the j column is the same as indeg(vj)
- The sum of entries in the ith row is the same as outdeg(vi)
- Sum of entries in A(D) is equal to the total number of arcs.
Incidence Matrix of a diagraph
The incidence matrix I(D) of a loop-free diagraph is the nxm matrix in which:
1 if arc ej is incident from vi
aij = -1 if arc ej is incident to vi
0 otherwise.
Note: An incidence matrix has a row for each vertex and a column for each arc.
Example: Find the incidence matrix I (D) of the diagraph in the figure.
8
e1
v1 v2 Solution: The incidence matrix for D is given as:
D3: e4 e5 e1 e2 e3 e4 e5 e6
e6 v1 1 0 0 1 0 0
e3 I(D3) = v2 -1 -1 0 0 1 1
v4 v3 v3 0 1 -1 0 0 0
v4 0 0 1 -1 -1 -1
Isomorphism of Graphs
It is possible for two graph diagrams two look different but to represent the same graph. On the
other hand, it is possible to look similar but to represent different graphs.
Consider the following diagrams which connects three houses H1,H2,H3 to three utilities tel.,
water and electricity.
T W E H1 W T H2 E
T H2
H1 H2 H3 H3 E H1 W H3
G1 G2 G3
G1 and G2 are the same but they look different.
G1 and G3 are different but they look the same.
Definition: Graphs G(V,E) and G*(V*,E*) are said to be isomorphic if there exists a one-to –
one correspondence f : V → V * such that {u,v} is an edge of G iff f (u ), f (v)is an edge of
G*.
Example: Show that G and H are isomorphic graphs.
v1 v2 d c
v6 H: f
G: v5
a b e
V3 v4
9
Note: 1. Two graphs G1(V1,E1) and G2 (V2,E2) are said to be isomorphic if a 1-1 correspondence
f exists from V1 to V2 such that u and v are adjacent in G1 iff f(u) and f(v) are adjacent in G2.
2. If G H the degrees of corresponding vertices are equal i.e., degrees are preserved.
3. Two isomorphic graphs must have the same number of vertices and edges.
Example: Prove that G H . u1
v2 v2 U1
u3 u4 u5
G: H:
v3 v4 v5 u2
10
Example: Consider the graph G.
P1 p2 p3
G:
P4
p5 P6
Take the following sequences of vertices.
= ( P4 , P1 , P2 , P5 , P1 , P2 , P3 , P6 )
= ( p 4 , p1 , p5 , p 2 , p 6 )
= ( p 4 , p1 , p5 , p 2 , p3 , p5 , p 6 )
= ( P4 , P1 , P5 , P3 , P6 )
p = ( P4 , P1 , P2 , P3 , P5 , P4 )
is an open path form p4 to p6 but it is not a cycle and not a trial as well .
is not a path since there is no edge {p2,p6}in G.
is a trial (no edge is used twice) but not a cycle.
The sequence is a simple path as well as a trial between p4 and p6 but not the shortest path
between p4 and p6.
The shortest path between p4 and p6 is (p4,p5,p6) which has length 2.
The sequence p is a circuit of length 5.
Example: How many paths of length four are there from a to d in the simple graph G in Figure 8?
v6 v5
v2
v6
H: v1 v3 v5
V4
v7
Solution:
G is a connected graph because every pair of vertices in G forms a path.
H is a disconnected graph because no path can be constructed from vi, i = 1,2,3,4 to vj, j = 5,
6, 7.
Remark: 1. A disconnected graph is made up of two or more disjoint connected subgraphs.
2. A graph is connected iff it has only one component.
3. The component of a graph is denoted by C(G).
Theorem: - A connected graph with n-vertices must have at least n-1 edges. (i.e,
E n − 1).
Example 2: a) A connected graph with 2 vertices must have at least (2-1) = 1 edge.
A B
b) A connected graph with 3 vertices must have at least: (3-1) = 2 edges.
v2
v1 v3
c). suppose that G is a graph with 6 vertices and 4 edges. Can G be connected? Why?
Solution: - A connected graph with 6 vertices must have at least: E = (6-1) = 5.But the number
of edges in G is 4.
Hence G cannot be a connected graph.
12
i) D3 is not strongly connected (why?)
ii) D3 is unilaterally connected and it is weak as well.
Spanning Path: is a path that visits all the vertices of a graph G, where G is directed or non-
directed.
Theorem: Let D be a diagraph. Then:
(i) D is strong D has a closed spanning path.
(ii) D is unilateral D has a spanning path.
(iii) D is weak D has a spanning semi-path.
Note: A semi-path is the same as a path (but not a path) except that the arc ei may begin
at either vi-1 or vi and end at the other vertex. That means there is at least one arc opposing
the direction of the path.
Example 2: Let D4 be the diagraph shown in the figure. Then describe the connectivity of D4.
A D
D4:
B C
Solution:
i) D4 is weakly connected since the under lining graph is connected or D has a spanning
semi-path, like ABCD.
ii) D4 is unilaterally connected since it has a spanning path, like ADBC or BADC.
iii) D4 is not strongly connected since C is a sink (i.e. every vertex is not reachable from
C) or since D has not a closed spanning path.
V Z
G:
W Y
13
X
Solution a) G is a connected graph and degree of each vertex is even (i.e. deg(u)=deg(x)=2;deg
(z)=deg(y)=deg(u) = deg(v)=4).
c) One Euler trial beginning and ending at U is UZWVZYXWYVU.
2. Explain why the two graphs, G1 and G2, given below are not Eulerian (exercise).
a) b)
Graph G1 Graph G2
Theorem: A graph G with 3 or more vertices contains an Euler path if and only if:
1. G is connected
2. G has exactly two vertices with odd degrees
3. The Eulerian path in G begins at one odd vertex and ends at an other odd vertex
Remark: i) A connected graph G with exactly two odd vertices is called
Semi-Eulerian graph.
ii) A graph (connected) with more than two odd vertices is neither Eulerian nor
semi- Eulerian.
Example 3: Show that the graph G given below is a semi-Eulerian graph.
A
E B
G:
D C
Solution: - G is a connected graph.
G has exactly two odd vertices D and C.
By the theorem, G has an Eulerian path that begins at C(or D) and ends at D(or C).
G is a semi Eulerian.
One possible Euler path is: CBAEBDCED
Hamilton Graph
Hamilton Paths:
- a path that visits every vertex in a graph G exactly once is called a Hamilton path.
- A closed Hamilton path is called a Hamilton cycle.
- G is called a Hamiltonian graph if it admits a Hamiltonian cycle.
Remark: An Eulerian trial traverses every edge exactly once, but may repeat vertices while a
Hamiltonian cycle (circuit) visits each vertex exactly once but may repeat edges.
14
Example: Consider the following graphs G1 and G2
A B
v1 v2 v3 F
G1:
G2:
E
D C
v6 v5 v4
G1 is Hamiltonian but not Eulerian. G2 is Eulerian but not Hamiltonian
Properties of Hamiltonian graph
- Only connected graphs can be Hamiltonian
- There is no simple criterion to identify a graph is Hamiltonian or not.
Theorem: If G is a simple graph with vertices n 3 and if deg(u)+deg(v) n for all pairs of
non-adjacent vertices u and v, then G is Hamiltonian. (The converse is not always true)
Example 1: show that a graph G given below is Hamilton.
Solution:
V1 - deg(v1)+deg(v6) = 8 7
v2 - deg(v1)+deg(v7) = 8 7
- deg(v2)+deg(v5) = 8 7
v5 v6 v3 - deg(v2)+deg(v7) = 8 7
v4 - deg(v4)+deg(v6) = 8 7
v7 - deg(v1)+deg(v5) = 8 7 , etc.
G satisfies the condition deg(vi)+deg(vj) 7 for all Paris of non-adjacent vertices vi and vj.i = j =
1, …, 7.
G is Hamiltonian.
n
Corollary: If G is a simple graph with number of vertices n 3 and if deg(v) for all
2
vertices v in G, then G is Hamiltonian.
Example 2: Consider the simple graph G and H given below.
A
v5 v3
G: v6 v4 E B
H:
v1 v2 D C
Consider first G:
n
- G satisfies the condition of the corollary. i.e. G is simple and deg vi for all
2
i = 1, 2, 3,4,5,6.
- G is a Hamiltonian graph
- One possible Hamiltonian cycle is v5v1v6v2v4v3v5
Now consider H:
- H has a Hamiltonian cycle, say ABCDEA
- H is a Hamiltonian graph
But deg(u)=2 for all vertices u {A, B, C, D, E}.
15
i.e. deg(u)=2 < n/2 = 5/2 = 2.5.
The converse of the corollary does not hold.
A B W
D C Y X
figure 1 figure 2
Definition (planar Graph)
A graph G which can be drawn in a plane with its edges intersecting only at (common) vertices is
called a planar graph. A graph that has no such plane representation (or depiction) is called a
non-planner graph.
Example 1: K4 is a planar graph. The graph K4 given in fig. 1 has planar depictions (or plane
drawings) shown in fig. 2. a , b and c.
a) b) c)
Figure 1
Figure 2
Example 2: A complete graph k5 and a complete bipartite graph k3,3 are non planar.
Graph Coloring
A traditional application of the theory of planar graphs is in the study of map colouring. The
problem is to take a map with various countries, some bordering each other, and to find how
many colors are required to color the countries in such a way that no two bordering countries
have the same color.
If we let the countries be represented by vertices and the borders by edges, then the coloring
problem becomes a problem in the theory of planar graphs.
Definition: Consider a graph G. a vertex coloring or simply a coloring of G is an assignment of
colors to the vertices of G such that adjacent vertices have different colors.
16
Examples: 1. In each of the graphs below, determine the number of colors needed to color the
vertices of the graph in such a way that no pair of adjacent vertices have the same color.
A B C
A B C
D F
E
V1 V2
G H I
G1
G2 G3
Solution:
a) The graph G1 is 2- colorable. The set of non-adjacent vertices X= {A, B, C} can be
painted by one color and the other set of non- adjacent vertices y = (V1, V2} by another.
b) G2 is 3- colorable as shown by the numbers at the vertices 2 1
of the graph. 1
This is because G2 contains a cycle of odd length.
c) Left as an exercise
2 2
Remark: 3
• A bipartite graph is 2 colorable.
• A graph G is bipartite iff every cycle (circuit) in G has
even length. 1 1
• A graph with a cycle consisting of an odd number of vertices 2
(i.e., a cycle with an odd length) cannot be painted with only
two colors (not 2- colorable).
Chromatic Number
Definitions:
1) For a positive integer K, a graph G is said to be K- colorable or K- colored if there exists
a coloring of G which uses K colors.
2) The chromatic number of graph G, denoted by X(G), is the minimum number of colors
needed to paint (or color) G so that no two adjacent vertices receive the same color.
Examples
1. Find the chromatic numbers of the graphs G and H below.
a) A B C A D
b)
D E F B C E F
G H
Solution:
a) X (G) = 2; since G is a rectangular grid.
b) X (H) = 3; since H contains a cycle ABCA with 3 vertices A , B, C - which is odd cycle.
2. What is the chromatic number of a cycle?
17
Solution:
The chromatic number of a cycle is either 2 or 3. It all depends on the type of the cycle. If the
cycle has an even number of vertices (i.e.; it is an even cycle), then it is 2- colorable. Otherwise,
the cycle is three colorable.
A A B
A A B
F C
E B
E D
B C
C D
3- Colorable 2- Colorable D C 2- Colorable
3 - Colorable
Rules on chromatic numbers
Rule 1. If G is a simple graph whose maximum vertex degree is d,
then X(G) ≤ d+1
Rule 2. X(G) V , where V is the number of vertices of G.
Rule 3. X(Kn) = n, where X(Kn) is a complete graph with n vertices.
Rule 4. If some subgraphs of G requires k colors then X(G) k .
Welch-Powel algorithm
Step 1: Order the vertices according to decreasing sequence of degrees.
Step 2: Assign the first color c1, to the first vertex in the sequence and then in sequential
order, assign c1, to each vertex w/c is not adjacent to a previous vertices.
Step 3: Repeat step2 with a second color c2 and the subsequence of non colored vertices.
Step 4: Repeat step 3 with color c3, the c4 and so on.
Example: Use Welch – Powel algorithm to find X(G).
A1 A2 A3
A4 A5 A6
A7 A8
Solution
Ordering the vertices in decreasing order of degrees we get:
{A5,A7,A3,A4,A2,A1,A6,A8}.
Now assign the first color c1 for A5 and A1.
Then we obtain the subsequence {A7,A3,A4,A2,A6,A8}to assign the second color c2.
That is assign c2 for A7,A6 and A2
Finally assign the third color c3 for A3, A4 and A8
G is 3 colorable
X (G) = 3
Remark: The following are equivalent for a graph G
i) G is 2-colorable
ii) G is bipartite
iii) Every cycle of G has even length
18