title: Efficient gremlin query to find a cycle in a graph
body: <p>I have a big TinkerGraph (~80.000 vertices, ~160.000 edges) and I need to detect if there is a cycle in it using the <a href="https://tinkerpop.apache.org/" rel="nofollow noreferrer">Apache TinkerPop/Gremlin</a> query language. If any, I would like to obtain the vertices of one of the cycles.</p>
  
  <p>Is there a way to write a <code>O(|V| + |E|)</code> gremlin query to find a cyclic path in a graph?</p>
  
  <p>I tried using the queries from <a href="https://tinkerpop.apache.org/docs/3.2.1-SNAPSHOT/recipes/#cycle-detection" rel="nofollow noreferrer">here</a> and <a href="https://stackoverflow.com/a/40695998/2491528">here</a>, but they are too slow and they time out. I suspect that they are not <code>O(|V| + |E|)</code>, but I am still learning TinkerPop and I can not evaluate the memory/time complexity of the TinkerGraph implementation.</p>