# Find cycles in a direct graph (simplecycles error: function not defined)

**URL:** https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449
**Category:** Graphs
**Tags:** graphs
**Created:** [August 28, 2022, 1:15am UTC](https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449 "2022-08-28T01:15:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Luiz\_Monteiro](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Luiz\_Monteiro](https://discourse.julialang.org/u/Luiz_Monteiro)
#### Post date: [August 28, 2022, 1:15am UTC](https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449/1 "2022-08-28T01:15:09Z")

</div>

Hi, I need to find cycles in a direct graph and return the vector of nodes of each cycle. I am using Graphs, LightGraphs, SimpleWeightedGraphs.

Example: For a direct graph with the arcs [(1 3), (2 4), (3 1), (4 5), (5, 2)], one solution should be a vector with two cycles [[1 3 1], [2 4 5 2]]

I look at the documentation, and it seems that the function “simplecycles()” would be a solution, but it is not running (ERROR: “UndefVarError: simplecycles not defined”), I dont know how to fix this error. Is there another function for similar application? Thanks

---

<div class="post-metadata">

### Author: ![Luiz\_Monteiro](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Luiz\_Monteiro](https://discourse.julialang.org/u/Luiz_Monteiro)
#### Post date: [August 28, 2022, 1:29am UTC](https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449/2 "2022-08-28T01:29:16Z")

</div>

Hi, I use the full line “Graphs.simplecycles(g)” and the function “simplecycles” worked well! I think it work as expected to solve the problem. 🙃

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [August 28, 2022, 1:40am UTC](https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449/3 "2022-08-28T01:40:00Z")

</div>

> [@Luiz\_Monteiro](#):
>
> using Graphs, LightGraphs

Hi! You shouldn’t be using both of these at the same time, and don’t need to either. `Graphs` contains the newer versions of `LightGraphs`, so you can remove the `LightGraphs` dependency.

That should solve the issue too, and allow you to call `simplecycles` directly without needing to specify `Graphs.simplecycles` - the conflict between `Graphs` and `LightGraphs` is what is causing the original issue.

---

<div class="post-metadata">

### Author: ![Luiz\_Monteiro](https://avatars.discourse-cdn.com/v4/letter/l/b77776/32.png) [@Luiz\_Monteiro](https://discourse.julialang.org/u/Luiz_Monteiro)
#### Post date: [August 28, 2022, 12:15pm UTC](https://discourse.julialang.org/t/find-cycles-in-a-direct-graph-simplecycles-error-function-not-defined/86449/4 "2022-08-28T12:15:18Z")

</div>

Thanks!
