Professional Documents
Culture Documents
Discrete Chapter 5 (New)
Discrete Chapter 5 (New)
Discrete Chapter 5 (New)
3 4
a b
Then order of or | | =4 and size of or | | = 8
5.1.2 Adjacent vertices
Two vertices are adjacencies if there exits an edge in
2
e.g. Let
G: 5
3
4
Then 1&2 are adjacent vertices, 1&3 are adjacent vertices,
2&3 are adjacent vertices, 4&5 are adjacent vertices
5.1.3 Parallel edges
If there is more than one edge between the same pair of vertices, then the edges are
said to be parallel edges.
𝑒5
e.g. Let 𝑒 2 5
1
G:
𝑒3 𝑒6
𝑒2
𝑒4
3 4
5.1.4. Loop
Then is a loop.
e.g. Let 1 2 4 3
5
G1 : G2 :
3 4
1 2
e.g t s
G: w
v
u
3
4
A graph (or digraph) is known as a weighted graph (or digraph) if each edge of the
graph has some weights.
Consider 2 3 4 5 , where ,
2 , 3 , 4 , 5 and , 2 ,
3 6
4
e.g. b
a e
Let
G:
d
c
g
F h
A vertex is said to be an isolated vertex if there is no edge connected from any other
vertex to that vertex.
In other words a vertex is said to be an isolated vertex if the degree of that vertex is
zero.
e.g. 1 . w s t
Let G:
u
v
2. a b e f
Let G:
c d g h
Then
d
G is directed multigraph.
There are 3 edge from a to b.
Edge (a, b) has multiplicity 3.
Edge (b, c) and (d, e) have multiplicity 2.
Edge (e, d) and (c, d) have multiplicity 1.
e.g.
4 3
Let
G:
Then G is complete graph.
1 2
i.e, G(V, E) is regular if deg(vi) = deg(vj), foe all i &j, where vi, vj V.
V1 V2
V4 V3
5.9. Cycle
If there is a path containing one or more edges which starts from a vertex and
terminates into the same vertex, then the path is known as a cycle.
e.g. Let V w
G:
t s
V4 V7
V5 V6
Then indegree of V4, V5, V6 and V7 is equal to 1 and outdegree is 0. Thus V4, V5, V6 and
V7 are pendant vertices.
2. Let V1 V2
V6
G2:
Then V1, V5, V6 are pendant vertices
V3
V4
V5
5.11. Acyclic graph
V8 V9
Then G is acyclic graph.
5.12. Matrix representation of graphs
A. Adjacency matrix
2
2 22 2
[ 2 ]
Where
{
This is also known as bit matrix or Boolean matrix as each entry is either 1 or 0.
Note:- 1. In the adjacency matrix, if the graph is a simple graph, then the main
diagonal elements are zero.
2. In a multi graph, the adjacency matrix can be found out with the relation
3. In a weighted graph, the adjacency matrix can be found out with the relation
𝑉6
𝑉3 𝑉4
A=
[ ]
A B
e.g. Let Then the adjacency matrix of the
graph with respect to ordering A, B, C,
G:
and D is
C D
A=
[ ]
e.g. 3. Let A 5 B
[ ]
B. Incidence matrix
Suppose G be a simple undirected with ‘m’ vertices and ‘n’ edges, then the incidence
matrix is a matrix of order (mxn), where the element defined as
2 3 4 5 6 7
I=
[ ]
5.13. Connected graph:-
A graph G is said to be connected if there is a path for every pair of distinct vertices ‘u’
and ‘v’ in G.
Definition:-
i) A directed graph is said to be strongly connected if for every distinct vertices ‘u’
and ‘v’ in G, there is a directed path from ‘u’ to ‘v’ and also from ‘v’ to ‘u’.
ii) A directed graph is said to be weakly connected if for every distinct vertices in
G, there is a directed path without taking the direction.
iii) A directed graph is said to be connected if its associated undirected graph
(obtained by ignoring the directions of the edges) is connected.
e.g. Let V1 V2 V1
G2: V2
V3
G1 :
V7
V5
V4
V6
V4 V3
V1 V2 V1 V3
V7 V6
G3 : G4 :
V4 V3 V2
V4 V5 V8
G:
t s
0 1 1 0
1 0 1 0
Then the adjacency matrix A is A= , number of vertices ‘n’ =4.
1 1 0 1
0 0 1 0
Therefore B = A + A2 + A3
2 1 1 1 2 3 4 1 4 5 6 2
1 2 1 1 3 2 4 1 5 4 6 2
2
Now A = , A3 = . Thus B = A + A2 + A3 =
1 1 3 0 4 4 2 3 6 6 5 4
1 1 0 1 1 1 3 0 2 2 4 1
Since all , the graph G is connected.
Exercise:- Let V1 V2
Let
G1 : G2 :
V2 V3 a
V2 V4
And 2
Then G1 and G2 are isomorphic graphs.
2. Let m n r s
G3 : G4 :
p w t u
With 2
2 by
Then a) is 1 – 1 and onto
b) is an edge in G3 but is not an edge in G4.
Hence is not graph isomorphism.
Thus G3 and G4 are not isomorphic.
5.15. Bipartite graph:-
A graph is bipartite if 2 with 2 and every edge of
has one end in and other end in 2 .
u2
e.g Let u1
and let 3 5 7
G: u7 2 2 4 6 8
u8
Then G is bipartite graph.
u6
u5
u4 u3
V2 V3
d d
d
G: v G1: v v
t u t G2: t
w ∙w ∙w
Then G1 is subgraph of G
G2 is not subgraph of G because(s, v) is a subset of E2 but (s, v) is not a subset of E.
5.16.1. Vertex deleted subgraph:
Suppose be graph. If we delete a subset of and all the edges, which
have a vertex in as an end, then the resultant graph is termed as vertex deleted
subgraph of G.
𝑣 𝑣2
e.g
Let
G:
𝑣3
𝑣4
𝑣2
Then by deleting the vertex ,
H:
the vertex deleted subgraph H is
𝑣3
𝑣4
𝑣4
𝑣3
H: ∙
𝑣3
𝑣4
5.17 Walks:-
Let be (not necessary distinct) vertices in an undirected graph .
An – walk in G is (loop – free) finite alternating sequence
2 of vertices and edges from G, starting
a vertex ‘ ’ and ending at vertex ‘ ’ and involving the ‘ ’ edges ,
d
e
G2 :
G1 : V3
V4 V3
V4 V3
Solution: V = { v1, v2, v3, v4, v5} ,
E = {{ v1, v2}, { v2, v3), { v3, v4}, { v4, v1}, { v1, v3}, { v2, v4}, { v5, v5}, { v3, v5}}
Hence the graph G1 G2 becomes V V2
1
G1 G2:
V5
V4 V3
B. Intersection
If G1 = (V1, E1) and G2 = (V2, E2) be two graphs with at least one vertex in common, then
their intersecton (G1 G2) = (V, E) is a graph with 2 and 2.
e.g Find the intersection of the following graph
V1 V2
V1 V2
G2:
G1:
V3 V4
V3 V4
V5
V5
G2:
V3 V4
V5
C. Complement
Suppose G be simple graph with n – vertices. Then the complement of G is given by ̅ and
is defined to the simple graph with the same vertices G and where vertices (u, v) are
adjacent in ̅ if u and v are not adjacent in G.
In other words the complement of G can be obtained from the complete graph by
deleting all the edges of G.
𝑣2 𝑣2
𝑣3 𝑣3
e.g Let G: 𝑣 , then 𝐺̅ : 𝑣
𝑣6 𝑣4 𝑣6 𝑣4
𝑣5 𝑣5
D. Product of graphs
Suppose 2 2 2 be graphs. The product of 2,
denoted 2 is defined as 2 , where 2 and the edge set can
be found out from the following relation:
If 2 and 2 be two vertices of 2 , then there is an edge between them
When i) ( and 2 is adjacent to 2 ) or
ii) ( 2 2 and is adjacent to )
e.g Consider the graphs and 2 as:
𝑣2
𝐺 𝐺2
𝑢 𝑢2 𝑣
𝑣3
𝑢 𝑣 𝑢 𝑣2
𝑢 𝑣3
Then 𝐺 𝑋𝐺2
𝑢2 𝑣 𝑢2 𝑣2 𝑢2 𝑣3
a
Let G: g Then .
d h
b
c
Let be the number of color. Then , in the variable is called the chromatic
polynomial of G, that will tell us in how many different ways we can properly color the
vertices of G, using at most colors.
5.21 Eulerian and Hamiltonian graphs
An Eulerian walk (or path) (or circuit) in a graph is a walk (or path) (or circuit)
which uses each edge in exactly once.
A Hamiltonian path (or circuit) cycle in a graph is a cycle which contains all
the vertices of exactly once except the starting vertex.
e.g 1 2 3
Let G:
Then 12367541 is Hamiltanian.
6
4 5
5.22. Trees
Definition:- A tree is a non – directional graph is connected and does not have a circuit.
Or A tree is connected graph that i) has no cycles
ii) has no loopes
iii)has no multiple edges.
a b
e.g a b
G1: c d
G2: c d
e f
e f
a b a b
G4: c d
G3: c d
e f
e f
G:
t s
Then the spanning tree may be
V w V w V w V w
or or or
t s t s t s t s
2. Rooted Tree
A tree is a digraph with a non empty set of nodes such that
i)there is exactly one node, called the root of the tree, which has indegree 0.
ii)Every node other than the root has indegree 1.
iii)For every node ‘a’ of the tree, there is a directed path from the root to ‘a’.
e.g V2 V3
V1 V1 V1
5 1
3 8 1
2
9
We records this tree as all elements less than 7 will be in the left sub tree and all
elements greater than 7 will be in the right sub tree.
Let us see the following tree: (i.e, by discriminate values in the leaves). The same
value we can take in this case. Internal values are discriminator. All values
records in the right sub tree.
3 5 14
9 12
:
21
37
32
2 4 30
7 1 12 15 20 25
Traversal Methods:-
Tree traversal algorism (or there are 3 methods in which we can traversal nodes)
Pre order:- 1. Process the root node of tree ( )
2. if (left sub tree) exists, then process
3. if 2 (right sub tree) exists, then process 2
(i.e, root, left, right)
In order :- 1. if (left sub tree) exists, then process
2.Process the root node of tree ( )
3. if 2 (right sub tree) exists, then process 2
(i.e, left, root, right)
Post order:- 1. . if (left sub tree) exists, then process
2. if 2 (right sub tree) exists, then process 2
3. Process the root node of tree ( )
(i.e, left, right, root)
e.g. 1. Consider the following tree:
a
Then 1. Pre order:- a b d e g c f h
b c 2. In order:- d b g e a c h f
3. Post order:- d g e b h f c a
d e f
g
h
Ex. 2. Let pre order is abcd and in order is badc. Then draw the tree.
3. Let pre order is abcd and post order is dcba. Then draw the tree.
4. Let pre order is abdehkcfigjl and in order is dbhkeaficglj
Solution:-
2. 3. a a
a
b b
b c c or
c
d
d
d
a
b c
4. g
d f
e j
i
h l
k
Prim’s algorithm for minimum spanning trees
Minimum spanning tree (MST) is a subset of edges that i) reaches every vertex.
ii) has minimum total weight
iii) has no cycles
To draw the tree, use the following steps:
1. Remove all the loops if exists.
2. Remove all parallel edges between two vertices except the one with least weight.
3. Select the sides of the minimum weighted graph G, enter in to T
4. Select the edge in G which has a minimum weight and side by side with
vertices in T, which provide that side does not form a circuit in T.
5. Repeat step 2 for n-2 times.
e.g Find MST if the following graph is given.
4
𝐶 5 𝐷
G: 4
12 10 11
𝐵
𝐴 5
8
Solution:- step1:- Remove all the loops
Step2:- Remove all the parallel edges
Now, the graph becomes,
𝐶 5 𝐷
G: 4 11
10
𝐴 𝐵
5
Step3,4,5 :-
A B C D
A 0 5 10
B 5 0 4 11
C 10 4 0 5
D 11 5 0
Put ‘0’ in cells having the same row and column because no loop.
Find the edge that directly connects A and B. (i.e. cell AB & cell BA, put 5)
Find the edge that directly connects A & C. (i.e, cell Ac & cell CA, put 10)
In a similar way plot the other cells
Start from vertex A. Find the smallest value in a A – row except ‘0’ (i.e, 5, so we
mark edge AB) and find the smallest value in a B – row & A – row (i.e, 4 is the
smallest unmarked value in A – row & B – row, so we mark edge BC)
Then find the smallest value in A – row, B – row, C – row. (i.e, 5 is the smallest un
marked value in A – row, B – row, C – row, so mark CD).
Finally, Draw MST,
𝐶 5 𝐷
G: 4
𝐴 𝐵
5
1. 4. 5
1 6
𝐶 3 𝐷 2 7
E 6
5 𝐺
G: 6 4
3 5 𝐹 9
𝐴 𝐵
8 H
B 8
2
C
2.
A 6 3
5 5
6 D 6
7
E
F 2
F 3
10 C
3. 2
A 7
8 4 3
18
4 B
9 D
10 2
25
H
3 E
G
7