function varargout = untitled(varargin)
% UNTITLED MATLAB code for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_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 untitled
% Last Modified by GUIDE v2.5 04-Mar-2020 10:53:52
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Way=str2double(get(handles.uitable1,'data'));
h=size(Way,1); %矩阵Way1 行数
l=size(Way,2);% 矩阵Way1 列数
data(1,1:l)=inf;
%%贝尔曼-福特算法是针对边的算法,而迪杰斯特拉算法是针对点的算法
%%举个明显的列子:
% 迪杰斯塔拉:假设从a到b的距离10,那么从b出发到a的距离也是10
% 贝尔曼-福特:假设从a到b的距离10,即a->b的边是10。但从b到a不一定是10
for i=2:1:l % 以a号点为节点的路径Way(1,:)不会得到更新 所以i从b开始
for j=1:1:l %以i为中间节点,对a号到所有顶点的路径进行逐步更新
if Way(1,j)>Way(1,i)+Way(i,j)
Way(1,j)=Way(1,i)+Way(i,j);
end
end
Data1=[data;Way(1,:)];
set(handles.uitable2,'data',Data1);
data = get(handles.uitable2,'Data'); %%读取表格中现有数据
end
% --- Executes on key press with focus on uitable1 and none of its controls.
function uitable1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
基于MATLAB的贝尔曼-福特算法.zip
5星 · 超过95%的资源 需积分: 50 21 浏览量
2020-03-04
14:33:37
上传
评论 4
收藏 15KB ZIP 举报
BaiLuQingFeng
- 粉丝: 2
- 资源: 5
最新资源
- RISC-V CPU 仿真器
- Macast投屏软件源码包Macast-src-v0.7.zip
- (自适应手机端)响应式中英文双语灯饰灯具外贸网站pbootcms模板 LED照明灯具网站源码下载.zip
- wang-et-al-2022-sr-based-sub-surface-integrated-layer-and-bulk-doping-to-enhance-high-voltage-cycling-of-a-ni-rich.pdf
- uwb距离定位方式求解车辆位置
- 蓝桥杯官网VIP试题-历届真题-模拟赛代码Python实现与讲解.rar
- 74CH190加减30+5+20交通灯
- 在只有usb数据线连接打印机的情况下,实现后台程序调用不同pc设备上的打印机实现实时打印! 打印机型号:zebra GT820
- 华为od三道机试题.pdf
- 79239254_g.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