Professional Documents
Culture Documents
Graph Theory –
Basic Concept of Graph Theory,
Euler’s Path & Circuits,
Hamiltonian Path & Circuits,
Partially Ordered Sets-
Lattices,
Finite Boolean Functions -
Boolean Polynomials,
Trees-
Minimal Spanning Trees
Unit 5: Part I
Graph Theory –
• Basic Concept of Graph Theory,
• Euler’s Path & Circuits,
• Hamiltonian Path & Circuits,
Graphs
Def: A graph G = (V,E, ) consists of a non-
empty set V of vertices (or nodes) and a finite
set of objects E called as edges and a function
that assigns to each edge a subset of
vertices.
Eg. Let V= {1,2,3,4} and E={e1,e2,e3,e4,e5}, Let
be defined by (e1) = (e5) ={1,2}, (e2) ={3,4},
(e3) ={1,3), (e4) ={2,4}. e 1
1 e5 2
e3
e4
3 4
e2
Basic Types of Graphs
1. Undirected graph 2. Directed graph
loop
G=(V,E)
isolated vertex
multiple
edges
adjacent
Unordered pair of edges Ordered pair of edges
a b
d
a b d
c
c
simple graph multi graph
• Ex. Draw the graph G=( V,E, ), where V= {a, b,
c, d, e} , E= {e1,e2,e3,e4,e5,e6} and
(e1)= (e5)={a ,c}, (e2)={a, d} , (e3)={e, c},
(e4)={b, c}, (e6)={e, d}.
Ex. Draw the graph G=( V,E, ), where V= {a, b, c,
d, e} , E= {e1,e2,e3,e4,e5,e6} and (e1)= (e5)={a
,c}, (e2)={a, d} , (e3)={e, c}, (e4)={b, c},
(e6)={e, d}.
a
a e2
e1 e5
c d
b
e4 e3
e6
e
Handshaking Theorem
Statement : Let G={V,E} be undirected graph with e
edges , then the sum of degrees of the vertices in
an undirected graph is even.
I.e. deg(v) =2e for all vV.
E C
a b d
c
Vertex degree
a 1
b 3
c 2+1=3
d 1
Total deg(v)= 8 = (2(e)) , where no. of edges
(e)=4.
Ex. How many edges are there in a graph with 10
vertices each of degree six?
Solution : 10 vertices each of degree 6 => total
no of deg. ie deg(v)= 10(6) =60.
1 3 5
1 3
4
Path
• A Elementary path is a walk through sequence u=v0,v1,..,vn of
vertices, each adjacent to the next, without any repetition of
vertices.
• A simple path from u-v is the one in which no edge is repeated in
the path.
• If first vertex equal to last vertex then path is called a closed path
and if first vertex not equal to last vertex then path is called an
open path.
• Length of path : The number of edges in a path is called the length
of the path.
• Note : An edge which is not a loop is a path of length one.
• A loop can be included in a walk but not in a path.
2
1
3
Simple Path Not a elementary path since, 2 is repeated Closed path
Circuit
• A circuit is a path that begins and ends at the
same vertex that contains no repeated edge.
Example : 1-2-3-4-5-6-1
1 2
1 1
6 3
2
5 4
Subgraph
• A graph G′(V′,E′) is a subgraph of the graph
G(V,E) if V′⊆V and E′⊆E.
b b
a a
d c d
c
a
c
b b
a c a
c
Euler Path & Circuit
• Eulerian Path : An Eulerian path through a
graph is a path whose edge list contains each
edge of the graph exactly once.
• Eulerian Circuit: An Euler circuit is a path
through a graph, in which the initial vertex
appears 2nd time as the terminal vertex.
• Note: An Euler Circuit is always and Euler Path,
but an Euler Path may not be an Euler Circuit.
Euler’s Theorem, or Rules
• If a graph has more than two odd
vertices(degrees), then it does not have an
Euler path.
• If a graph has two or fewer odd
vertices(degrees), then it has at least one
Euler path.
• If a graph has any odd vertices(degrees), then
it cannot have an Euler circuit.
• If every vertex in a graph is even, then it has at
least one Euler circuit.
•A graph with 2 odd vertices and some even vertices contains an Euler path.
•A graph with all vertices being even contains an Euler circuit.
•A graph with more than 2 odd vertices does not contain any Euler path or circuit.
1 0 10 C
2 0 6 C
3 2 6 P
4 2 4 P
5 4 1 N
6 8 0 N
F, A, B, E, C, G, D is a Hamilton
path
• A Hamilton circuit is a circuit that goes
through each vertex of the graph once and
only once (starting point and ending point is
the same)
F, B, E, C, G, D, A, F is a Hamilton
circuit
Example:
d c 6 5
G G�
An isomorphism between G and G�:
a 6 (3) d 5 (4)
b 1 (4) e 2 (4)
c 3 (3) f 4 (4)
Note : we can take a 3 then c 6 , or b 5 or
2 or 4 similarly with d, e ,f.
Two non-isomorphic graphs
Vertices: 6
Vertices: 6
Edges: 7
Edges: 7
Vertex sequence: 4, 3, 3, 2, 2, 0.
Vertex sequence: 5, 3, 2, 2, 1, 1.
Example of Isomorphic Graph
Are these pairs of graphs isomorphic?
3
a e 1 5 Isomorphic:
a-1, b-5,
#1
c d c-4, d-3, e-2,
b f 6
f-6.
2
4
d
1 2 Not Isomorphic:
a b c 5 6 5 K3’s on left,
#2
7 4 K3’s on right.
e g 4 3
f
28
Check This for Isomorphic
b b
a c a c
e d e d
G G’
Unit 5: Part II
Partially Ordered Sets
• POSET
• Hasse Diagram
• Lattices
Recall
– An equivalence relation is a relation that is reflexive, symmetric, and
transitive
33
Example of Posets
Examples:
(P(S), ⊆)
(Z, )
(Z, divides)
Note : For divisibility we have if a,b Z such that
a b then a|b.
Related Terms
Note : Existence of non comparable pairs avoids the linearly order set.
The set containing one element is always linearly ordered.
Ex: Consider the set A={1,2,3….} is ordered by
divisibility. Determine whether each of the
following subset of A are linearly ordered or not.
(i) B={2,4,8} (ii)C={3,6,9,11} (iii) D={1}
Sol :
(ii) Since 2|4, 2|8 as well 4|8 , every pair is
comparable. So B is linearly ordered.
(iii) Since 3 | 11 i.e. (3,11) is not comparable is
enough to say that C is not linearly ordered.
(iv) The set containing one element is always
linearly ordered.
Related Terms
Hasse Diagram
Hasse Diagram is a tool to describe the partial order.
The resulting diagram of the partial order, is called as the Hasse diagram
of poset.
Example of Hasse Daigram
• Consider the set A={4,5,6,7} and a relation
on A. Draw the diagraph and the Hasse
diagram of R.
Sol : The relation on A is given by
R={(4,4),(5,5),(6,6),(7,7), (4,5), (4,6), (4,7), (5,6),
(5,7), (6,7)}
7
5 6
4
Example of Hasse Diagram
6
5
7
4
5 6 7
6
4
5
4
Note : The Hasse diagrame of such form defines the given poset is
linearly order.
Hasse Diagrams
• Consider the graph for a finite poset
({1,2,3,4},≤)
• When we KNOW it’s a poset, we can simplify
the graph 4 4
4 4
Called the
3 3 3 3 Hasse
diagram
2 2 2 2
1 1 1 1
Example of Hasse Diagram
– Let S = {1, 2, 3} and A=P(S).
Draw the Hasse of the poset A
with the partial order (set
inclusion)
Sol: A = {, {1}, {2}, {3}, {1,
2}, {2, 3}, {1, 3}, {1,2,3}} {1,2,3}
– Now (A,) is a poset, The
Hasse diagram of (A,) is {2,3} {1,3}
{1,2}
shown as.
{3}
{1}
{2}
– The Diagram itself implies that the
poset is not linearly order.
Hasse Diagram
• For the poset ({1,2,3,4,6,8,12}, |)
Exercise for student
Ex: Consider the partial order of divisibility on
the set A={1,2,3,5,6,10,15,30}. Draw the Hasse
diagram of the poset and determine whether
it is linearly ordered .
15
9
Eg : if n=45, then Sn={1,3,5,9,15,45}
So the Hasse diagram is given by 3 5
1
Lattices
Defination : A lattice L is a poset in which every pair of elements has a LUB
and GLB.
e.g. A poset (L,) is called a lattice if ab and ab exist in L for all a,b L.
This is true for such pairs a,b L. , so Lattice {L,|} and
Lattice {(P(S),)} are isomorphic .
Unit 5: Part IV
Minimum Spanning Tree (MST)
• Basic Terms
• Kruskal’s Algorithm for MST
• Prism’s Algorithm for MST
• Matrix Version of Prism’s Algorithm
Basic Terms
• A tree is a connected undirected graph with no
simple circuits.
B
A
7
7 3
C 5 D
4
6 8 4
9
E F
Sol : Given n=6 vertices and e=9 edges in G.
we have
Sr. no. Edges Weights Forms
Circuit ?
Added or Not
So. MST is
1 (B,D) 3 No Added (1)
2 (A,E) 4 No Added (2)
3 (F,D) 4 No Added (3)
4 (B,F) 5 YES NOT Added
5 (C,E) 6 No Added (4)
6 (C,B) 7 No Added (5)
7 (A,C) 7 Yes Not Added The minimum weight of
spanning Tree is 24.
8 (A,F) 8 -- Not Added
9 (B,E) 9 -- Not Added
Prim’s Algorithm
T = a spanning tree containing a single node s;
E = set of edges adjacent to s;
while T does not contain all the nodes
{
remove an edge (v, w) of lowest cost from E
if w is already in T then discard edge (v, w)
else {
add edge (v, w) and node w to T
add to E the edges adjacent to w
}
}
Steps involved in Prim’s Algorithm
1. Consider the given connected, weighted graph G with n vertices ,
whose minimum spanning tree T, is to be determine.
2. Select an edge of the graph G having minimum weight and
consider any vertex of this edge.
3. Among all the edges incident (connected) with the selected
vertex select an edge with minimum weight which do not form a
circuit .Include it in T.
4. At each stage, select an edge with minimum weight joining a
vertex already included in T and a vertex which is yet to be
included.
5. Repeat this process for n-1 time or un-till all the vertices of G are
not included in T .
Example of Prim’s Algorithm
• Find the minimal spanning tree of the
following graph using Prim’s Algorithm
b 6.3 c
a
4.8
8.3 2.0
12.5
d
f 5.0 e
b 6.3
4.8
8.3 2.0
12.5
d
f 5.0
2.0
d
f 5.0 e
b 6.3 c
a
4.8
2.0
12.5
d
f 5.0 e
20 19
D 12
B
10 15
12 13
F C
8 E 14
This network may be described using a Distance Matrix
A B C D E F
A - 19 20 - -
-
B 19 - 13 12 - -
C - 13 - 15 14 -
D 20 12 15 - 12 10
E - - 14 12 - 8
F - - - 10 8 -
Step 1: Choose a starting vertex and delete all elements
in that vertex’s row and arrow its column
20 19
AB BD DF FE BC
D 12
B
19 12 10 8 13
10 15
12 13
F C
8 E 14
A B C D
A 4 3
B 4 5 3
M
C 3 5 2
D 3 2
AC CD DB
3 2 3