Agenda
INTRODUCTION ABOUT GRAPH SPANNING TREE MINIMAL SPANNING TREE KRUSKALS ALGORITHM DIJKSTRAS ALGORITHM
Graph
A Graph G=(V, E), Where V is a nonempty set of vertices & E is a set
of edges. every edge is associated with unordered pair of vertices. V={V1, V2, V3, V4} ={e1, e2}
V3
e2 e1 V4
V1
e1=<V4,V1> e2=<V3,V2>
Tree
V2
Spanning Tree
Let G be a Graph & H be a Spanning Sub graph of
V3
G=(V, E) be a connected graph if there is a function f : V(G) -> R then it is called weighted connected graph. A(G),The cost adjacency matrix of G, whose entries are given by
ij=
V2 1 V1
V3
4 3
V5
V4
Prims Algorithm (Based on Vertices ) (order is O(E +V lg V) Kruskals Algorithm(Based on Edges)(order is O(E lg E) Sollin's Algorithm
Kruskals Algorithm
Input Connected weighted graph with |v(G)|=n Or Cost adjacency matrix(n*n)
Output Minimal Spanning Tree
Example
1 2
Dijkstras Algorithm
[Single Source Shortest Path Problem] Input:
Connected weighted graph G(V|G|=n) Or Cost adjacency matrix (n*n) with a specified vertex as source say v.
graph,with all weights positive) {G has vertices a=V0,V1,Vn=Z and weights w(Vi,Vj) where w(Vi,Vj) = if {Vi,Vj} is not an edge in G} for i:=1 to n
L(Vi):= L(a):= 0 S:= { the labels are now initialized so that the label of a is 0 and all other labels are , and S is the empty set}
While z s
Begin
If L(u)+w(u , v)<L(v) then L(v):=L(u)+w( u,v) {this adds a vertex to S with minimal label and updates the labels
of vertices not in S}
V1
8 4
V6
7 7 7 7
9 9 9 9
13 13
References
1.Discrete Mathematics and its Applications ,6th edition., Tata McGraw-Hill.,2007.,by Kenneth.H.Rosen 2.Graph Theory and its Applications ,2nd edition.,Chapman & Hall/CRC.,2006., By Jonathan L.Gross Jay Yellen 3.Introduction to Algorithms.,Prentice Hall of India.,2004.,by Thomas H.Cormen,Charles E.Leiserson,Ronald L.Rivest
Thank You