Chapter 5 - Graphs

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

QM1063 CHAPTER 4

CHAPTER 4
GRAPHS AND DIRECTED GRAPHS
4.1 Graphs

Definition 1
A graph is a finite set V called the vertex set and a collection E of two
element subsets of V. The set E is called the edge set. An element of E is
called an edge. A graph is denoted by G(V, E). The elements a and b of V
are joined or connected by the edge {a, b} if {a, b} E.

A finite graph is usually represented by a diagram in which the vertices


are represented by dots and the edges connecting two vertices are
represented by lines between their dots.

Definition 2
i)

If {a, b} is an edge, then vertices a and b are called the


endpoints of the edge {a, b}.

QM1063 CHAPTER 4

ii)

The edge {a, b} is also said to be incident on the vertices a and


b. Conversely, vertices a and b are said to be incident on the
edge {a, b}.

iii)

Two vertices are adjacent if they are endpoints of an edge or


equivalently they are incident on the same edge. Two edge are
adjacent if they are incident on a common vertex.

Example 1
The graph with V = {a, b, c} and E = {(a, b), (b, c)} may be shown as
Figure 1 or Figure 2.
c
e2

b
e1
a
Figure 1

c
Figure 2

QM1063 CHAPTER 4

Example 2
The graph with V = {a, b, c, d, e} and E ={{a, b}, {a, e}, {b, e}, {b, d},
{b, c}, {c, d}} has the diagram shown in Figure 3.

b
a

cb
v
d
e
Figure 3

Example 3
In a football league there have seven groups T1, T2, T3, T4, T5, T6 and
T7. Assume that after several games we have the situation below
T1 vs T2, T3, T5
T2 vs T1, T3, T5
T3 vs T1, T2, T4
T4 vs T3, T7
T5 vs T1, T2
T6 dont play any games yet
T7 vs T4
Model this situation with a graph.

QM1063 CHAPTER 4

An edge from a vertex to itself is called a loop.

Definition 3
The degree of a vertex v, denoted by deg(v), is the number of edges that
are incident on that vertex. A vertex with degree 0 is called isolated.

Example 4
In the graph shown in Figure 4,

a, b and c are adjacent vertices


a and f are not adjacent vertices,
e1, e2, and e3 are all adjacent

a
e1
b

e3
e7

e6

edges.
c

e4
e

e2

e4 and e5 are not adjacent edges.


Deg (a)=6

e5

Deg (b)= Deg (c)= Deg (d)=2


Deg (e)=0 (isolated)
Figure 4
Deg (f)=4

QM1063 CHAPTER 4

Definition 4

A graph G(V, E) is a subgraph of graph G(V, E),

denoted by G(V, E) G(V, E), if V V and E E. Thus,


every vertex in G is a vertex in G and every edge in G is an
edge in G.

Example 5
Consider graph in Figure 5

e
Figure 5

Some subgraphs of the Figure 5 are

Figure 6

QM1063 CHAPTER 4

Such edges are called parallel edges if two edges are both associated
with the pair vertex.

Example 6
v0
e1

Figure 7
v1

e2
v2
e1 and e2 are parallel edges.

A graph with neither loops nor parallel edges is called a simple graph.
Example 7
e1

v0

v1

e5

e7

e3

e2

e6
v3

v4
e4

v2

Figure 8: Simple graph

QM1063 CHAPTER 4

Definition 5
A graph is a complete graph if there is an edge between every two
distinct vertices. A complete graph with n vertices is denoted by Kn.
Example 8
The graphs K2, K3, K4, and K5 are shown respectively in Figure 9.

Figure 9
Definition 6
A graph G = (V, E) is called a bipartite graph if V can be expressed as
the disjoint union of nonempty sets, say V = A B, such that every edge
has the form {a, b} where a A and b B. Thus every edge connects a
vertex in A to a vertex in B and no vertices both in A or both in B are
connected. A bipartite graph is called a complete bipartite graph Km,n if
A contains m vertices, B contains n vertices and for every a A, b B,
there is an edge connecting them.

