資源簡介
Matlab繪制鄰接矩陣 Floyd算法的基本思想如下:從任意節點A到任意節點B的最短路徑不外乎2種可能,1是直接從A到B,2是從A經過若干個節點X到B。所以,我們假設Dis(AB)為節點A到節點B的最短路徑的距離,對于每一個節點X,我們檢查Dis(AX) + Dis(XB) < Dis(AB)是否成立,如果成立,證明從A到X再到B的路徑比A直接到B的路徑短,我們便設置Dis(AB) = Dis(AX) + Dis(XB),這樣一來,當我們遍歷完所有節點X,Dis(AB)中記錄的便是A到B的最短路徑的距離。
代碼片段和文件信息
function?varargout?=?plotdcm(varargin)
%?PLOTDCM?MATLAB?code?for?plotdcm.fig
%??????PLOTDCM?by?itself?creates?a?new?PLOTDCM?or?raises?the?existing
%??????singleton*.
%
%??????H?=?PLOTDCM?returns?the?handle?to?a?new?PLOTDCM?or?the?handle?to
%??????the?existing?singleton*.
%
%??????PLOTDCM(‘CALLBACK‘hobjecteventDatahandles...)?calls?the?local
%??????function?named?CALLBACK?in?PLOTDCM.M?with?the?given?input?arguments.
%
%??????PLOTDCM(‘Property‘‘Value‘...)?creates?a?new?PLOTDCM?or?raises?the
%??????existing?singleton*.??Starting?from?the?left?property?value?pairs?are
%??????applied?to?the?GUI?before?plotdcm_OpeningFcn?gets?called.??An
%??????unrecognized?property?name?or?invalid?value?makes?property?application
%??????stop.??All?inputs?are?passed?to?plotdcm_OpeningFcn?via?varargin.
%
%??????*See?GUI?Options?on?GUIDE‘s?Tools?menu.??Choose?“GUI?allows?only?one
%??????instance?to?run?(singleton)“.
%
%?See?also:?GUIDE?GUIDATA?GUIHANDLES
%?Edit?the?above?text?to?modify?the?response?to?help?plotdcm
%?Last?Modified?by?GUIDE?v2.5?24-Jan-2013?16:28:03
%?Begin?initialization?code?-?DO?NOT?EDIT
gui_Singleton?=?1;
gui_State?=?struct(‘gui_Name‘???????mfilename?...
???????????????????‘gui_Singleton‘??gui_Singleton?...
???????????????????‘gui_OpeningFcn‘?@plotdcm_OpeningFcn?...
???????????????????‘gui_OutputFcn‘??@plotdcm_OutputFcn?...
???????????????????‘gui_LayoutFcn‘??[]??...
???????????????????‘gui_Callback‘???[]);
if?nargin?&&?ischar(varargin{1})
????gui_State.gui_Callback?=?str2func(varargin{1});
end
if?nargout
????[varargout{1:nargout}]?=?gui_mainfcn(gui_State?varargin{:});
else
????gui_mainfcn(gui_State?varargin{:});
end
%?End?initialization?code?-?DO?NOT?EDIT
%?---?Executes?just?before?plotdcm?is?made?visible.
function?plotdcm_OpeningFcn(hobject?eventdata?handles?varargin)
%?This?function?has?no?output?args?see?OutputFcn.
%?hobject????handle?to?figure
%?eventdata??reserved?-?to?be?defined?in?a?future?version?of?MATLAB
%?handles????structure?with?handles?and?user?data?(see?GUIDATA)
%?varargin???command?line?arguments?to?plotdcm?(see?VARARGIN)
%?Choose?default?command?line?output?for?plotdcm
handles.output?=?hobject;
%?Update?handles?structure
guidata(hobject?handles);
%?UIWAIT?makes?plotdcm?wait?for?user?response?(see?UIRESUME)
%?uiwait(handles.figure1);
%?---?Outputs?from?this?function?are?returned?to?the?command?line.
function?varargout?=?plotdcm_OutputFcn(hobject?eventdata?handles)?
%?varargout??cell?array?for?returning?output?args?(
評論
共有 條評論