35
35
% See also JOHNSON_ALL_SP, FLOYD_WARSHALL_ALL_SP.
42
% Added full2sparse check
45
% Added option for predecessor matrix from floyd_warshall
48
% Added edge weight option
51
% Fixed typos in strings and documentation
52
% Removed fixes for the Johnson algorithm
55
% Fixed edge_weight documentation.
58
% Fixed divide by 0 error in check for algorithm type
60
% 2008-04-02: Added documenation for predecessor matrix
38
% Copyright, Stanford University, 2006-2008
41
% 2006-04-19: Initial version
42
% 2006-05-31: Added full2sparse check
43
% 2007-03-01: Added option for predecessor matrix from floyd_warshall
44
% 2007-04-20: Added edge weight option
45
% 2007-07-08: Fixed typos in strings and documentation
46
% Removed fixes for the Johnson algorithm
47
% 2007-07-12: Fixed edge_weight documentation.
48
% 2007-07-21: Fixed divide by 0 error in check for algorithm type
49
% 2008-04-02: Added documenation for predecessor matrix
63
52
[trans check full2sparse] = get_matlab_bgl_options(varargin{:});
64
if (full2sparse && ~issparse(A))
53
if full2sparse && ~issparse(A), A = sparse(A); end
68
55
options = struct('algname', 'auto', 'inf', Inf, 'edge_weight', 'matrix');
69
if (~isempty(varargin))
70
options = merge_structs(varargin{1}, options);
56
if ~isempty(varargin), options = merge_structs(varargin{1}, options); end
73
58
% edge_weights is an indicator that is 1 if we are using edge_weights
74
59
% passed on the command line or 0 if we are using the matrix.
81
66
edge_weight_opt = options.edge_weight;
85
70
% check the values of the matrix
86
71
check_matlab_bgl(A,struct('values',1));
89
if (strcmpi(options.algname, 'auto'))
74
if strcmpi(options.algname, 'auto')
91
76
if (nz/(numel(A)+1) > .1)
92
77
options.algname = 'floyd_warshall';
98
if (strcmpi(options.algname, 'auto'))
83
if strcmpi(options.algname, 'auto')
99
84
error('all_shortest_paths:invalidParameter', ...
100
85
'algname auto is not compatible with no check');
109
92
[D,P] = matlab_bgl_all_sp_mex(A,lower(options.algname),options.inf,edge_weight_opt);