public void DGraph_has_cycle() { DGraph<int> g = null; using (var reader = File.OpenText(@"C:\rajiv\DSinCS\DataStructures\DSTests\graph1.txt")) while (!reader.EndOfStream) { var V = uint.Parse(reader.ReadLine().Trim()); g = new DGraph<int>(V); while (!reader.EndOfStream) { var inp = reader.ReadLine().Split(new char[] { ' ' }).Select(int.Parse).ToArray(); g.AddEdge(inp[0], inp[1]); } } foreach (var e in g.BfsPathTo(0, 9)) { Console.WriteLine($"{e} "); } foreach (var e in g.DfsPathTo(0, 4)) { Console.WriteLine($"{e} "); } Console.WriteLine($"check cycle from a node 7 :{g.HasCycle(7)}"); Console.WriteLine($"check cycle from a node 0 :{g.HasCycle(0)}"); foreach (var e in g.DfsPathToNon(0, 4)) { Console.WriteLine($"{e} "); } }