private void rProbeAndAddHopsToCandidateSet(Hop hop,HashSet<Hop> probeSet,HashSet<Pair<Hop,Hop>> candSet){
  if (hop.getVisited() == VisitStatus.DONE)   return;
  if (hop.getInput() != null)   for (  Hop c : hop.getInput()) {
    if (!probeSet.contains(c))     rProbeAndAddHopsToCandidateSet(c,probeSet,candSet);
 else {
      candSet.add(new Pair<Hop,Hop>(hop,c));
    }
  }
  hop.setVisited(VisitStatus.DONE);
}

private void rProbeAndAddHopsToCandidateSet ( Hop hop , HashSet < Hop > probeSet , HashSet < Pair < Hop , Hop > > candSet ) { if ( hop . getVisited ( ) == VisitStatus . DONE ) return ; if ( hop . getInput ( ) != null ) for ( Hop c : hop . getInput ( ) ) { if ( ! probeSet . contains ( c ) ) rProbeAndAddHopsToCandidateSet ( c , probeSet , candSet ) ; else { candSet . add ( new Pair < Hop , Hop > ( hop , c ) ) ; } } hop . setVisited ( VisitStatus . DONE ) ; }
note : candset is a set of parent - child pairs because a parent might have multiple references to replicated hops .
