3.16667

3.2 | 6 ratings Rate this file 50 downloads (last 30 days) File Size: 3.11 KB File ID: #13457

Kruskal Algorithm

by Nickolas Cheilakos

 

20 Dec 2006

Code covered by BSD License  

Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connect

Download Now | Watch this File

File Information
Description

Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected un directed weighted graph

The zip file contains

kruskal.m iscycle.m fysalida.m connected.m

If we want to find the minimum spanning tree. We call function kruskal.

% Input: PV = nx3 martix. 1st and 2nd row's define the edge (2 vertices) and
% the 3rd is the edge's weight
% Output: w = Minimum spanning tree's weight
% T = Minimum spanning tree's adjacency matrix

example :

>>PV = PV = [ 1 2 5;1 3 8;1 5 10;2 3 10;3 4 4;3 5 7;4 5 6];

>>[w T] = kruskal(PV)

w =

    23

T =

     0 1 1 0 0
     1 0 0 0 0
     1 0 0 1 0
     0 0 1 0 1
     0 0 0 1 0

MATLAB release MATLAB 6.5 (R13)
Zip File Content  
Other Files MST_Kruskal/connected.m,
MST_Kruskal/fysalida.m,
MST_Kruskal/iscycle.m,
MST_Kruskal/kruskal.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
21 Dec 2006 Nick Cheilakos

I promise to update soon the documentation. But now I have a problem and I can't

29 Jan 2007 Anima Kumar

Simple and easy to use !

08 Feb 2007 John Litmaier

not simply to use, a real mess! :)

18 Feb 2007 Greg Mardis  
25 Apr 2007 Guillaume Bouchard

I compared this code to the PRIM algortihm
on a dense adjacency matrix of size (100x100):
0.0578 seconds for PRIM algorithm
64.9045 seconds for Kruskal method
This is a huge difference!
Theoretically, the two algorithms have a similar complexity, so I think this code should be improved.

29 Sep 2007 Jonathan Primof  
11 May 2008 kadri mourad  
31 May 2008 Lai Wei

 I think the code is not correct. If we get w=[0 1 0 0;1 0 1 0;0 1 0 0;0 1 0 0], the connected will also be 1.

15 Oct 2008 kheroua mohalled reda

je voudrais savoir

15 Oct 2008 kheroua mohammed reda

a kadri mourad...es-tu celui que je connais le prof. de geologie a l'ecole des mines de paris...si oui j'aimerais renrer en contact...!

23 Dec 2008 Billal merabti

the code of 'connected' function is not correct. if you want to use this code you have to correct it (it is simple to do). but i think that the code is verry simple to understand and to use.
an other think, we can use the matlab function max(PV,3)' in the place of "fysalida.m"
thanks

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
specialized Nickolas Cheilakos 22 Oct 2008 08:53:25
plotting Nickolas Cheilakos 22 Oct 2008 08:53:25
kruskal Nickolas Cheilakos 22 Oct 2008 08:53:25
minimum spanning tree Nickolas Cheilakos 22 Oct 2008 08:53:25
algorithm Nickolas Cheilakos 22 Oct 2008 08:53:25
specialized plot Nickolas Cheilakos 22 Oct 2008 08:53:25
graphics Nickolas Cheilakos 22 Oct 2008 08:53:25
i want to signal a msitake in the function connected Billal merabti 23 Dec 2008 05:09:12
like this it cant work all the times Billal merabti 23 Dec 2008 05:09:12
graphics Morvan 03 Apr 2009 02:50:38
i want to signal a msitake in the function connected Koray K 17 May 2009 07:50:29
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com