- 2
- 0
- 约16.32万字
- 约 28页
- 2016-09-13 发布于河南
- 举报
dijk
dijkDijkstra算法 开放分类: 算法、单源最短路径关于 Dijkstra算法解决voronoi图的问题macrolian 发表于: 2008-5-03 19:36 来源: Matlab中文学习站 我想用 Dijkstra算法解决voronoi图中求解最短路径的时候,有一个dijkstra.m的文件代码如下:function [dist,path] = dijkstra(nodes,segments,start_id,finish_id)%DIJKSTRA Calculates the shortest distance and path between points on a map% using Dijkstras Shortest Path Algorithm% % [DIST, PATH] = DIJKSTRA(NODES, SEGMENTS, SID, FID)% Calculates the shortest distance and path between start and finish nodes SID and FID% % [DIST, PATH] = DIJKSTRA(NODES, SEGMENTS, SID)% Calculates the shortest distances and paths from the starting node SID to all% other nodes in the map% % Note:% DIJKSTRA is set up so that an example is created if no inputs are provided,% but ignores the example and just processes the inputs if they are given.% % Inputs:% NODES should be an Nx3 or Nx4 matrix with the format [ID X Y] or [ID X Y Z]% where ID is an integer, and X, Y, Z are cartesian position coordinates)% SEGMENTS should be an Mx3 matrix with the format [ID N1 N2]% where ID is an integer, and N1, N2 correspond to node IDs from NODES list% such that there is an [undirected] edge/segment between node N1 and node N2% SID should be an integer in the node ID list corresponding with the starting node% FID (optional) should be an integer in the node ID list corresponding with the finish% % Outputs:% DIST is the shortest Euclidean distance% If FID was specified, DIST will be a 1x1 double representing the shortest% Euclidean distance between SID and FID along the map segments. DIST will have% a value of INF if there are no segments connecting SID and FID.% If FID was not specified, DIST will be a 1xN vector representing the shortest% Euclidean distance between SID and all other nodes on the map. DIST will have% a value of INF for any nodes that cannot be reached along segments of the map.% PATH is a list of nodes containing the shorte
原创力文档

文档评论(0)