91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

matlab程序,找出網絡中確定兩點間的所有最短路徑。 注意:輸入的矩陣為鄰接矩陣。如果兩點間沒有相鄰,請將參數設較大數,例如點i和點j間沒有相鄰,則將Aij設為999。

資源截圖

代碼片段和文件信息

function?[sp?spcost]?=?dijkstraties(matriz_costo?s?d)
%
%?This?function?is?built?on?the?dijkstra.m?function?written?by?Jorge
%?Ignacia?Barrera?Alviar?(April?2008)?available?at
%?http://www.mathworks.com/matlabcentral/fileexchange?under?file?ID?5550.
%?Modification?records?all?ties?for?shortest?path.
%
%?The?inputs?are?the?same?is?with?the?original?code.?Because?the?original
%?documentation?is?not?clear?with?respect?to?the?array?matriz_costo?
%?matriz_costo?is?an?n?x?n?adjacency?matrix?where?the?(ij)?element
%?represents?the?cost?of?traveling?along?the?edge?linking?node?i?to?node?j.?
%?One?should?not?set?any?elements?to?0?(unless?your?intention?is?that?there?
%?is?no?cost?to?travel?along?the?corresponding?edge).?Typically?I?choose?
%?some?arbitrarily?large?number?for?all?elements?representing?non-edges.
%
%?I?have?also?been?trying?unsuccessfully?so?modify?the?code?so?that
%?instead?of?adding?the?costs?of?each?edge?to?compute?total?path?costs
%?the?cost?of?traveling?along?edges?e1?and?2?is?equal?to?1?-?(1-coste1)(1-coste2).
%?This?formulation?is?useful?if?the?costs?represent?hazard?rates?and?the
%?goal?is?find?the?path?that?minimizes?the?probability?of?loss?from?node?s
%?to?node?d?(or?maximizes?the?probability?of?survival).
%
%?My?attempt?to?modify?the?code?in?the?latter?manner?is?commented?out.
%?Code?to?be?removed?is?commented?“Switch?#?(add)“?and?code?to?substituted
%?in?its?place?is?labeled?“Switch?#?(mult)“.?If?one?were?to?output?the?the?
%?prev?array?one?would?see?that?it?isn‘t
%?generated?properly?which?the?code?switch?is?performed.?However?the?dist
%?vector?does?appear?to?be?generated?correctly.
%
%?Any?help?in?getting?the?code?to?work?properly?while?computing?costs
%?as?1?minus?the?product?of?survival?probabilities??would?be?greatly?
%?appreciated.
%
%?-David?Blum
%??dmblum@gmail.com
%
%
%
%%%%%%%%%%?Original?documentation?%%%%%%%%%%%%%%%%%%
%
%?This?is?an?implementation?of?the?dijkstra磗?algorithm?wich?finds?the?
%?minimal?cost?path?between?two?nodes.?It磗?supoussed?to?solve?the?problem?on?
%?possitive?weighted?instances.

%?the?inputs?of?the?algorithm?are:
%farthestNode:?the?farthest?node?to?reach?for?each?node?after?performing
%?the?routing;
%?n:?the?number?of?nodes?in?the?network;
%?s:?source?node?index;
%?d:?destination?node?index;

%For?information?about?this?algorithm?visit:
%http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

%This?implementatios?is?inspired?by?the?Xiaodong?Wang‘s?implememtation?of
%the?dijkstra‘s?algorithm?available?at
%http://www.mathworks.com/matlabcentral/fileexchange
%file?ID?5550

%Author:?Jorge?Ignacio?Barrera?Alviar.?April/2007


n=size(matriz_costo1);
S(1:n)?=?0;?????%s?vector?set?of?visited?vectors
dist(1:n)?=?inf;???%?it?stores?the?shortest?distance?between?the?source?node?and?any?other?node;
prev?=?cell(1n);
%?prev(1:n)?=?n+1;????%?Previous?node?informs?about?the?best?previous?node?known?to?reach?each??network?node?
prev

評論

共有 條評論