networkx/networkx — pull request #888 by Friedsoap (2013-06-12 21:43:34+00:00)
Title: Main changes to add node and edge filtering capacity to simple_cycles

I modified the simple_cycles algorithm because I was getting a MemoryError due to the size of the result array (I was studying (almost) complete digraphs which are the worst case for simple cycles since (almost) all of cycles exists. The biggest complete digraph for which all cycles can be found in a 32-bit machine is an 11 node one; a 12 node one raises a MemoryError). However, I did not require all simple cycles but only some: the ones going through specific nodes or edges. Thus, I modified simple_cycles accordingly, so that now you can filter the results either by providing a list of nodes AND/ OR a list of edges which will not appear in the results.

In both cases, the size of the result is lower due to the filtering, enabling to analyse bigger graphs.

Providing a node list also speeds up the calculation since some nodes are skipped.

The code seems to work for digraphs but I am not sure for non-directed graphs. I believe I should filter for both edge directions ([a,b] and [b,a]) but I am not sure whether that is redundant.