igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Writing a C extension of python-igraph...


From: Emmanuel Navarro
Subject: [igraph] Writing a C extension of python-igraph...
Date: Fri, 20 Jan 2012 17:38:47 +0100

Hello,

I'm trying to rewrite some part of my python/igraph code in C...
Indeed it's quick and easy to implement a graph algorithm with
pyhton-igraph, however when an algorithm has proved its interest, it
may be very nice to move it to the C level of igraph and to still be
able to call it from Python !

The first thing to do is to rewrite the algorithm it self in C using igraph C.
Coding in C is not as pleasant than in Python (for my point of view
;-)) but it's not so complicated.

Ok, then I want to make it callable from python-igraph module.
For that I write a C extension for Python (a Python module written in
C) which wrap my newly written C function to a Python function.
Documentation is nice, it's not so complicated neither (cf:
http://docs.python.org/extending/extending.html).
Except to properly convert PyObject (graph, list, vertex selectors,
...) to corresponding igraph objects...

I manage to use "igraphmodule_api.h" in my wrapper, and then to
convert a PyObject* argument to a igraph_t pointer (with
PyIGraph_ToCGraph).
However I don't know how to do with other objects (list, vertex
selectors, etc...).
I see that all needed functions are in "convert.h" / "convert.c" in
the igraph-python module sources.
But it seems impossible to link this code from my wrapper... (?)
I can copy some functions from "convert.c" to my wrapper's code, it
works when functions doesn't need "graphobject.h" functions.
But anyway it looks stupid to have this code in double...
Is it a proper way to do ?
Does this functions have to be present in "igraphmodule_api.h" ?

Best regards,
Emmanuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]