SlideShare a Scribd company logo
1 of 55
Operations Research
CS-302
(3+0)
Prerequisites:
Probability and Statistics
SYED MUHAMMAD RAFI
LECTURER, DEPARTMENT OF SOFTWARE ENGINEERING
FACULTY OF ENGINEERING SCIENCE AND TECHNOLOGY,
ZIAUDDIN UNIVERSITY
GRAPHS
Lecture # 06
Operations Research
2
Analysis Of Algorithms 3
Analysis Of Algorithms 4
Analysis Of Algorithms 5
Analysis Of Algorithms 6
Topological Sort
Indegree Before Dequeue
Vertex 1 2 3 4 5
0 0 0 0 0
1 0 0 0 0
2 1 1 1 0
3 2 1 0 0
1 1 0 0 0
3 3 3 3 2
2 2 2 1 0
enqueue
V1
V2
V3
V4
V5
V6
V7
V1
V2
V5
V4
V3
, V7
Analysis Of Algorithms 7
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
Step by Step
Step 1
Analysis Of Algorithms 8
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
Step by Step
Step 2
Analysis Of Algorithms 9
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
Step by Step
Step 3
Analysis Of Algorithms 10
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
0
0
1
0
0
3
1
V4
V4
Step by Step
Step 4
Analysis Of Algorithms 11
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
0
0
1
0
0
3
1
V4
V4
0
0
0
0
0
2
0
V3, V7
V3
Step by Step
Step 5
Analysis Of Algorithms 12
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
0
0
1
0
0
3
1
V4
V4
0
0
0
0
0
2
0
V3, V7
V3
0
0
0
0
0
1
0
V7
Step by Step
Step 6
Analysis Of Algorithms 13
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
0
0
1
0
0
3
1
V4
V4
0
0
0
0
0
2
0
V3, V7
V3
0
0
0
0
0
1
0
V7
0
0
0
0
0
0
0
V6
V6
Step by Step
Step 7
Analysis Of Algorithms 14
Indegree Before Dequeue
Vertex 1 2 3 4 5 6 7
V1 0
V2 1
V3 2
V4 3
V5 1
V6 3
V7 2
enqueue V1
dequeue V1
Topological Sort
0
0
1
2
1
3
2
V2
V2
0
0
1
1
0
3
2
V5
V5
0
0
1
0
0
3
1
V4
V4
0
0
0
0
0
2
0
V3, V7
V3
0
0
0
0
0
1
0
V7
0
0
0
0
0
0
0
V6
V6
Analysis Of Algorithms 15
Analysis Of Algorithms 16
Complexit
y Analysis
Topological Sort
Shortest Path Algorithm
Unweighted Graphs
Analysis Of Algorithms 17
Shortest Path Algorithm
Unweighted Graphs
Initial State
v Known dv pv
v1 0  0
v2 0  0
v3 0 0 0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v3
Step by Step
Step 1
Analysis Of Algorithms 18
Shortest Path Algorithm
Unweighted Graphs
Initial State
v Known dv pv
v1 0  0
v2 0  0
v3 0 0 0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v3
v3 dequeued
Known dv pv
0 1 v3
0  0
1 0 0
0  0
0  0
0 1 v3
0  0
v1, v6
Step by Step
Step 2
Analysis Of Algorithms 19
Shortest Path Algorithm
Unweighted Graphs
Initial State
v Known dv pv
v1 0  0
v2 0  0
v3 0 0 0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v3
v3 dequeued
Known dv pv
0 1 v3
0  0
1 0 0
0  0
0  0
0 1 v3
0  0
v1, v6
v1 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
0 1 v3
0  0
v6, v2, v4
Step by Step
Step 3
Analysis Of Algorithms 20
Shortest Path Algorithm
Unweighted Graphs
Initial State
v Known dv pv
v1 0  0
v2 0  0
v3 0 0 0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v3
v3 dequeued
Known dv pv
0 1 v3
0  0
1 0 0
0  0
0  0
0 1 v3
0  0
v1, v6
v1 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
0 1 v3
0  0
v6, v2, v4
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
Step by Step
Step 4
Analysis Of Algorithms 21
Shortest Path Algorithm
Unweighted Graphs
v2 dequeued
v Known dv pv
v1 1 1 v3
v2 1 2 v1
v3 1 0 0
v4 0 2 v1
v5 0 3 v2
v6 1 1 v3
v7 0  0
Q v4, v5
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
Step by Step
Step 5
Analysis Of Algorithms 22
Shortest Path Algorithm
Unweighted Graphs
v2 dequeued
v Known dv pv
v1 1 1 v3
v2 1 2 v1
v3 1 0 0
v4 0 2 v1
v5 0 3 v2
v6 1 1 v3
v7 0  0
Q v4, v5
v4 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
0 3 v2
1 1 v3
0 3 v4
v5, v7
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
Step by Step
Step 6
Analysis Of Algorithms 23
Shortest Path Algorithm
Unweighted Graphs
v2 dequeued
v Known dv pv
v1 1 1 v3
v2 1 2 v1
v3 1 0 0
v4 0 2 v1
v5 0 3 v2
v6 1 1 v3
v7 0  0
Q v4, v5
v4 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
0 3 v2
1 1 v3
0 3 v4
v5, v7
v5 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
1 3 v2
1 1 v3
0 3 v4
v7
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
Step by Step
Step 7
Analysis Of Algorithms 24
Shortest Path Algorithm
Unweighted Graphs
v2 dequeued
v Known dv pv
v1 1 1 v3
v2 1 2 v1
v3 1 0 0
v4 0 2 v1
v5 0 3 v2
v6 1 1 v3
v7 0  0
Q v4, v5
v4 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
0 3 v2
1 1 v3
0 3 v4
v5, v7
v5 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
1 3 v2
1 1 v3
0 3 v4
v7
v7 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
1 3 v2
1 1 v3
1 3 v4
empty
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
Step by Step
Step 8
Analysis Of Algorithms 25
Shortest Path Algorithm
Unweighted Graphs
v2 dequeued
v Known dv pv
v1 1 1 v3
v2 1 2 v1
v3 1 0 0
v4 0 2 v1
v5 0 3 v2
v6 1 1 v3
v7 0  0
Q v4, v5
v4 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
0 3 v2
1 1 v3
0 3 v4
v5, v7
v5 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
1 3 v2
1 1 v3
0 3 v4
v7
v7 dequeued
Known dv pv
1 1 v3
1 2 v1
1 0 0
1 2 v1
1 3 v2
1 1 v3
1 3 v4
empty
v6 dequeued
Known dv pv
1 1 v3
0 2 v1
1 0 0
0 2 v1
0  0
1 1 v3
0  0
v2, v4
n = |V|
T(n) = O(n2) for arrays
T(n) = O(|V| + |E|) for adjacency List
Analysis Of Algorithms 26
Shortest Path Algorithm
Unweighted Graphs
Analysis Of Algorithms 27
Complexit
y Analysis
Analysis Of Algorithms 28
END OF (Shortest Path Unweighted Graphs)
Algorithm
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Analysis Of Algorithms 29
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v1
Step by Step
Step 1
Analysis Of Algorithms 30
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v1
v1 dequeued
Known dv pv
1 0 0
0 2 v1
0 0 0
0 1 v1
0  0
0  0
0  0
v2, v4
Step by Step
Step 2
Analysis Of Algorithms 31
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
v2 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 v4
0 1 v1
0 3 v4
0 9 v4
0 5 v4
v2, v5,v3, v6, v7,
Step by Step
Step 3
v1dequeued
Known dv pv
1 0 0
0 2 v1
0 0 0
0 1 v1
0  0
0  0
0  0
v4, v2
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v1 Analysis Of Algorithms 32
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
v2 dequeued
Known dv pv
1 0 0
1 2 v1
0 0 0
0 1 v1
0 12 v2
0  0
0  0
v4, v5
Step by Step
Step 4
v1dequeued
Known dv pv
1 0 0
0 2 v1
0 0 0
0 1 v1
0  0
0  0
0  0
v2, v4
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Q v1
v4 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 v4
1 1 v1
0 3 v4
0 9 v4
0 5 v4
v5, v3, v6,v7
Analysis Of Algorithms 33
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Step by Step
Step 5
v5 dequeued
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 0 3 v4
v4 1 1 v1
v5 1 3 v4
v6 0 9 v4
v7 0 5 v4
Q v3, v6,v7
v4 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 0
1 1 v1
0 3 v4
0 9 v4
0 5 v4
v5, v3, v6,v7
Analysis Of Algorithms 34
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Step by Step
Step 6
v3 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 v4
1 1 v1
1 3 v4
0 8 v3
0 5 v4
v6,v7
v5 dequeued
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 0 3 0
v4 1 1 v1
v5 1 3 v4
v6 0 9 v4
v7 0 5 v4
Q v3, v6,v7
v4 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 0
1 1 v1
0 3 v4
0 9 v4
0 5 v4
v5, v3, v6,v7
Analysis Of Algorithms 35
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
v6 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 v4
1 1 v1
1 3 v4
1 8 v3
0 5 v4
v7
Step by Step
Step 7
v3 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 0
1 1 v1
1 3 v4
0 8 v3
0 5 v4
v6,v7
v5 dequeued
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 0 3 0
v4 1 1 v1
v5 1 3 v4
v6 0 9 v4
v7 0 5 v4
Q v3, v6,v7
v4 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 0
1 1 v1
0 3 v4
0 9 v4
0 5 v4
v5, v3, v6,v7
Analysis Of Algorithms 36
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
v6 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 0
1 1 v1
1 3 v4
1 8 v3
0 5 v4
v7
Step by Step
Step 8
v3 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 0
1 1 v1
1 3 v4
0 8 v3
0 5 v4
v6,v7
v5 dequeued
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 0 3 0
v4 1 1 v1
v5 1 3 v4
v6 0 9 v4
v7 0 5 v4
Q v3, v6,v7
v4 dequeued
Known dv pv
1 0 0
1 2 v1
0 3 0
1 1 v1
0 3 v4
0 9 v4
0 5 v4
v5, v3, v6,v7
v7 dequeued
Known dv pv
1 0 0
1 2 v1
1 3 v4
1 1 v1
1 3 v4
1 6 v7
1 5 v4
Empty
Analysis Of Algorithms 37
Shortest Path Algorithm
Weighted Graphs
Dijkstra’s Algorithm
Analysis Of Algorithms 38
Complexity
Analysis
Analysis Of Algorithms 39
END OF Dijkstra’s Algorithm
Minimum Spanning Tree
Weighted and Undirected Graphs
Prim’s Algorithm
Analysis Of Algorithms 40
Prim’s
Algorithm
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Step by Step
Step 1
Minimum Spanning Tree
Weighted and Undirected Graphs
Analysis Of Algorithms 41
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Minimum Spanning Tree
Weighted and Undirected Graphs
v1 known
Known dv pv
1 0 0
0 2 v1
0 4 v1
0 1 v1
0  0
0  0
0  0
Prim’s
Algorithm
Step by Step
Step 2
Analysis Of Algorithms 42
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Minimum Spanning Tree
Weighted and Undirected Graphs
v1 known
Known dv pv
1 0 0
0 2 v1
0 4 v1
0 1 v1
0  0
0  0
0  0
Prim’s
Algorithm
Step by Step
Step 3
v4 known
Known dv pv
1 0 0
0 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v2 ,v3 , v5 , v6 , v7
Analysis Of Algorithms 43
Initial State
v Known dv pv
v1 0 0 0
v2 0  0
v3 0  0
v4 0  0
v5 0  0
v6 0  0
v7 0  0
Minimum Spanning Tree
Weighted and Undirected Graphs
v1 known
Known dv pv
1 0 0
0 2 v1
0 4 v1
0 1 v1
0  0
0  0
0  0
Prim’s
Algorithm
Step by Step
Step 4
v4 known
Known dv pv
1 0 0
0 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v2 ,v3 , v5 , v6 , v7
v2known
Known dv pv
1 0 0
1 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v3 , v5 , v6 , v7
Analysis Of Algorithms 44
v3 known
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 1 2 v4
v4 1 1 v1
v5 0 7 v4
v6 0 5 v3
v7 0 4 v4
v5 , v6 , v7
Minimum Spanning Tree
Weighted and Undirected Graphs
Prim’s
Algorithm
Step by Step
Step 5
v2known
Known dv pv
1 0 0
1 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v3 , v5 , v6 , v7
Analysis Of Algorithms 45
v3 known
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 1 2 v4
v4 1 1 v1
v5 0 7 v4
v6 0 5 v3
v7 0 4 v4
v5 , v6 , v7
Minimum Spanning Tree
Weighted and Undirected Graphs
v7 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
0 6 v7
0 1 v7
1 4 v4
v5 , v6
Prim’s
Algorithm
Step by Step
Step 6
v2known
Known dv pv
1 0 0
1 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v3 , v5 , v6 , v7
Analysis Of Algorithms 46
v3 known
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 1 2 v4
v4 1 1 v1
v5 0 7 v4
v6 0 5 v3
v7 0 4 v4
v5 , v6 , v7
Minimum Spanning Tree
Weighted and Undirected Graphs
v7 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
0 6 v7
0 1 v7
1 4 v4
v5 , v6
Prim’s
Algorithm
Step by Step
Step 7
v6 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
0 6 v7
1 1 v7
1 4 v4
v5
v2known
Known dv pv
1 0 0
1 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v3 , v5 , v6 , v7
Analysis Of Algorithms 47
Minimum Spanning Tree
Weighted and Undirected Graphs
Prim’s
Algorithm
Step by Step
Step 8
v5 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
1 6 v7
1 1 v7
1 4 v4
v2known
Known dv pv
1 0 0
1 2 v1
0 2 v4
1 1 v1
0 7 v4
0 8 v4
0 4 v4
v3 , v5 , v6 , v7
v3 known
v Known dv pv
v1 1 0 0
v2 1 2 v1
v3 1 2 v4
v4 1 1 v1
v5 0 7 v4
v6 0 5 v3
v7 0 4 v4
v5 , v6 , v7
v7 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
0 6 v7
0 1 v7
1 4 v4
v5 , v6
v6 known
Known dv pv
1 0 0
1 2 v1
1 2 v4
1 1 v1
0 6 v7
1 1 v7
1 4 v4
v5
Total Cost = 16
Analysis Of Algorithms 48
Prim’s Algorithm
Analysis Of Algorithms 49
Complexity
Analysis
Analysis Of Algorithms 50
END OF Prim’s Algorithm
Minimum Spanning Tree
Weighted and Undirected Graphs
Kruskal’s Algorithm
Analysis Of Algorithms 51
Kruskal’s Algorithm
Step by Step
Step 1
Minimum Spanning Tree
Weighted Undirected Graphs
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Analysis Of Algorithms 52
Minimum Spanning Tree
Weighted and Undirected Graphs
Kruskal’s Algorithm
Analysis Of Algorithms 53
Complexity
Analysis
Analysis Of Algorithms 54
End of Kruskal’s Algorithm
End
GRAPHS
Analysis Of Algorithms 55