QM1063 CHAPTER 4

Example 9
The graphs K1,2, K2,3, K2,2 and K3,3 respectively, are shown in Figure 10.
v1

w1

w2

v1

v2

w1

w2

v1

w3

w1

v2

w2

v1

w1

v2

w2

v3

w3

Figure 10
4.2 Directed Graphs
Definition 7
A directed graph or digraph G, denoted by G (V, E), consists of a set V
of vertices, together with a set E of ordered pairs of V called the set of
directed edges or simply edges if it understood that the graph is
directed. An element of E is called a directed edge. If (a, b) E then a is
called initial vertex of (a, b) and b is called the terminal vertex.

QM1063 CHAPTER 4

Example 10
The digraph with V = {a, b, c, d} and E = {(a, b), (b, c), (c, c), (b, d), (d,
b), (c, d), (d, a)} is shown in Figure 11.
b

Figure 11
a

4.3 Representing Graphs


One way to represent a graph without multiple edges is to list all the
edges of this graph. Another way to represent a graph with no multiple
edges is to use adjacency list, which specify the vertices that are
adjacent to each vertex of the graph.
Example 11

QM1063 CHAPTER 4

Use adjacency list to describe the simple graph given figure 12.Example
12
Represent the directed graph shown in figure 13 by listing all the vertices
that are terminal vertices of edges starting at each vertex of the graph.

Figure 12

Carrying out graph algorithm using the representation of graphs by


list of edges, or by adjacency lists, can be cumbersome if there are
many edges in graph.
To simplify computation, graphs can be represented using matrices.
Two types of matrices commonly used to represent graphs, one is
based on adjacency of vertices, and the other is based on incidence
of vertices and edges.

10

QM1063 CHAPTER 4

4.3.1 Adjacency matrices


Definition 8
Suppose that G=(V,E) is a simple graph where [V]=n Suppose that the
vertices of G are listed arbitrarily as v1,v2,vn. The adjacency matrix A
(AG) of G, with respect to this listing of vertices, is the n n zero-one
matrix with 1 as its (i, j) th entry when vi and vj are adjacent, and 0 as as
its (i, j) th entry when vi and vj are not adjacent.
A aij
In the other words, if its adjacency matrix
then
1 if vi , v j is an edge of G
aij
0 otherwise
Example 13
Use an adjacency matrix to represent the graph shown in Figure 14.

11

QM1063 CHAPTER 4

Example 14
Draw a graph with adjacency matrix
0
1

1
0
0
1

1
0
0
1

0
1

We use zero-one matrices to represent directed graphs. Thus, the


A aij
adjacency matrix
for the directed graph
1 if vi , v j is an edge of G
aij
0 otherwise
Example 15
Use the adjacency matrix to represent the graph in figure 15.

12

QM1063 CHAPTER 4

4.3.2 Incidence Matrices


Definition 9
Let G=(V,E) be an undirected graph. Suppose that v1,v2,vn are the
vertices and e1,e2,en are edges of G. Then the incidence matrix with

M mij
respect to this ordering of V and E is the n m matrix
, where
1 when edge e j is incident with vi

mij

otherwise

Example 16
Represent the graph shown in Figure 16 with the incidence matrix

13

QM1063 CHAPTER 4

Figure 164.4 Isomorphism of Graphs


Definition 10
Graph G1 and G2 are isomorphic if there is a one to one, onto function f
from vertices of G1 to the vertices of G2 and a one to one, onto function g
from the edges of G1 to the edges of G2, so that and edge e is incident on
v and w in G1 if and only if the edge g(e) is incident on f (v) and f (w) in
G2. The pair of functions f and g is called isomorphism of G1 onto G2.
Example 17

An isomorphism for the graphs G1 and G2 of figure 11 is defined by


f (a) = A, f (b) = B, f (c) = C, f (d) = D, f (e) = E
g(xi) = yi

i = 1, . . ., 5.

Example 18
Show that the graphs displayed in Figure 18 are not isomorphic

H
14

You might also like