Question
Introduction to the Prim Algorithm for MST (1) The definition of Minimum spanning trees (MST): G = (V, E) is a weighted connected undirected graph;
- Introduction to the Prim Algorithm for MST
(1) The definition of Minimum spanning trees (MST):
- G = (V, E) is a weighted connected undirected graph;
- Spanning tree is S = (V, T), T E, undirected tree;
- Minimum spanning tree (MST) is a spanning tree with the smallest total weight.
(2) The Prim Algorithm for finding MST:
Step 1: x V, Let A = {x}, B = V - {x}.
Step 2: Select (u, v) E, u A, v B such that (u, v) has the smallest weight between A and B.
Step 3: Put (u, v) in the tree. A = A {v}, B = B - {v}
Step 4: If B = , stop; otherwise, go to Step 2.
2. Experimental Purpose
(1)Understand what is the Minimum spanning trees (MST);
(2)Learn what kinds of algorithms can be used to find MST, such as: Kruskal and Prim algorithms;
(3)Compare the difference between these two algorithms;
3. Experimental Contents
(1) Given a undirected Graph G=(V, E) like below, to calculate the minimum spanning tree using Kruskals algorithm and Prims algorithm.
4. Experimental Requirement
- The template should be used for all kinds of data type, such as: integer, real, double, etc. in the program;
- Programs should be made by Object-Oriented Programming (OOP) method;
- Use using Kruskals algorithm and Prims algorithm to solve this problem.
- And compare the results between these two algorithms and the difference of selection processes.
- Write down the report in which there should be the execution results of the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started