All files / src/algorithm find-cycles.ts

100% Statements 3/3
100% Branches 3/3
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11      16x 6x 11x          
import Graph from '../Graph';
import tarjan from './tarjan';
 
const findCycles = <NodeType>(graph: Graph<NodeType>) => {
  return tarjan<NodeType>(graph).filter(
    (cmpt) => cmpt.length > 1 || (cmpt.length === 1 && graph.hasEdge(cmpt[0], cmpt[0])),
  );
};
 
export default findCycles;