Finding Out Looped Graphs

I am trying to identify situations where I have inadvertently created edges that connect to the same vertex, resulting in F -> F and also possibly G -> F -> G scenarios. What are effective Gremlin techniques for detecting and resolving these instances?
2 Replies
kelvinl2816
kelvinl28162y ago
You most likely want to look at the cyclicPath step. You can then build repeat until type queries that look for cyclicPath happening. You will also want to limit those queries (using loops or something similar) so they don't become long running if the graph is highly connected Here is a very simple example
gremlin> g.V(1,2,3).repeat(out()).until(cyclicPath().or().loops().is(3)).path().limit(3)
==>[v[1],v[47],v[1]]
==>[v[1],v[49],v[1]]
==>[v[1],v[51],v[1]]
gremlin> g.V(1,2,3).repeat(out()).until(cyclicPath().or().loops().is(3)).path().limit(3)
==>[v[1],v[47],v[1]]
==>[v[1],v[49],v[1]]
==>[v[1],v[51],v[1]]
ManabuBeach
ManabuBeach2y ago
🏁
Want results from more Discord servers?
Add your server