It is a algorithm used to find a minimum cost spanning tree for connected weighted undirected graph.This algorithm first appeared in Proceedings of the American Mathematical Society in 1956, and was written by Joseph Kruskal.
It is a algorithm used to find a minimum cost spanning tree for connected weighted undirected graph.This algorithm first appeared in Proceedings of the American Mathematical Society in 1956, and was written by Joseph Kruskal.
Linear Combination, Span And Linearly Independent, Dependent SetDhaval Shukla
In this presentation, the topic of Linear Combination, Span and Linearly Independent and Linearly Dependent Sets have been discussed. The sums for each topic have been given to understand the concept clearly for viewers.
In computer science, Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized.
Linear Combination, Span And Linearly Independent, Dependent SetDhaval Shukla
In this presentation, the topic of Linear Combination, Span and Linearly Independent and Linearly Dependent Sets have been discussed. The sums for each topic have been given to understand the concept clearly for viewers.
In computer science, Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized.
A presentation on prim's and kruskal's algorithmGaurav Kolekar
This slides are for a presentation on Prim's and Kruskal's algorithm. Where I have tried to explain how both the algorithms work, their similarities and their differences.
The purpose of making this presentation is to explain Kruskal's Algorithm in a simple and attractive way. However, the content of this presentation is taken from more than one resources and merged at one place for the better understanding of students. It also contains an example which will definitely help students to understand it more quickly.
a spanning tree of that graph is a subgraph that is a tree and connects all the vertices together. A single graph can have many different spanning trees.
The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it is capable of handling graphs in which some of the edge weights are negative numbers.
To give the complete list of Uq(sl2)-actions of the quantum plane, we first obtain the structure of quantum plane automorphisms. Then we introduce some special symbolic matrices to classify the series of actions using the weights. There are uncountably many isomorphism classes of the symmetries. We give the classical limit of the above actions.
Second Part of Inner Products including Cauchy Schwarz inequality, Pythagorean theorem, Orthogonal complement, Projection theorem with geometrical interpretation, Least Square Solution
a graph search algorithm that solves the single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
2. What is a Spanning Tree
In order to find a spanning tree, we must make sure that every node (vertex) is
some how connected to the rest of the nodes by arcs (edges)
Use the fewest number of edges possible.
2
3. What is a Spanning Tree
In order to find a spanning tree, we must make sure that every node (vertex) is
some how connected to the rest of the nodes by arcs (edge)
Use the fewest number of edges possible.
3
4. What is a Spanning Tree
In order to find a spanning tree, we must make sure that every node (vertex) is
some how connected to the rest of the nodes by arcs (edge)
Use the fewest number of edges possible.
If a loop can be found,
then one of the edges is not necessary
4
5. What is a Spanning Tree
In order to find a spanning tree, we must make sure that every node (vertex) is
some how connected to the rest of the nodes by an arc (edge)
Use the fewest number of edges possible.
You may think now, How many edges you
have in a spanning tree given N vertices
5
6. Minimum Spanning Tree
The subset of edges E that connects all vertices V in the graph, and has
minimum total weight.
a
b c
d
1
6
54
2
6
7. Minimum Spanning Tree
The subset of edges E that connects all vertices V in the graph, and has
minimum total weight.
a
b c
d
1
6
54
2
MST = { (a,b),(a,d),(d,c) }
7
9. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
Kruskal's algorithm utilizes Disjoint Sets (DS).
9
10. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
Kruskal's algorithm utilizes Disjoint Sets (DS).
DS has two Operations Find and Union.
10
11. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
Find: takes an item and pretend that this is a
DS that item belongs to
Union: will merge two DS of its input items in to
one DS
11
12. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
A: is used to store all edges of the minimum
spanning tree
Initially A is empty
Eventually return A
12
13. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
for each vertex v of the graph, make a DS with v
Each vertex will be used to create a single vertex
Disjoint Set
13
14. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
Sort all edges by weight increasingly
the edge of smallest weight will be in front and the one
with largest weight will be at the end
14
15. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
1st we will take the edge with the smallest weight
C and f don’t belong to the same DS
15
16. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),}
c and f will be merged in a one DS
(c,f) is pushed to A
16
17. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),}
17
18. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),}
18
19. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),}
c and d will be merged in a one DS
19
20. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),}
c and d will be merged in a one DS
20
21. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),(c,d),}
21
22. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),(c,d),}
e and f belong to the same DS
DO NOT MERGE !!
22
23. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),(c,d),(a,b)}
23
24. Kruskal’s Algorithm
Kruskal(V,E)
A = ø
foreach v V:
Make-disjoint-set(v)
Sort E by weight increasingly
foreach (v1,v2) E:
if Find(v1) ≠ Find(v2):
A = A U {(v1,v2)}
Union (v1,v2)
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { (c,f),(a,f),(d,e),(c,d),(a,b)}
Now we have a Spanning Tree that connects all
vertices which have the minimum total weight
24
28. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
A: is used to store all edges of the minimum
spanning tree
Initially A is empty
Eventually return A
28
29. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
for each vertex v of the graph, Each vertex will have
two attributes KEY and PARENT
KEY and PARENT initialized to ∞ and null Respectively
29
30. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
a
2
c
b d
f
4
6
3
4
15
e
2
A = { }
for each vertex v of the graph, Each vertex will have
two attributes KEY and PARENT
KEY and PARENT initialized to ∞ and null Respectively
∞,null
∞,null
∞,null
∞,null
∞,null
∞,null
30
31. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Randomly choose a vertex as a ROOT r and set its
KEY value to Zero
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
31
32. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Create Q list which contains all vertices in the graph
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
Q = { a,b,c,d,e,f }
32
33. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Find Q with the smallest (Minimum) KEY
In this case, KEY[a] = 0 (Minimum KEY)
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
Q = { a,b,c,d,e,f }
33
34. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Remove a from Q
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
Q = { b,c,d,e,f }
34
35. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
PARENT [a] = null !!
Skip the if statement
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
Q = { b,c,d,e,f }
35
36. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Update attributes for all vertices Adjacent to a which
are b and f
Starting with f , 2 < ∞
∞,null
∞,null
∞,null
∞,null
0,null
∞,null
Q = { b,c,d,e,f }
36
37. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { }
Update attributes for all vertices Adjacent to a which are b
and f
Starting with f , 2 < ∞
PARENT [ f ] = a and KEY [ f ] = 2
∞,null
∞,null
∞,null
2, a
0,null
4, a
Q = { b,c,d,e,f }
37
38. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f) }
Now, Enter the Second Loop
a ! Q
u = min(Q) = f , Remove f from Q
PARENT [ f ] ! = null, push (a,f) to A
∞,null
∞,null
∞,null
2, a
0,null
4, a
Q = { b,c,d,e }
38
39. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f) }
Update attributes for all vertices Adjacent to f which
are c and d where weight < KEY
1, f
∞,null
4, f
2, a
0,null
4, a
Q = { b,c,d,e }
39
40. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f) }
Now, Enter the NEXT Loop
u = min(Q) = c , Remove c from Q
PARENT [ c ] ! = null, push (c,f) to A
1, f
∞,null
4, f
2, a
0,null
4, a
Q = { b,d,e }
40
41. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f) }
Update attributes for all vertices Adjacent to c where
weight < KEY
1, f
3, c
4, f
2, a
0,null
4, a
Q = { b,d,e }
41
42. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d) }
Enter the NEXT Loop
u = min(Q) = d , Remove d from Q
PARENT [ d ] ! = null, push (c,d) to A
1, f
3, c
4, f
2, a
0,null
4, a
Q = { b,e }
42
43. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d) }
Update attributes for all vertices Adjacent to d where
weight < KEY
1, f
3, c
2, d
2, a
0,null
4, a
Q = { b,e }
43
44. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e) }
Enter the NEXT Loop
u = min(Q) = e , Remove e from Q
PARENT [ e] ! = null, push (d,e) to A
1, f
3, c
2, d
2, a
0,null
4, a
Q = { b }
44
45. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e) }
No Updates for attributes because d and f ! Q
1, f
3, c
2, d
2, a
0,null
4, a
Q = { b }
45
46. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e), (a,b) }
Enter the NEXT Loop
u = b , Remove b from Q
PARENT [ b] ! = null, push (a,b) to A
1, f
3, c
2, d
2, a
0,null
4, a
Q = { }
46
47. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e), (a,b) }
No Updates for attributes because all neighbors of b
doesn’t exist in Q
1, f
3, c
2, d
2, a
0,null
4, a
Q = { }
47
48. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e), (a,b) }
Enter the NEXT Loop, Q = ø
Exit loop
Return A
Q = { }
48
49. Prim’s Algorithm
A = ø
foreach v V:
KEY[v] = ∞
PARENT[v] = null
KEY[r] = 0
Q = V
While Q != ø:
u = min (Q) by KEY value
Q = Q – u
if PARENT(u) != null:
A = A U (u, PARENT(u))
foreach v Adj(u):
if v Q and w(u,v) < KEY[v]:
PARENT[v] = u
KEY[v] = w
Return A
3
a
2
c
b d
f
4
6
4
15
e
2
A = { (a,f), (c,f), (c,d), (d,e), (a,b) }
Now we have a Spanning Tree that connects all
vertices which have the minimum total weight
Q = { }
49
51. Prim’s Algorithm
The time complexity of the algorithm is computed as follows:
Step 1 costs q(n) time.
The for loop in Step 2 requires Ø(n) time.
The time taken by steps 3 - 6 is O(n).
The time taken by Step 10 to search for a vertex y closest to X is Ø(n) per iteration. This
is because the algorithm inspects each entry in the vector representing the set Y. Since
it is executed n-1 times, the overall time required by Step 10 is Ø(n2).
Steps 11,12 and 13 cost Ø(1) time per iteration for a total of q(n) time.
The for loop in Step 14 is executed 2m times, where m=|E|. This is because each edge
(y, w) is inspected twice: once when y is moved to X and the other when w is moved to
X.
Hence, the overall time required by step 14 is Ø(m).
The test in Step 15 is executed exactly m times, and Steps 16 and 17 are executed at
most m times.
Thus, Steps 14 to 19 cost q(m) time.
It follows that the time complexity of the algorithm is
Ø(m + n2) = Ø (n2)
51