findCycles method

HashSet<T> findCycles(
  1. T n
)

Implementation

HashSet<T> findCycles(T n) {
  _perm.clear();
  _temp.clear();
  _cycleNodes.clear();
  _order.clear();

  var cycles = stronglyConnectedComponents<T>([n], dependentsOf);

  cycles.forEach((cycle) {
    // cycles of len 1 are not cycles.
    if (cycle.length > 1) {
      cycle.forEach(_cycleNodes.add);
    }
  });
  return _cycleNodes;
}