Inputs:[AorV]EitherAorVwhereAisaNxNadjacencymatrix,whereA(I,J)isnonzeroifandonlyifanedgeconnectspointItopointJNOTE:WorksforbothsymmetricandasymmetricAVisaNx2(orNx3)matrixofx,y,(z)coordinates[xyCorE]EitherxyorCorE(orE3)wherexyisaNx2(orNx3)matrixofx,y,(z)coordinates(equivalenttoV)NOTE:onlyvalidwithAasthefirstinputCisaNxNcost(perhapsdistance)matrix,whereC(I,J)containsthevalueofthecosttomovefrompointItopointJNOTE:onlyvalidwithAasthefirstinputEisaPx2matrixcontainingalistofedgeconnectionsNOTE:onlyvalidwithVasthefirstinputE3isaPx3matrixcontainingalistofedgeconnectionsinthefirsttwocolumnsandedgeweightsinthethirdcolumnNOTE:onlyvalidwithVasthefirstinput[SID](optional)1xLvectorofstartingpoints.Ifunspecified,thealgorithmwillcalculatetheminimalpathfromallNpointstothefinishpoint(s)(automaticallysetsSID=1:N)[FID](optional)1xMvectoroffinishpoints.Ifunspecified,thealgorithmwillcalculatetheminimalpathfromthestartingpoint(s)toallNpoints(automaticallysetsFID=1:N)Outputs:[costs]isanLxMmatrixofminimumcostvaluesfortheminimalpaths[paths]isanLxMcellcontainingtheshortestpatharrays[showWaitbar](optional)ascalarlogicalthatinitializesawaitbarifnonzeroNote:Iftheinputsare[A,xy]or[V,E],thecostisassumedtobe(andiscalculatedas)thepointtopointEuclideandistanceIftheinputsare[A,C]or[V,E3],thecostisobtainedfromeithertheCmatrixorfromtheedgeweightsinthe3rdcolumnofE3Example:%Calculatethe(allpairs)shortestdistancesandpathsusing[A,C]inputsn=7;A=zeros(n);xy=10*rand(n,2)tri=delaunay(xy(:,1),xy(:,2));I=tri(:);J=tri(:,[231]);J=J(:);IJ=I+n*(J-1);A(IJ)=1a=(1:n);b=a(ones(n,1),:);C=round(reshape(sqrt(sum((xy(b,:)-
2024/8/21 4:46:22
4KB
路由WSN
1