亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dijkstra.m

?? 沿著圖的邊計算代價最小的路徑
?? M
字號:
function [costs,paths] = dijkstra(AorV,xyCorE,SID,FID)
%DIJKSTRA Calculate Minimum Costs and Paths using Dijkstra's Algorithm
%
%   Inputs:
%     [AorV] Either A or V where
%         A   is a NxN adjacency matrix, where A(I,J) is nonzero
%               if and only if an edge connects point I to point J
%               NOTE: Works for both symmetric and asymmetric A
%         V   is a Nx2 (or Nx3) matrix of x,y,(z) coordinates
%     [xyCorE] Either xy or C or E (or E3) where
%         xy  is a Nx2 (or Nx3) matrix of x,y,(z) coordinates (equivalent to V)
%               NOTE: only valid with A as the first input
%         C   is a NxN cost (perhaps distance) matrix, where C(I,J) contains
%               the value of the cost to move from point I to point J
%               NOTE: only valid with A as the first input
%         E   is a Px2 matrix containing a list of edge connections
%               NOTE: only valid with V as the first input
%         E3  is a Px3 matrix containing a list of edge connections in the
%               first two columns and edge weights in the third column
%               NOTE: only valid with V as the first input
%     [SID] (optional) 1xL vector of starting points
%         if unspecified, the algorithm will calculate the minimal path from
%         all N points to the finish point(s) (automatically sets SID = 1:N)
%     [FID] (optional) 1xM vector of finish points
%         if unspecified, the algorithm will calculate the minimal path from
%         the starting point(s) to all N points (automatically sets FID = 1:N)
%
%   Outputs:
%     [costs] is an LxM matrix of minimum cost values for the minimal paths
%     [paths] is an LxM cell containing the shortest path arrays
%
%   Note:
%     If the inputs are [A,xy] or [V,E], the cost is assumed to be (and is
%       calculated as) the point to point Euclidean distance
%     If the inputs are [A,C] or [V,E3], the cost is obtained from either
%       the C matrix or from the edge weights in the 3rd column of E3
%
%   Example:
%       % Calculate the (all pairs) shortest distances and paths using [A,xy] inputs
%       n = 7; A = zeros(n); xy = 10*rand(n,2)
%       tri = delaunay(xy(:,1),xy(:,2));
%       I = tri(:); J = tri(:,[2 3 1]); J = J(:);
%       IJ = I + n*(J-1); A(IJ) = 1
%       [costs,paths] = dijkstra(A,xy)
%
%   Example:
%       % Calculate the (all pairs) shortest distances and paths using [A,C] inputs
%       n = 7; A = zeros(n); xy = 10*rand(n,2)
%       tri = delaunay(xy(:,1),xy(:,2));
%       I = tri(:); J = tri(:,[2 3 1]); J = J(:);
%       IJ = I + n*(J-1); A(IJ) = 1
%       a = (1:n); b = a(ones(n,1),:);
%       C = round(reshape(sqrt(sum((xy(b,:) - xy(b',:)).^2,2)),n,n))
%       [costs,paths] = dijkstra(A,C)
%
%   Example:
%       % Calculate the (all pairs) shortest distances and paths using [V,E] inputs
%       n = 7; V = 10*rand(n,2)
%       I = delaunay(V(:,1),V(:,2));
%       J = I(:,[2 3 1]); E = [I(:) J(:)]
%       [costs,paths] = dijkstra(V,E)
%
%   Example:
%       % Calculate the (all pairs) shortest distances and paths using [V,E3] inputs
%       n = 7; V = 10*rand(n,2)
%       I = delaunay(V(:,1),V(:,2));
%       J = I(:,[2 3 1]);
%       D = sqrt(sum((V(I(:),:) - V(J(:),:)).^2,2));
%       E3 = [I(:) J(:) D]
%       [costs,paths] = dijkstra(V,E3)
%
%   Example:
%       % Calculate the shortest distances and paths from the 3rd point to all the rest
%       n = 7; V = 10*rand(n,2)
%       I = delaunay(V(:,1),V(:,2));
%       J = I(:,[2 3 1]); E = [I(:) J(:)]
%       [costs,paths] = dijkstra(V,E,3)
%
%   Example:
%       % Calculate the shortest distances and paths from all points to the 2nd
%       n = 7; A = zeros(n); xy = 10*rand(n,2)
%       tri = delaunay(xy(:,1),xy(:,2));
%       I = tri(:); J = tri(:,[2 3 1]); J = J(:);
%       IJ = I + n*(J-1); A(IJ) = 1
%       [costs,paths] = dijkstra(A,xy,1:n,3)
%
%   Example:
%       % Calculate the shortest distance and path from points [1 3 4] to [2 3 5 7]
%       n = 7; V = 10*rand(n,2)
%       I = delaunay(V(:,1),V(:,2));
%       J = I(:,[2 3 1]); E = [I(:) J(:)]
%       [costs,paths] = dijkstra(V,E,[1 3 4],[2 3 5 7])
%
%   Example:
%       % Calculate the shortest distance and path from point 3 to 5
%       n = 15; A = zeros(n); xy = 10*rand(n,2)
%       tri = delaunay(xy(:,1),xy(:,2));
%       I = tri(:); J = tri(:,[2 3 1]); J = J(:);
%       IJ = I + n*(J-1); A(IJ) = 1
%       [cost,path] = dijkstra(A,xy,3,5)
%       gplot(A,xy,'b.:'); hold on;
%       plot(xy(path,1),xy(path,2),'ro-','LineWidth',2)
%       for k = 1:n, text(xy(k,1),xy(k,2),['  ' num2str(k)],'Color','k'); end
%
% Web Resources:
%   <a href="http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">Dijkstra's Algorithm</a>
%   <a href="http://en.wikipedia.org/wiki/Graph_%28mathematics%29">Graphs</a>
%   <a href="http://en.wikipedia.org/wiki/Adjacency_matrix">Adjacency Matrix</a>
%
% See also: gplot, gplotd, gplotdc, distmat, ve2axy, axy2ve
%
% Author: Joseph Kirk
% Email: jdkirk630@gmail.com
% Release: 1.0
% Release Date: 5/22/08

% Process Inputs
error(nargchk(2,4,nargin));
[n,nc] = size(AorV);
[m,mc] = size(xyCorE);
[E,cost] = processInputs(AorV,xyCorE);
if nargin < 4
    FID = (1:n);
end
if nargin < 3
    SID = (1:n);
end
if max(SID) > n || min(SID) < 1
    eval(['help ' mfilename]);
    error('Invalid [SID] input. See help notes above.');
end
if max(FID) > n || min(FID) < 1
    eval(['help ' mfilename]);
    error('Invalid [FID] input. See help notes above.');
end

isreversed = 0;
if length(FID) < length(SID)
    E = E(:,[2 1]);
    cost = cost';
    tmp = SID;
    SID = FID;
    FID = tmp;
    isreversed = 1;
end

L = length(SID);
M = length(FID);
costs = zeros(L,M);
paths = num2cell(nan(L,M));
% Find the Minimum Costs and Paths using Dijkstra's Algorithm
for k = 1:L
    % (Re)Set Initializations
    TBL = sparse(1,n);
    min_cost = Inf(1,n);
    settled = zeros(1,n);
    path = num2cell(nan(1,n));
    I = SID(k);
    min_cost(I) = 0;
    TBL(I,2) = 0;
    settled(I) = 1;
    path(I) = {I};

    while any(~settled(FID))
        % Update the Table
        TAB = TBL;
        TBL(I) = 0;
        % nids = find(A(I,:));
        nids = find(E(:,1) == I);
        % Calculate the Costs to the Neighbor Points and Record Paths
        for kk = 1:length(nids)
            % J = nids(kk);
            J = E(nids(kk),2);
            if ~settled(J)
                c = cost(I,J);
                if ~TAB(J) || (TAB(J) > (TAB(I) + c))
                    TBL(J) = TAB(I) + c;
                    if isreversed
                        path{J} = [J path{I}];
                    else
                        path{J} = [path{I} J];
                    end
                else
                    TBL(J) = TAB(J);
                end
            end
        end
        % Find the Minimum Non-zero Value in the Table
        K = find(TBL);
        N = find(TBL(K) == min(TBL(K)));
        if isempty(N)
            break
        else
            % Settle the Minimum Value
            I = K(N(1));
            min_cost(I) = TBL(I);
            settled(I) = 1;
        end
    end
    % Store Costs and Paths
    costs(k,:) = min_cost(FID);
    paths(k,:) = path(FID);
end

if isreversed
    costs = costs';
    paths = paths';
end

if L == 1 && M == 1
    paths = paths{1};
end

% -------------------------------------------------------------------
    function [E,C] = processInputs(AorV,xyCorE)
        C = sparse(n,n);
        if n == nc
            if m == n
                if m == mc
                    % Inputs: A,cost
                    A = AorV;
                    C = xyCorE;
                    E = a2e(A);
                else
                    % Inputs: A,xy
                    A = AorV;
                    xy = xyCorE;
                    E = a2e(A);
                    D = ve2d(xy,E);
                    for row = 1:length(D)
                        C(E(row,1),E(row,2)) = D(row);
                    end
                end
            else
                eval(['help ' mfilename]);
                error('Invalid [A,xy] or [A,cost] inputs. See help notes above.');
            end
        else
            if mc == 2
                % Inputs: V,E
                V = AorV;
                E = xyCorE;
                D = ve2d(V,E);
                for row = 1:m
                    C(E(row,1),E(row,2)) = D(row);
                end
            elseif mc == 3
                % Inputs: V,E3
                E3 = xyCorE;
                E = E3(:,1:2);
                for row = 1:m
                    C(E3(row,1),E3(row,2)) = E3(row,3);
                end
            else
                eval(['help ' mfilename]);
                error('Invalid [V,E] inputs. See help notes above.');
            end
        end
    end

    function E = a2e(A)
        % Convert Adjacency Matrix to Edge List
        [I,J] = find(A);
        E = [I J];
    end

    function D = ve2d(V,E)
        % Compute Euclidean Distance for Edges
        VI = V(E(:,1),:);
        VJ = V(E(:,2),:);
        D = sqrt(sum((VI - VJ).^2,2));
    end
end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩不卡免费| 蜜桃视频一区二区三区| 日韩综合小视频| 风间由美一区二区av101| 777午夜精品免费视频| 亚洲视频一区二区在线| 黄色资源网久久资源365| 欧美视频三区在线播放| 中文字幕一区二区三区四区| 精品亚洲aⅴ乱码一区二区三区| 亚洲成人1区2区| av综合在线播放| 久久亚洲二区三区| 毛片av中文字幕一区二区| 欧美性色黄大片手机版| 亚洲免费看黄网站| 成人久久18免费网站麻豆| 久久久亚洲高清| 蜜臀久久99精品久久久久久9 | 国产在线麻豆精品观看| 91美女福利视频| 综合av第一页| 国产精品综合二区| 精品免费99久久| 亚洲图片欧美视频| 色偷偷一区二区三区| 久久久久国产精品人| 极品销魂美女一区二区三区| 欧美在线视频全部完| 亚洲视频在线一区观看| 粉嫩绯色av一区二区在线观看| 美国三级日本三级久久99| 日韩欧美三级在线| 午夜精品福利视频网站| 欧美亚洲国产一区二区三区va| 精品国产91洋老外米糕| 国产成人av福利| 欧美高清激情brazzers| 亚洲另类中文字| 欧美视频一区二区三区四区| 亚洲日本va在线观看| 欧洲精品一区二区| 一区二区三区视频在线看| 91久久精品午夜一区二区| 国产精品美日韩| 91欧美一区二区| 中文字幕中文字幕一区| 久久电影网电视剧免费观看| 久久亚洲影视婷婷| 国产精品资源站在线| 国产精品丝袜在线| 成人精品视频一区二区三区| 亚洲欧美激情插 | 亚洲另类色综合网站| av动漫一区二区| 亚洲天堂2016| 在线这里只有精品| 日韩成人一级大片| 欧美精品一区二| 成人av电影在线| 亚洲精品大片www| 9久草视频在线视频精品| 亚洲图片自拍偷拍| 3d成人动漫网站| 成人av免费在线观看| 亚洲欧美色图小说| 日韩欧美一区二区免费| 国模无码大尺度一区二区三区| 欧美激情在线一区二区| 成人a区在线观看| 日韩电影在线一区二区| 2021中文字幕一区亚洲| 色悠久久久久综合欧美99| 亚洲愉拍自拍另类高清精品| 欧美午夜电影网| 成人理论电影网| 亚洲电影在线免费观看| 国产精品女同一区二区三区| 一本大道久久精品懂色aⅴ| 麻豆精品蜜桃视频网站| 国产精品美女视频| 欧美一级高清大全免费观看| 国产乱码精品一区二区三| 一区二区高清免费观看影视大全 | 一区二区三区日韩欧美精品| 欧美精品久久99| 国产精品资源网站| 日韩综合在线视频| 国产精品久久久久久久久免费丝袜 | 最新久久zyz资源站| 欧美一级欧美三级在线观看 | 亚洲乱码日产精品bd | 麻豆国产精品官网| 国产精品高潮呻吟| 2024国产精品| 欧美日韩一级黄| 成人影视亚洲图片在线| 日韩精品福利网| 国产女人18毛片水真多成人如厕| 91激情在线视频| 国产一区福利在线| 奇米色777欧美一区二区| 亚洲视频一区二区在线观看| 中文字幕欧美日本乱码一线二线| 在线观看日韩高清av| 97精品视频在线观看自产线路二| 亚洲一区自拍偷拍| 亚洲一二三区在线观看| 中文字幕av一区二区三区高 | 中文字幕在线不卡国产视频| 久久久久88色偷偷免费| 欧美日韩另类一区| 一本到高清视频免费精品| 成人av资源网站| 亚洲天堂精品在线观看| 亚洲欧美经典视频| 亚洲国产成人在线| 国产精品国产成人国产三级| 国产三级一区二区| 亚洲欧美怡红院| 欧美国产日韩a欧美在线观看| 精品久久久网站| 日韩欧美一区在线| 精品美女被调教视频大全网站| 一本久久a久久精品亚洲| 欧美色国产精品| 一本大道综合伊人精品热热| 欧美三级视频在线播放| 在线观看亚洲精品视频| 欧美性xxxxxxxx| 欧美三区在线视频| 欧美zozozo| 精品国产一区a| 亚洲国产精品激情在线观看| 久久久www免费人成精品| 国产精品人人做人人爽人人添| 日韩视频在线观看一区二区| 国产午夜精品久久久久久免费视| 日韩免费观看高清完整版在线观看 | 成人h精品动漫一区二区三区| 国产在线麻豆精品观看| 丁香婷婷综合五月| www.爱久久.com| 99在线视频精品| 91亚洲精品一区二区乱码| 色婷婷综合视频在线观看| 91久久精品一区二区三| 成人激情免费网站| 欧美性videosxxxxx| 日韩精品一区二| 亚洲另类中文字| 日日夜夜精品视频天天综合网| 精品在线观看视频| 国产精品99久久久久久有的能看| 不卡视频一二三四| 色狠狠一区二区三区香蕉| 日韩欧美国产一区二区三区| 久久久久久日产精品| 亚洲一区二区四区蜜桃| 三级在线观看一区二区| 岛国精品一区二区| 91成人网在线| 国产精品免费视频网站| 亚洲主播在线播放| 成人免费高清视频| 欧美揉bbbbb揉bbbbb| 国产精品无人区| 亚洲高清视频中文字幕| 成人开心网精品视频| 欧美日韩高清一区二区不卡 | 69堂亚洲精品首页| 国产日韩精品一区| 国产精品电影一区二区| 亚洲国产一区视频| www.久久精品| 日韩一区二区三区观看| 午夜视频一区在线观看| 国产精品一二三四区| 日韩欧美国产一区在线观看| 最新久久zyz资源站| 不卡在线视频中文字幕| 欧美一级黄色大片| 午夜天堂影视香蕉久久| 风间由美一区二区av101| 国产亚洲精品福利| 亚洲成av人影院| 欧美在线高清视频| 国产日产欧美一区| 成人小视频在线观看| 欧美性xxxxx极品少妇| 亚洲精品免费电影| 99精品欧美一区二区三区综合在线| 91精品啪在线观看国产60岁| 国产精品麻豆久久久| 精品制服美女久久| 精品国产一区a| 蜜臀av性久久久久蜜臀av麻豆| 欧美色视频一区| 亚洲男女毛片无遮挡| 欧美色视频一区|