public void Run() { Digraph g = BuildGraph(true); Cycle cycle = GetCycle(g); bool hasCycle = cycle.HasCycle(); if (hasCycle) { var cycles = cycle.GetCycle(); string cycleStr = ""; if (cycles != null) { cycleStr = string.Join(",", cycles); } Console.WriteLine($"Has cycle, the cycle is : {cycleStr}"); } else { Console.WriteLine("Hasn't cycle"); } g = BuildGraph(false); cycle = GetCycle(g); hasCycle = cycle.HasCycle(); if (hasCycle) { var cycles = cycle.GetCycle(); string cycleStr = ""; if (cycles != null) { cycleStr = string.Join(",", cycles); } Console.WriteLine($"Has cycle, the cycle is : {cycleStr}"); } else { Console.WriteLine("Hasn't cycle"); } }
public override bool IsDag() { return(!_cycle.HasCycle()); }