public void BaseTest() { var dfs = new DFS <int>(); var emptyList = new List <int>(); // No elements to traverse Assert.Equal(emptyList, dfs.Find(0, 1)); // Add bogey nodes and edge dfs.AddEdge(0, 1); // Target vertex does not exist Assert.Equal(emptyList, dfs.Find(0, 5)); }
public void SimpleTraversalTest_Integers() { var dfs = new DFS <int>(); dfs.AddEdge(2, 0); dfs.AddEdge(0, 2); dfs.AddEdge(0, 1); dfs.AddEdge(1, 2); dfs.AddEdge(2, 3); dfs.AddEdge(3, 3); }
public static void Main(String[] args) { DFS g = new DFS(4); g.AddEdge(0, 1); g.AddEdge(0, 2); g.AddEdge(1, 2); g.AddEdge(2, 0); g.AddEdge(2, 3); g.AddEdge(3, 3); Console.WriteLine("Following is Depth First Traversal (starting from vertex 2)"); g.dfs(2); Console.ReadKey(); }