You are on page 1of 36

A

Graph Theory Part 1

L
UK
Dr H S SHUKLA
Assistant Professor

SH
Mathematics
Government Engineering College, Gandhinagar,
GUJARAT(INDIA).
S
H

January 27, 2022


Dr
Plan of Presentation

LA
UK
SH
Graph
S
H
Dr
Graph

The Königsberg bridge problem: The city of Königsberg was the

A
located on the Pregel River in Prussia. The city occupied two islands

L
plus areas on both banks. These regions were linked by seven bridges.

UK
The citizens wondered whether they could leave home, cross every
bridge exactly ones, and return home. The problem reduces to the
traversing the figure on the below, with heavy dots representing land

SH
masses and curves representing bridges.
S
H
Dr
Graph

A
C

L
e1
e6

UK
e2
A e5 D

SH
e4
e7
e3
S B
H
The model on the below makes it easy to argue that the desired
traversal does not exist. Each time we enter and leave a land mass,
Dr

we use two bridges ending at it. We can also pair the first bridge
with the last bridge on the land mass where we begin and end. Thus
existence of the desired traversal requires that each land mass be
Graph

A
involved in an even number of bridges. This necessary condition did

L
not hold in Königsberg. Meanwhile, the problem suggests a general

UK
model for discussing such questions.
The problem that is often said to have been the birth of graph theory
will suggests our basic definition of a graph.

SH
A graph consists of a collection of dots (called vertices or nodes)
and a collection of lines or arches (called edges). Each edge connects
two vertices. The Königsberg graph is an example of the graph.
S
Definition: (Graph)
H
A graph is a pair G = (V , E ) or G = ⟨V , E ⟩ where V is a nonempty
set of vertices or nodes, and E ⊆ {(u, v )/u, v ∈ V } is a set of edges
Dr

joining ordered or unordered pairs of vertices.


Graph

Example

A
A graph G is defined by the sets V (G ) = {u, v , w , x, y , z} and

L
E (G ) = {uv , uw , wx, xy , xz}.

UK
z y u

SH
x
S w v
H
Example
(1) Let V = {1, 2, 3, 4} and E = {(1, 2), (1, 3), (3, 2), (4, 4)}. Then
Dr

G = (V , E ) is a graph.
(2) Let V = {1, 2, 3, 4} and E = {(1, 5), (2, 3)}. Then G = (V , E )
is not a graph, as 5 is not in V .
Graph

L A
UK
Definition: (Adjacent nodes)
If e = uv = vu = (u, v ) = (v , u) is an edge of a graph G , then we

SH
say that u and v are adjacent nodes in G and that e joins u and v .
The vertex u and an edge e are incident with each other as are v
and e. If two distinct edges say e and f are incident with a common
S
vertex, then they are adjacent edges.
H
Dr
Graph

Example

A
In the following graph

L
UK
V2
e1 e2

SH
V1 V3
e4 e3
S V4
H
1. V1 and V2 are adjacent nodes 5. e1 and e2 are adjacent edges
2. V1 and V4 are adjacent nodes 6. e3 and e2 are adjacent edges
Dr

3. V3 and V2 are adjacent nodes 7. e3 and e4 are adjacent edges


4. V3 and V4 are adjacent nodes 8. e1 and e4 are adjacent edges
Graph

A
Definition: (Directed edge)

L
UK
In the graph G = (V , E ), an edge which is associated with an ordered
pair of V × V is called a directed edge.
In other words: In the graph G = (V , E ), an edge e = (u, v ) is

SH
represented by an arrow or directed curve from initial point u of e to
the terminal point v , then the edge e is called directed edge.
Definition: (Undirected edge)
S
In the graph G = (V , E ), an edge which is associated with an un-
H
ordered pair of nodes is called an undirected edge.
In other words: An edge of the graph G has no direction then the
Dr

edge e is called undirected edge.


Graph

L A
UK
Definition: (Directed Graph)
A graph in which every edge is directed, is called a digraph or directed

SH
graph.
In other words: A digraph is a pair G = (V , E ) where V is a nonempty
set of nodes, and E ⊆ V ×V is a set of directed edges or edges joining
S
ordered pairs of vertices.
H
Dr
Graph
Example

A
An example of a directed graph is

L
UK
e1
e3

SH
A B
e2
S e10
e9 e8 e e4 e5
H
11

e6
Dr

D C
e7
Graph

Definition: (Undirected Graph)

A
A graph in which every edge is undirected is called an undirected

L
graph.

UK
In other words: An undirected graph is a pair G = (V , E ) where V
is a nonempty set of nodes, and E ⊆ V × V is a set of undirected

SH
edges or edges joining unordered pairs of vertices.
Example
An example of an undirected graph
S
b d
H

a c
Dr

We can refer to an edge joining the vertex pair i and j as either (i, j)
or (j, i).
Graph

A
Definition: (Mixed Graph)

L
A graph in which few edges are directed and few edges are undirected

UK
is called an mixed graph.
Example

SH
An example of a mixed graph
S b d
H

