Function pathfinding::cycle_detection::floyd
source · pub fn floyd<T, FS>(start: T, successor: FS) -> (usize, T, usize)where
T: Clone + PartialEq,
FS: Fn(T) -> T,
Expand description
Identify a cycle in an infinite sequence using Floyd’s algorithm. Return the cycle size, the first element, and the index of first element.
Warning
If no cycle exist, this function loops forever.