More Related Content

More from SirRafiLectures (7)

AI Lecture-01 (Introduction) NN and Fuzzy
AI Lecture-01 (Introduction) NN and FuzzyAI Lecture-01 (Introduction) NN and Fuzzy
AI Lecture-01 (Introduction) NN and Fuzzy
 
Lecture 08 (SQE, Testing, PM, RM, ME).pptx
Lecture 08 (SQE, Testing, PM, RM, ME).pptxLecture 08 (SQE, Testing, PM, RM, ME).pptx
Lecture 08 (SQE, Testing, PM, RM, ME).pptx
 
Lecture 01 (Mean, Median, Mode).pdf
Lecture 01 (Mean, Median, Mode).pdfLecture 01 (Mean, Median, Mode).pdf
Lecture 01 (Mean, Median, Mode).pdf
 
ICT-Lecture_08(OperatingSystem).pdf
ICT-Lecture_08(OperatingSystem).pdfICT-Lecture_08(OperatingSystem).pdf
ICT-Lecture_08(OperatingSystem).pdf
 
ICT-Lecture_12(VonNeumannArchitecture).pptx
ICT-Lecture_12(VonNeumannArchitecture).pptxICT-Lecture_12(VonNeumannArchitecture).pptx
ICT-Lecture_12(VonNeumannArchitecture).pptx
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Fall_2022 classes Timetable_Rev2.pdf
Fall_2022 classes Timetable_Rev2.pdfFall_2022 classes Timetable_Rev2.pdf
Fall_2022 classes Timetable_Rev2.pdf
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Operations Research-Lecture 06B (Graphs).ppt

  • 1. Operations Research CS-302 (3+0) Prerequisites: Probability and Statistics SYED MUHAMMAD RAFI LECTURER, DEPARTMENT OF SOFTWARE ENGINEERING FACULTY OF ENGINEERING SCIENCE AND TECHNOLOGY, ZIAUDDIN UNIVERSITY
  • 7. Topological Sort Indegree Before Dequeue Vertex 1 2 3 4 5 0 0 0 0 0 1 0 0 0 0 2 1 1 1 0 3 2 1 0 0 1 1 0 0 0 3 3 3 3 2 2 2 2 1 0 enqueue V1 V2 V3 V4 V5 V6 V7 V1 V2 V5 V4 V3 , V7 Analysis Of Algorithms 7
  • 8. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort Step by Step Step 1 Analysis Of Algorithms 8
  • 9. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 Step by Step Step 2 Analysis Of Algorithms 9
  • 10. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 Step by Step Step 3 Analysis Of Algorithms 10
  • 11. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 0 0 1 0 0 3 1 V4 V4 Step by Step Step 4 Analysis Of Algorithms 11
  • 12. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 0 0 1 0 0 3 1 V4 V4 0 0 0 0 0 2 0 V3, V7 V3 Step by Step Step 5 Analysis Of Algorithms 12
  • 13. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 0 0 1 0 0 3 1 V4 V4 0 0 0 0 0 2 0 V3, V7 V3 0 0 0 0 0 1 0 V7 Step by Step Step 6 Analysis Of Algorithms 13
  • 14. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 0 0 1 0 0 3 1 V4 V4 0 0 0 0 0 2 0 V3, V7 V3 0 0 0 0 0 1 0 V7 0 0 0 0 0 0 0 V6 V6 Step by Step Step 7 Analysis Of Algorithms 14
  • 15. Indegree Before Dequeue Vertex 1 2 3 4 5 6 7 V1 0 V2 1 V3 2 V4 3 V5 1 V6 3 V7 2 enqueue V1 dequeue V1 Topological Sort 0 0 1 2 1 3 2 V2 V2 0 0 1 1 0 3 2 V5 V5 0 0 1 0 0 3 1 V4 V4 0 0 0 0 0 2 0 V3, V7 V3 0 0 0 0 0 1 0 V7 0 0 0 0 0 0 0 V6 V6 Analysis Of Algorithms 15
  • 16. Analysis Of Algorithms 16 Complexit y Analysis Topological Sort
  • 17. Shortest Path Algorithm Unweighted Graphs Analysis Of Algorithms 17
  • 18. Shortest Path Algorithm Unweighted Graphs Initial State v Known dv pv v1 0  0 v2 0  0 v3 0 0 0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v3 Step by Step Step 1 Analysis Of Algorithms 18
  • 19. Shortest Path Algorithm Unweighted Graphs Initial State v Known dv pv v1 0  0 v2 0  0 v3 0 0 0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v3 v3 dequeued Known dv pv 0 1 v3 0  0 1 0 0 0  0 0  0 0 1 v3 0  0 v1, v6 Step by Step Step 2 Analysis Of Algorithms 19
  • 20. Shortest Path Algorithm Unweighted Graphs Initial State v Known dv pv v1 0  0 v2 0  0 v3 0 0 0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v3 v3 dequeued Known dv pv 0 1 v3 0  0 1 0 0 0  0 0  0 0 1 v3 0  0 v1, v6 v1 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 0 1 v3 0  0 v6, v2, v4 Step by Step Step 3 Analysis Of Algorithms 20
  • 21. Shortest Path Algorithm Unweighted Graphs Initial State v Known dv pv v1 0  0 v2 0  0 v3 0 0 0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v3 v3 dequeued Known dv pv 0 1 v3 0  0 1 0 0 0  0 0  0 0 1 v3 0  0 v1, v6 v1 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 0 1 v3 0  0 v6, v2, v4 v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 Step by Step Step 4 Analysis Of Algorithms 21
  • 22. Shortest Path Algorithm Unweighted Graphs v2 dequeued v Known dv pv v1 1 1 v3 v2 1 2 v1 v3 1 0 0 v4 0 2 v1 v5 0 3 v2 v6 1 1 v3 v7 0  0 Q v4, v5 v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 Step by Step Step 5 Analysis Of Algorithms 22
  • 23. Shortest Path Algorithm Unweighted Graphs v2 dequeued v Known dv pv v1 1 1 v3 v2 1 2 v1 v3 1 0 0 v4 0 2 v1 v5 0 3 v2 v6 1 1 v3 v7 0  0 Q v4, v5 v4 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 0 3 v2 1 1 v3 0 3 v4 v5, v7 v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 Step by Step Step 6 Analysis Of Algorithms 23
  • 24. Shortest Path Algorithm Unweighted Graphs v2 dequeued v Known dv pv v1 1 1 v3 v2 1 2 v1 v3 1 0 0 v4 0 2 v1 v5 0 3 v2 v6 1 1 v3 v7 0  0 Q v4, v5 v4 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 0 3 v2 1 1 v3 0 3 v4 v5, v7 v5 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 1 3 v2 1 1 v3 0 3 v4 v7 v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 Step by Step Step 7 Analysis Of Algorithms 24
  • 25. Shortest Path Algorithm Unweighted Graphs v2 dequeued v Known dv pv v1 1 1 v3 v2 1 2 v1 v3 1 0 0 v4 0 2 v1 v5 0 3 v2 v6 1 1 v3 v7 0  0 Q v4, v5 v4 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 0 3 v2 1 1 v3 0 3 v4 v5, v7 v5 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 1 3 v2 1 1 v3 0 3 v4 v7 v7 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 1 3 v2 1 1 v3 1 3 v4 empty v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 Step by Step Step 8 Analysis Of Algorithms 25
  • 26. Shortest Path Algorithm Unweighted Graphs v2 dequeued v Known dv pv v1 1 1 v3 v2 1 2 v1 v3 1 0 0 v4 0 2 v1 v5 0 3 v2 v6 1 1 v3 v7 0  0 Q v4, v5 v4 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 0 3 v2 1 1 v3 0 3 v4 v5, v7 v5 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 1 3 v2 1 1 v3 0 3 v4 v7 v7 dequeued Known dv pv 1 1 v3 1 2 v1 1 0 0 1 2 v1 1 3 v2 1 1 v3 1 3 v4 empty v6 dequeued Known dv pv 1 1 v3 0 2 v1 1 0 0 0 2 v1 0  0 1 1 v3 0  0 v2, v4 n = |V| T(n) = O(n2) for arrays T(n) = O(|V| + |E|) for adjacency List Analysis Of Algorithms 26
  • 27. Shortest Path Algorithm Unweighted Graphs Analysis Of Algorithms 27 Complexit y Analysis
  • 28. Analysis Of Algorithms 28 END OF (Shortest Path Unweighted Graphs) Algorithm
  • 29. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Analysis Of Algorithms 29
  • 30. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v1 Step by Step Step 1 Analysis Of Algorithms 30
  • 31. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v1 v1 dequeued Known dv pv 1 0 0 0 2 v1 0 0 0 0 1 v1 0  0 0  0 0  0 v2, v4 Step by Step Step 2 Analysis Of Algorithms 31
  • 32. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm v2 dequeued Known dv pv 1 0 0 1 2 v1 0 3 v4 0 1 v1 0 3 v4 0 9 v4 0 5 v4 v2, v5,v3, v6, v7, Step by Step Step 3 v1dequeued Known dv pv 1 0 0 0 2 v1 0 0 0 0 1 v1 0  0 0  0 0  0 v4, v2 Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v1 Analysis Of Algorithms 32
  • 33. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm v2 dequeued Known dv pv 1 0 0 1 2 v1 0 0 0 0 1 v1 0 12 v2 0  0 0  0 v4, v5 Step by Step Step 4 v1dequeued Known dv pv 1 0 0 0 2 v1 0 0 0 0 1 v1 0  0 0  0 0  0 v2, v4 Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Q v1 v4 dequeued Known dv pv 1 0 0 1 2 v1 0 3 v4 1 1 v1 0 3 v4 0 9 v4 0 5 v4 v5, v3, v6,v7 Analysis Of Algorithms 33
  • 34. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Step by Step Step 5 v5 dequeued v Known dv pv v1 1 0 0 v2 1 2 v1 v3 0 3 v4 v4 1 1 v1 v5 1 3 v4 v6 0 9 v4 v7 0 5 v4 Q v3, v6,v7 v4 dequeued Known dv pv 1 0 0 1 2 v1 0 3 0 1 1 v1 0 3 v4 0 9 v4 0 5 v4 v5, v3, v6,v7 Analysis Of Algorithms 34
  • 35. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Step by Step Step 6 v3 dequeued Known dv pv 1 0 0 1 2 v1 1 3 v4 1 1 v1 1 3 v4 0 8 v3 0 5 v4 v6,v7 v5 dequeued v Known dv pv v1 1 0 0 v2 1 2 v1 v3 0 3 0 v4 1 1 v1 v5 1 3 v4 v6 0 9 v4 v7 0 5 v4 Q v3, v6,v7 v4 dequeued Known dv pv 1 0 0 1 2 v1 0 3 0 1 1 v1 0 3 v4 0 9 v4 0 5 v4 v5, v3, v6,v7 Analysis Of Algorithms 35
  • 36. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm v6 dequeued Known dv pv 1 0 0 1 2 v1 1 3 v4 1 1 v1 1 3 v4 1 8 v3 0 5 v4 v7 Step by Step Step 7 v3 dequeued Known dv pv 1 0 0 1 2 v1 1 3 0 1 1 v1 1 3 v4 0 8 v3 0 5 v4 v6,v7 v5 dequeued v Known dv pv v1 1 0 0 v2 1 2 v1 v3 0 3 0 v4 1 1 v1 v5 1 3 v4 v6 0 9 v4 v7 0 5 v4 Q v3, v6,v7 v4 dequeued Known dv pv 1 0 0 1 2 v1 0 3 0 1 1 v1 0 3 v4 0 9 v4 0 5 v4 v5, v3, v6,v7 Analysis Of Algorithms 36
  • 37. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm v6 dequeued Known dv pv 1 0 0 1 2 v1 1 3 0 1 1 v1 1 3 v4 1 8 v3 0 5 v4 v7 Step by Step Step 8 v3 dequeued Known dv pv 1 0 0 1 2 v1 1 3 0 1 1 v1 1 3 v4 0 8 v3 0 5 v4 v6,v7 v5 dequeued v Known dv pv v1 1 0 0 v2 1 2 v1 v3 0 3 0 v4 1 1 v1 v5 1 3 v4 v6 0 9 v4 v7 0 5 v4 Q v3, v6,v7 v4 dequeued Known dv pv 1 0 0 1 2 v1 0 3 0 1 1 v1 0 3 v4 0 9 v4 0 5 v4 v5, v3, v6,v7 v7 dequeued Known dv pv 1 0 0 1 2 v1 1 3 v4 1 1 v1 1 3 v4 1 6 v7 1 5 v4 Empty Analysis Of Algorithms 37
  • 38. Shortest Path Algorithm Weighted Graphs Dijkstra’s Algorithm Analysis Of Algorithms 38 Complexity Analysis
  • 39. Analysis Of Algorithms 39 END OF Dijkstra’s Algorithm
  • 40. Minimum Spanning Tree Weighted and Undirected Graphs Prim’s Algorithm Analysis Of Algorithms 40
  • 41. Prim’s Algorithm Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Step by Step Step 1 Minimum Spanning Tree Weighted and Undirected Graphs Analysis Of Algorithms 41
  • 42. Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Minimum Spanning Tree Weighted and Undirected Graphs v1 known Known dv pv 1 0 0 0 2 v1 0 4 v1 0 1 v1 0  0 0  0 0  0 Prim’s Algorithm Step by Step Step 2 Analysis Of Algorithms 42
  • 43. Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Minimum Spanning Tree Weighted and Undirected Graphs v1 known Known dv pv 1 0 0 0 2 v1 0 4 v1 0 1 v1 0  0 0  0 0  0 Prim’s Algorithm Step by Step Step 3 v4 known Known dv pv 1 0 0 0 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v2 ,v3 , v5 , v6 , v7 Analysis Of Algorithms 43
  • 44. Initial State v Known dv pv v1 0 0 0 v2 0  0 v3 0  0 v4 0  0 v5 0  0 v6 0  0 v7 0  0 Minimum Spanning Tree Weighted and Undirected Graphs v1 known Known dv pv 1 0 0 0 2 v1 0 4 v1 0 1 v1 0  0 0  0 0  0 Prim’s Algorithm Step by Step Step 4 v4 known Known dv pv 1 0 0 0 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v2 ,v3 , v5 , v6 , v7 v2known Known dv pv 1 0 0 1 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v3 , v5 , v6 , v7 Analysis Of Algorithms 44
  • 45. v3 known v Known dv pv v1 1 0 0 v2 1 2 v1 v3 1 2 v4 v4 1 1 v1 v5 0 7 v4 v6 0 5 v3 v7 0 4 v4 v5 , v6 , v7 Minimum Spanning Tree Weighted and Undirected Graphs Prim’s Algorithm Step by Step Step 5 v2known Known dv pv 1 0 0 1 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v3 , v5 , v6 , v7 Analysis Of Algorithms 45
  • 46. v3 known v Known dv pv v1 1 0 0 v2 1 2 v1 v3 1 2 v4 v4 1 1 v1 v5 0 7 v4 v6 0 5 v3 v7 0 4 v4 v5 , v6 , v7 Minimum Spanning Tree Weighted and Undirected Graphs v7 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 0 6 v7 0 1 v7 1 4 v4 v5 , v6 Prim’s Algorithm Step by Step Step 6 v2known Known dv pv 1 0 0 1 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v3 , v5 , v6 , v7 Analysis Of Algorithms 46
  • 47. v3 known v Known dv pv v1 1 0 0 v2 1 2 v1 v3 1 2 v4 v4 1 1 v1 v5 0 7 v4 v6 0 5 v3 v7 0 4 v4 v5 , v6 , v7 Minimum Spanning Tree Weighted and Undirected Graphs v7 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 0 6 v7 0 1 v7 1 4 v4 v5 , v6 Prim’s Algorithm Step by Step Step 7 v6 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 0 6 v7 1 1 v7 1 4 v4 v5 v2known Known dv pv 1 0 0 1 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v3 , v5 , v6 , v7 Analysis Of Algorithms 47
  • 48. Minimum Spanning Tree Weighted and Undirected Graphs Prim’s Algorithm Step by Step Step 8 v5 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 1 6 v7 1 1 v7 1 4 v4 v2known Known dv pv 1 0 0 1 2 v1 0 2 v4 1 1 v1 0 7 v4 0 8 v4 0 4 v4 v3 , v5 , v6 , v7 v3 known v Known dv pv v1 1 0 0 v2 1 2 v1 v3 1 2 v4 v4 1 1 v1 v5 0 7 v4 v6 0 5 v3 v7 0 4 v4 v5 , v6 , v7 v7 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 0 6 v7 0 1 v7 1 4 v4 v5 , v6 v6 known Known dv pv 1 0 0 1 2 v1 1 2 v4 1 1 v1 0 6 v7 1 1 v7 1 4 v4 v5 Total Cost = 16 Analysis Of Algorithms 48
  • 49. Prim’s Algorithm Analysis Of Algorithms 49 Complexity Analysis
  • 50. Analysis Of Algorithms 50 END OF Prim’s Algorithm
  • 51. Minimum Spanning Tree Weighted and Undirected Graphs Kruskal’s Algorithm Analysis Of Algorithms 51
  • 52. Kruskal’s Algorithm Step by Step Step 1 Minimum Spanning Tree Weighted Undirected Graphs Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Analysis Of Algorithms 52
  • 53. Minimum Spanning Tree Weighted and Undirected Graphs Kruskal’s Algorithm Analysis Of Algorithms 53 Complexity Analysis
  • 54. Analysis Of Algorithms 54 End of Kruskal’s Algorithm