a c
Dr
Graph

A
Definition: (Initiating and Terminating nodes)

L
Suppose e = (u, v ) is a directed edge in a digraph, then the edge e

UK
is said to be initiating or originating in the node u and terminating or
ending in the node v . The nodes u and v are called the initial and
terminal nodes of the edge e.

SH
Definition: (Loop (sling))
A loop or self-loop or sling is an edge from a node u to itself.
S
Definition: (Distinct edges and Parallel edges)
H
In the case of directed edges, the two possible edges between a pair
of nodes which are opposite in direction are considered distinct. Two
Dr

edges are called parallel edges or multiple edges if they both go from
same node u and both go to the same node v .
Graph

Example

A
In graph (a): e8 is loop. e4 and e5 are parallel edges. e1 , e2 and e3

L
are parallel edges.

UK
In graph (b): e1 is loop. e2 and e12 are parallel edges.

SH
e8 e1
e12
e4 e3
V2 V3 A B
e5 e2
S e10
e3 e1 e2 e6 e9 e8 e11 e4 e5
H
e6

D C
Dr

e7
V1 V4 e7

(a) Undirected graph (b) Directed graph


Graph

L A
UK
Definition: (Multi-graph)

SH
A graph which contains some parallel/multiple edges is called a multi-
graph.
S
H
Dr
Graph

Example

A
An example of an undirected multi-graph and a directed multi-graph

L
are

UK
e1
e3

SH
e8
e4 e12
V2 V3 A B
e5 S e2
e10

e3 e1 e2 e6 e9 e8 e4 e5
H
e11

e6
Dr

e7 D C
V1 V4 e7
Graph

A
Definition: (Simple graph)

L
A graph is simple if it has neither loops nor multiple edges.

UK
Example
Examples of undirected simple graph and directed simple graph are

SH
e2
e2
V5 A B
e8 e7
S V4 e1
e9
V1
e4 e3 e5 e8 e7 e10 e3 e4
H
e1
e2 e5
Dr

D C
V2 V3 e6
Graph

A
Definition: (Weighted graph)

L
A graph G in which every edge is assigned a real number (weight) is
called a weighted graph.

UK
Example

SH
Examples of an weighted graph are

7 4.2
S V2 V3
A 2 B
1.3
1.5 6.3
H
9
8 7
Dr

1.4 7.1
D C V1 V4
Graph

A
Definition: (Degree of the vertex)
The degree of the vertex v ∈ V , denoted deg (v ), is the number of

L
edges that are incident with v . Loops are counted twice (once for

UK
each end of the loop).
If every vertex in G has the same degree, the graph is said to be

SH
regular.
Example
The degrees of vertices in the graph
S
v2 v3
H
v4
v6 v1 v5
Dr

deg (v2 ) = 2 = deg (v4 ) = deg (v1 ), deg (v3 ) = 3, deg (v5 ) = 1 and
deg (v6 ) = 0
Graph

Example

L A
u z

UK
w
v

SH
deg (u) = 3, deg (v ) = 8, deg (w ) = 6 and deg (z) = 1.
S
Definition: (In-degree, Out-degree and Total degree)
H
Let v be a vertex in a directed graph, G . The in-degree of v , denoted
deg − (v ), is the number of arcs whose terminal vertex is v . The out-
Dr

degree of v , denoted deg + (v ), is the number of arcs whose initial


vertex is v . The sum of the in-degree and out-degree of a vertex is
called the total degree of a vertex.
Graph

A
Example-1

L
UK
Find the in-degree, out-degree and total degree of each vertex of the
following graph.

SH
v4 v3

S
H
v1 v2
G
Dr
Graph

L A
UK
Solution:
Graph G

SH
Vertex In-degree Out-degree Total degree
v1 0 3 3
v2 S 1 0 3
v3 4 0 4
v4 1 3 4
H
Dr
Graph

A
Example-2

L
Find the in-degree and out-degree of each vertex of the following
directed graphs:

UK
a

SH
b
v5

v4 v3
S
H
d c
v1 v2
Dr

(i) (ii)
Graph
Solution:

A
Graph (i)

L
Vertex In-degree Out-degree

UK
v1 2 1
v2 1 2

SH
v3 2 1
v4 3 1
v5 0 3
S Graph (ii)
H
Vertex In-degree Out-degree
a 5 2
Dr

b 3 3
c 1 6
d 4 2
Graph

L A
UK
Definition: (Isolated node)
A node having no incident edge is called an isolated node.
In other words, isolated vertices are those with zero degree.

SH
Definition: (Pendent Vertex)
A vertex having degree 1 is called an pendent vertex.
S
Definition: (Null graph)
H
A graph which contains only isolated nodes, is called a null graph.
Dr
Graph

Example

A
An example of null graph is

L
UK
V2 V3

SH
V1 V4
S
Definition: (Isomorphic graph)
H
Let G1 = (V1 , E1 ) and G2 = (V2 , E2 ) be two simple graphs. A function
f : V1 → V2 is called a graphs isomorphism if (i) f is one-one and
Dr

