//is this graph cyclical private bool isCyclical(Stack <point> current, List <point> visited, point parent, out List <point> newVisted) { if (current.Count == 0) { newVisted = new List <point>(visited); return(false); } point nextPoint = current.Pop(); visited.Add(nextPoint); foreach (point p in nextPoint.getAdj()) { if (visited.Contains(p)) { if (p != parent) { newVisted = new List <point>(visited); return(true); } } else { current.Push(p); if (isCyclical(current, visited, nextPoint, out newVisted)) { newVisted = new List <point>(visited); return(true); } } } newVisted = new List <point>(visited); return(false); }