Minimum Spanning Tree
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 (2023). Minimum Spanning Tree (https://www.mathworks.com/matlabcentral/fileexchange/70454-minimum-spanning-tree), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |