Minimum Spanning Tree

Implementation of Prim algorithm to solve Minimum Spanning Tree (MST)
313 Downloads
Updated 3 Mar 2019

View License

The input Matrix is edge-weighted matirx with not connected edge assigned as 0
>>A =
[0 192 344 0 0 0 0 0 0 0 0;
192 0 309 0 555 0 0 0 0 0 0;
344 309 0 499 0 0 0 0 0 0 0;
0 0 499 0 840 0 229 286 0 0 0;
0 555 0 840 0 237 0 0 0 0 0;
0 0 0 0 237 0 729 0 0 793 0;
0 0 0 229 0 729 0 383 0 0 0;
0 0 0 286 0 0 383 0 929 0 0;
0 0 0 0 0 0 0 929 0 934 581;
0 0 0 0 0 793 0 0 934 0 633;
0 0 0 0 0 0 0 0 581 633 0;]
>>route=prims(A,1)
1 2 192
2 3 309
3 4 499
4 7 229
4 8 286
2 5 555
5 6 237
6 10 793
10 11 633
11 9 581

Cite As

Ashim Gautam (2024). Minimum Spanning Tree (https://www.mathworks.com/matlabcentral/fileexchange/70454-minimum-spanning-tree), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Biological and Health Sciences in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0