-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathkruskal_mst.m
36 lines (30 loc) · 861 Bytes
/
kruskal_mst.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [varargout] = kruskal_mst(A,varargin)
% KRUSKAL_MST Compute a minimum spanning with Kruskal's algorithm.
%
% The Kruskal MST algorithm computes a minimum spanning tree for a graph.
%
% This method works on weighted symmetric graphs.
% The runtime is O(E log (E)).
%
% See the mst function for calling information. This function just calls
% mst(...,struct('algname','kruskal'));
%
% Example:
% load graphs/clr-24-1.mat
% kruskal_mst(A)
%
% See also MST, PRIM_MST.
% David Gleich
% Copyright, Stanford University, 2006-2008
%% History
% 2006-04-23: Initial version
% 2008-09-24: Code cleanup
%%
algname = 'kruskal';
if ~isempty(varargin),
options = merge_options(struct(),varargin{:});
options.algname= algname;
else options = struct('algname',algname);
end
varargout = cell(1,max(nargout,1));
[varargout{:}] = mst(A,options);