QuickGraph


グラフ理論
QuickGraphを使えばパス探索(最短経路)ぐらいは簡単そう。
https://quickgraph.codeplex.com/

適当に作ったデータのエッジをコピペして動かしてみた。
LINK-Node

型指定だし使いやすそう。
ArcGISで言うところのジオメトリックネットワーク相当の機能か。
閉路になってるエッジ一覧が欲しいが見つけられていない。

  var edges = new SEdge<int>[]
  {
new SEdge<int>(1,2),
new SEdge<int>(3,2),
new SEdge<int>(1,4),
new SEdge<int>(2,1),
new SEdge<int>(1,0),
new SEdge<int>(5,4),
new SEdge<int>(7,3),
new SEdge<int>(3,5),
new SEdge<int>(5,6),
new SEdge<int>(9,7),
new SEdge<int>(7,8),
new SEdge<int>(7,9),
new SEdge<int>(11,9),
new SEdge<int>(9,10),
new SEdge<int>(10,8),
new SEdge<int>(13,10),
new SEdge<int>(10,12),
new SEdge<int>(8,6),
new SEdge<int>(11,13),
new SEdge<int>(14,12),
new SEdge<int>(14,16),
new SEdge<int>(13,14),
new SEdge<int>(15,13),
new SEdge<int>(16,17),
new SEdge<int>(18,17),
new SEdge<int>(3,7),
new SEdge<int>(18,19),
new SEdge<int>(20,21),
new SEdge<int>(19,17),
new SEdge<int>(20,19),
new SEdge<int>(15,18),
new SEdge<int>(20,22),
new SEdge<int>(15,20),
new SEdge<int>(22,21),
new SEdge<int>(22,24),
new SEdge<int>(23,22),
new SEdge<int>(15,23),
new SEdge<int>(26,24),
new SEdge<int>(25,26),
new SEdge<int>(25,23),
new SEdge<int>(21,17),
new SEdge<int>(26,27),
new SEdge<int>(11,15),
new SEdge<int>(4,0),
new SEdge<int>(29,28),
new SEdge<int>(28,27),
new SEdge<int>(27,30),
new SEdge<int>(27,24),
new SEdge<int>(28,29),
new SEdge<int>(32,29),
new SEdge<int>(29,31),
new SEdge<int>(31,34),
new SEdge<int>(33,31),
new SEdge<int>(35,34),
new SEdge<int>(31,30),
new SEdge<int>(25,28),
new SEdge<int>(33,35),
new SEdge<int>(36,34),
new SEdge<int>(35,36),
new SEdge<int>(25,32),
new SEdge<int>(32,33),
new SEdge<int>(16,12),
new SEdge<int>(40,32),
new SEdge<int>(32,37),
new SEdge<int>(35,39),
new SEdge<int>(37,35),
new SEdge<int>(38,32),
new SEdge<int>(40,42),
new SEdge<int>(37,41),
new SEdge<int>(43,38),
new SEdge<int>(12,6),
new SEdge<int>(24,17),
new SEdge<int>(6,0),
new SEdge<int>(17,6),
new SEdge<int>(38,40),
new SEdge<int>(42,41),
new SEdge<int>(38,44),
new SEdge<int>(43,45),
new SEdge<int>(25,38),
new SEdge<int>(38,43),
new SEdge<int>(11,25)
  };


  var graph = edges.ToAdjacencyGraph<int, SEdge<int>>();

  int srcId = 18;
  int dstId = 0;

  Func<SEdge<int>, double> distFunc = e => 1;


  var pathFunc = graph.ShortestPathsDijkstra(distFunc, srcId);
  IEnumerable<SEdge<int>> path = null;

  if (pathFunc(dstId, out path))
  {
    foreach (var e in path)
    {
      Console.WriteLine(e);
    }//end loop
  }//end if
カテゴリー: 開発 タグ: パーマリンク