onto. (ii) for all a, b ∈ V1 , (a, b) ∈ E1 if and only if (f (a), f (b)) ∈ E2


when such a function exists, G1 and G2 are called isomorphic graphs
and is written as G1 ∼ = G2 .
Graph

L A
In other words, two simple graphs G1 and G2 are said to be isomor-

UK
phic to each other if there is a one to one correspondence between
their vertices and between edges such that incidence relationship is
preserve. Written as G1 ∼ = G2 or G1 = G2 .

SH
The necessary and sufficient conditions for two simple graphs to be
isomorphic are
1. Both must have the same number of vertices.
S
2. Both must have the same number of edges.
3. Both must have equal number of vertices with the same degree
H
(Incidence relation is preserved).
4. Edge relation is preserved (Adjacency is preserved).
Dr
Graph

A
Example-3

L
Show that the following graphs are isomorphic

UK
e′

SH
a
d′ c′
e
S
H
c
b d a′ b′
Dr

(G ) (G ′ )
Graph

Solution: From the above graphs, there are 5 vertices and 6 edges.

A
Now let us check for degree

L
UK
Graph (G ) Graph (G ′ )
Vertex Degree Vertex Degree
a 3 a′ 3

SH
b 2 b′ 2
c 3 c′ 3
d S 3 d′ 3
e 1 e′ 1
H
There exist a mapping a → a′ , b → b ′ , c → c ′ , d → d ′ , e → e ′ .
Under this mapping, the edges ⟨a, b⟩, ⟨a, c⟩, ⟨a, d⟩, ⟨b, c⟩, ⟨c, d⟩, and
Dr

⟨d, e⟩ of G are mapped into ⟨a′ , b ′ ⟩, ⟨a′ , c ′ ⟩, ⟨a′ , d ′ ⟩, ⟨b ′ , c ′ ⟩, ⟨c ′ , d ′ ⟩,


and ⟨d ′ , e ′ ⟩ which are the only edges of the graph G ′ . Therefore, the
given two graphs are isomorphic.
Graph

A
Example-4

L
Show that the following graphs are isomorphic

UK
a e
c

SH
v5 v4
v6 v3
d
v1 v2
b
S
f
(H) (G )
H

Solution: From the above graphs, there are 6 vertices and 9 edges.
Dr

Now let us check for degree


Graph

A
Graph (H) Graph (G )

L
Vertex In-degree Out-degree Vertex In-degree Out-degree

UK
a 0 3 v1 0 3
b 3 0 v2 3 0
c 0 3 v3 0 3

SH
d 3 0 v4 3 0
e 0 3 v5 0 3
f 3 S 0 v6 3 0

There exist a mapping a → v1 , b → v2 , c → v3 , d → v4 , e → v5 , f →


H
v6 . Under this mapping, the edges ⟨a, b⟩, ⟨a, d⟩, ⟨a, f ⟩, ⟨c, b⟩, ⟨c, d⟩,
⟨c, f ⟩, ⟨e, b⟩, ⟨e, d⟩ and ⟨e, f ⟩ of H are mapped into ⟨v1 , v2 ⟩, ⟨v1 , v4 ⟩,
Dr

⟨v1 , v6 ⟩, ⟨v3 , v2 ⟩, ⟨v3 , v4 ⟩, ⟨v3 , v6 ⟩, ⟨v5 , v2 ⟩, ⟨v5 , v4 ⟩ and ⟨v5 , v6 ⟩ which


are the only edges of the graph G . Therefore, the given two graphs
are isomorphic.
Graph

A
Example-5

L
Check whether the given below graphs are isomorphic? Give a reason.

UK
b′

SH
a′ c′
a
e S b
f′ d′
f
d c
H
e′
(G ) (G ′ )
Dr
Graph

Solution: From the above graphs, there are 6 vertices and 9 edges.

A
Now let us check for degree

L
UK
Graph (G ) Graph (G ′ )
Vertex Degree Vertex Degree
a 3 a′ 3

SH
b 4 b′ 2
c 3 c′ 4
d S 4 d′ 3
e 2 e′ 2
f 2 f′ 4
H
Now the vertices of degree 3, in G are a and c and they are adjacent
Dr

in G , while the vertices of degree 3, in G ′ are a′ and d ′ which are not


adjacent in G ′ . Thus adjacencies do not preserved. Hence, the given
two graphs are not isomorphic.
Graph

L A
Example-6

UK
Check whether the following graphs are isomorphic
a b a′ d′

SH
S
c d b′ c′
H
(H) (G )
Dr
Graph

A
Solution: From the above graphs, there are 4 vertices and 4 edges.

L
Now let us check for degree

UK
Graph (H) Graph (G )

SH
Vertex In-degree Out-degree Vertex In-degree Out-degree
a 1 1 a′ 0 3
b 1 S 1 b′ 1 1
c 1 1 c′ 2 0
d 1 1 d′ 1 0
H
From the above table we see that there is no vertices of degree 3 in
graph H, hence these graphs are not isomorphic.
Dr

You might also like