Dijkstra算法求最短路径C#版.docx

想预览更多内容,点击预览全文

申明敬告:

本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己完全接受本站规则且自行承担所有风险,本站不退款、不进行额外附加服务;如果您已付费下载过本站文档,您可以点击这里二次下载

文档介绍

Dijkstra算法求最短路径(C#版)行如下图的路径,(vo是中心):经过该算法后转化为下图usingSystem;usingSystem.Collections;usingSystem.Text;namespaceGreedyclassMarxprivateint[Jdistance;privateintrow;privateArrayListways=newArrayList():publicMarx(intn,paramsint[jd){this?row=n;distance=newint[row*row];for(inti=0;i<row*row;i++){this?distance[:L=d[i];}for(inti=0;i<this.row;i++)//有row个点,则从中心到各点的路有row-1条{ArrayListw=newArrayList();intj=0;w.Add(j);ways?Add(w);}}//publicvoidFind_way(){ArrayListS=newArrayList(1);ArrayListSr=newArrayList(1);int[ZIndexof_distance=newint[this.row];for(inti=0;i<row;i++){Indexof_distance[iZ=i;}S?Add(Indexof_distanceLOZ);for(inti=0;i<this.row;i++){Sr.Add(Indexof_distanceFiZ);}Sr.RemoveAt(0);int匚D=newint[this,row]://存放中心点到每个点的距离//—以上已经初始化了,S和Sr(里边放的都是点的编号)intCount=this.row-1;while(Count>0){//假定中心点

最近下载