文档介绍
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){//假定中心点