[Networkit] Exporting NetworKit Iterators to Python

Michael Hamann michael.hamann at kit.edu
Mon Apr 27 13:38:32 CEST 2015


Dear NetworKit developers,

as I wanted a way to iterate over all edges of a graph in Python that also 
allows me to use edge ids without requesting each edge id separately, I added 
some Cython code which exports Graph::forEdges() to Python. I'm not totally 
happy, especially as it needs a C macro in order to work. I already asked in 
the cython-users list [0] how to do this without C macro, but unfortunately 
haven't got any reply so far. Furthermore I almost directly exported the 
method to Python which means that you do not get a Python iterator but a 
method which takes any Python callable (like a lambda or also a regular 
method) as argument.

I still think this might be useful for some and also a good starting point for 
implementating real Python iterators for our NetworKit iterators in Cython so 
I'm attaching a patch.

Best regards,
Michael

[0]: https://groups.google.com/d/topic/cython-users/tERxpDMcZHs/discussion
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Export-Graph-forEdges-to-Python.patch
Type: text/x-patch
Size: 2190 bytes
Desc: not available
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150427/e465e95e/attachment.bin>


More information about the NetworKit mailing list