乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Dijkstra.NET 庫(kù)體驗(yàn)報(bào)告

       路人甲Java 2021-12-06

      在VS里用Nuget下載"Dijkstra.NET"庫(kù),然后就可以在需要的地方使用了。

      首先,這是一個(gè)簡(jiǎn)單的graph,5個(gè)節(jié)點(diǎn),7條邊。

      上代碼

      移動(dòng)端看不清楚的可以看下面的:

      Graph<int, string> graph = new Graph<int, string>();
      graph.AddNode(1); // 添加節(jié)點(diǎn)1
      graph.AddNode(2); // 添加節(jié)點(diǎn)2
      graph.AddNode(3);
      graph.AddNode(4);
      graph.AddNode(5);
      graph.Connect(1, 2, 4, "some custom information in edge"); // 添加節(jié)點(diǎn)1和2的邊長(zhǎng)(即成本)5,并添加描述信息
      graph.Connect(2, 4, 1, "some custom information in edge"); 
      graph.Connect(1, 4, 2, "some custom information in edge"); 
      graph.Connect(2, 3, 4, "some custom information in edge"); 
      graph.Connect(3, 4, 1, "some custom information in edge");
      graph.Connect(3, 5, 3, "some custom information in edge"); 
      graph.Connect(4, 5, 7, "some custom information in edge"); 
      // graph.Connect(4, 3, 1, "some custom information in edge");  // 注釋這一句就會(huì)變成1 4 5 不注釋就是 1 4 3 5
      // 證明這個(gè)算法只能算有向圖
      
      ShortestPathResult result = graph.Dijkstra(1, 5); // 從圖中獲取節(jié)點(diǎn)1和2的最短路徑
      IEnumerable<uint> path = result.GetPath();// 返回所需走過(guò)的節(jié)點(diǎn)列表
      foreach (var item in path)
      {
          System.Console.WriteLine(item);// 結(jié)果是 1 4 5 -> 因?yàn)?~3沒(méi)有距離
      }

      基本不需要解釋了

      發(fā)現(xiàn)的問(wèn)題

      第一,這個(gè)算法只能解決有向圖的最短路徑;

      第二,計(jì)算結(jié)果返回的是節(jié)點(diǎn)號(hào)?不太清楚

      第三,沒(méi)有提供鄰接矩陣的接口,輸入數(shù)據(jù)也比較麻煩

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多