资源简介
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 (
评论
共有 条评论