public List<Set<T>> getCycles() {
        return scc.stream().filter(cc ->
                cc.size() > 1
                        || graph.get(Iterables.getOnlyElement(cc)).contains(Iterables.getOnlyElement(cc))
        )
                .collect(Collectors.toList());
    }
public List < Set < T > > getCycles ( ) { return scc . stream ( ) . filter ( cc -> cc . size ( ) > 1 || graph . get ( Iterables . getOnlyElement ( cc ) ) . contains ( Iterables . getOnlyElement ( cc ) ) ) . collect ( Collectors . toList ( ) ) ; }
A cycle isa a connected component that has more than one vertex or a single vertex linked to itself.
@return list of cycles in the graph