# Calculating minimal cycle basis on IGraph

**URL:** <https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905>\
**Category:** Usage\
**Tags:** Python, Mathematica\
**Created:** [18 October 2021 20:22 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905 "2021-10-18T20:22:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shashank\_markande](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/shashank_markande/32/540_2.png) [@shashank\_markande](https://igraph.discourse.group/u/shashank_markande)\
**Post date:** [18 October 2021 20:22 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905/1 "2021-10-18T20:22:53Z")

</div>

Hi! I have to calculate minimal cycles bases for a bunch of graphs each of have around 500-1000 nodes (in that range). The algorithm implemented in NetworkX takes extremely long. While I’ve noticed it is extremely fast in mathematica. However, I want to be able to use a method that is native to python environment. So, does IGraph implement a faster method for calculating cycle basis? Or any other method I am not aware of, that is faster and can be implemented in python is useful too.

Thanks!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [18 October 2021 20:46 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905/2 "2021-10-18T20:46:30Z")

</div>

It is coming “soon”. I’m done with most of the implementation of the unweighted case, but some parts need to be finished and I have very little time right now. The weighted case still needs to be done.

The unweighted case will certainly be in C/igraph 0.10 and whatever high-level interfaces are based on that.

The work-in-progress implementation I wrote is orders of magnitude faster than networkx’s.

---

<div class="post-metadata">

**Author:** ![shashank\_markande](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/shashank_markande/32/540_2.png) [@shashank\_markande](https://igraph.discourse.group/u/shashank_markande)\
**Post date:** [27 October 2021 19:39 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905/3 "2021-10-27T19:39:12Z")

</div>

That’s great to know! I have been using networkx algorithm for weighted graphs and it is pretty slow. I am looking forward to using it. Is this implementation is going to be in python? or just in the mathematica package?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [27 October 2021 19:50 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905/4 "2021-10-27T19:50:10Z")

</div>

It will be in both Mathematica in Python. It is being contributed to the C core.

> <https://github.com/igraph/igraph/pull/1786>
>
> Fixes #1252

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [27 October 2021 20:25 UTC](https://igraph.discourse.group/t/calculating-minimal-cycle-basis-on-igraph/905/5 "2021-10-27T20:25:39Z")

</div>

Also, to be clear, I can’t make promises about implementing the weighted case for the next release. The unweighted case will certainly be there, but I may not have time for the weighted one before the next release, so it may need to be delayed.
