code: private void search(int v, long prev, long curr) {
  
          state[v] = curr; // store the state before we visited v
          curr = setBit(curr, v); // include v in our current state (state[v] is unmodified)
          visited |= curr; // mark v as visited (or being visited)
  
          // neighbors of v
          for (int w : g[v]) {
  
              // w has been visited or is partially visited further up stack
              if (visited(w)) {
  
                  // if w is in our prev state we have a cycle of size >2.
                  // we don't check out current state as this will always
                  // include w - they are adjacent
                  if (isBitSet(prev, w)) {
                      numCycles++;
  
                      // xor the state when we last visited 'w' with our current
                      // state. this set is all the vertices we visited since then
                      // and are all in a cycle
                      add(state[w] ^ curr);
                  }
              } else {
                  // recursively call for the unvisited neighbor w
                  search(w, state[v], curr);
              }
          }
      }
docs: Perform a depth first search from the vertex <i>v</i>.
  
  @param v    vertex to search from
  @param prev the state before we vistaed our parent (previous state)
  @param curr the current state (including our parent)