public void DepthFirstWalk(DepthFirstHandler inHandler, DepthFirstHandler outHandler, int root, DirectedWalkMode mode, bool includeUnreachableFromRoot = false, object tag = null) { igraph_dfshandler_t inWrapper = (t, vid, dist, extra) => inHandler != null && inHandler(this, vid, dist, tag); igraph_dfshandler_t outWrapper = (t, vid, dist, extra) => outHandler != null && outHandler(this, vid, dist, tag); DllImporter.igraph_dfs(graph, root, (igraph_neimode_t)mode, includeUnreachableFromRoot, null, null, null, null, inWrapper, outWrapper, tag); }
public void IGraphWrappersGraphDepthFirstWalkTest() { 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>(); DepthFirstHandler handler = (graph1, vertexId, distance, tag) => { visited.Add(vertexId); return(false); }; graph.DepthFirstWalk(handler, 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)); } }