⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bellman_ford_sp.m

📁 The MatlabBGL library fills a hole in Matlab s suite of algorithms. Namely, it provides a rich set o
💻 M
字号:
function [d pred] = bellman_ford_sp(A,u,varargin)
% BELLMAN_FORD_SP Compute the weighted single source shortest path problem.
%
% The Bellman-Ford algorithm for the single source shortest path problem
% works on graphs with negative edge weights.  
%
% See the shortest_paths function for calling information.  This function 
% just calls shortest_paths(...,struct('algname','bellman_ford'));
%
% This method works on weighted directed graphs with negative edge weights.
% The runtime is O(VE).
%
% The options structure can contain a visitor for the Bellman-Ford 
% algorithm.  
%
% See http://www.boost.org/libs/graph/doc/BellmanFordVisitor.html for a 
% description of the events.
% 
% visitor is a struct with the following optional fields
%    vis.initialize_vertex(u)
%    vis.examine_edge(ei,u,v)
%    vis.edge_relaxed(ei,u,v)
%    vis.edge_not_relaxed(ei,u,v)
%    vis.edge_minimized(ei,u,v)
%    vis.edge_not_minimized(ei,u,v)
% Each visitor parameter should be a function pointer, which returns 0
% if the shortest path search should stop.  (If the function does not 
% return anything, the algorithm continues.)
%
% Example:
%    load graphs/kt-6-23.mat
%    d = bellman_ford_sp(A,1);
%
% See also SHORTEST_PATHS, DIJKSTRA_SP.

%
% David Gleich
% 23 April 2006
%

algname = 'bellman_ford';

if (nargin > 2)
    options = varargin{1};
    options.algname = algname;
else
    options = struct('algname',algname);
end;

[d pred] = shortest_paths(A,u,options);




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -