コード例 #1
0
 public void IGraphWrappersGraphBreadthFirstWalkTest()
 {
     using (var graph = new Graph(4, new[] {
         Tuple.Create(0, 1),
         Tuple.Create(0, 2),
         Tuple.Create(1, 2),
         Tuple.Create(2, 0),
         Tuple.Create(3, 2),
     }, directed: true)) {
         var visited = new HashSet <int>();
         BreadthFirstHandler handler = (graph1, currentVertexId, previousVertexId, nextVertexId, rank, distance, tag) => {
             visited.Add(currentVertexId);
             return(false);
         };
         graph.BreadthFirstWalk(handler, 0, DirectedWalkMode.All, true, null);
         Assert.AreEqual(4, visited.Count);
         Assert.IsTrue(visited.Contains(0));
         Assert.IsTrue(visited.Contains(1));
         Assert.IsTrue(visited.Contains(2));
         Assert.IsTrue(visited.Contains(3));
     }
 }
コード例 #2
0
ファイル: Graph.cs プロジェクト: YChuan1115/HeuristicLab
        public void BreadthFirstWalk(BreadthFirstHandler handler, int root, DirectedWalkMode mode, bool includeUnreachableFromRoot = false, object tag = null)
        {
            igraph_bfshandler_t wrapper = (t, vid, pred, succ, rank, dist, extra) => handler != null && handler(this, vid, pred, succ, rank, dist, tag);

            DllImporter.igraph_bfs(graph, root, null, (igraph_neimode_t)mode, includeUnreachableFromRoot, null, null, null, null, null, null, null, wrapper, tag);
        }