/** * Performs yes/no cycle detection on the entire graph. * * @return true iff the graph contains at least one cycle */ public boolean detectCycles() { try { execute(null, null); } catch (CycleDetectedException ex) { return true; } return false; }
/** * Performs yes/no cycle detection on an individual vertex. * * @param v the vertex to test * @return true if v is on at least one cycle */ public boolean detectCyclesContainingVertex(V v) { try { execute(null, v); } catch (CycleDetectedException ex) { return true; } return false; }
/** * Finds the vertex set for the subgraph of all cycles which contain a particular vertex. * * <p>REVIEW jvs 25-Aug-2006: This implementation is not guaranteed to cover all cases. If you * want to be absolutely certain that you report vertices from all cycles containing v, it's safer * (but less efficient) to use StrongConnectivityInspector instead and return the strongly * connected component containing v. * * @param v the vertex to test * @return set of all vertices reachable from v via at least one cycle */ public Set<V> findCyclesContainingVertex(V v) { Set<V> set = new HashSet<V>(); execute(set, v); return set; }