Rust igraph bindings

Hello!

I am soon migrating a project of mine written in Python to Rust and since I am using igraph, would like to port bindings for that as well :slight_smile:

I see that a previous attempt at Rust bindings for igraph was discussed but didn’t really seem to go anywhere (but maybe @dahlbaek if you have something you could share that would be great).

Is currently a good time to start writing these bindings? Is there something to keep in mind? I saw a 1.0 is currently in progress for the C bindings, so I’m a bit hesitant, I don’t know if I should start with the stable C bindings or focus on the efforts for 1.0. Are the rust-igraph-sys and rust-igraph crate names still fine to take?

In theory Rust bindings should be relatively straight forward. The sys crate can probably be mostly auto-generated with bindgen and the high level abstraction should be fairly straight forward as well. Hopefully I can get some trait-based magic in there to make vertex and edge attributes somewhat type-able :slight_smile: - But I also haven’t used nearly all of igraph’s features yet.

1 Like

Version 1.0 will be released soon (by the end of September, maybe October, if all goes well). The major change in this release affects attribute handling. The rest of the breaking changes concern mostly individual functions and have to do with API cleanup. After 1.0 there’ll be much more stability (see draft policy).

I recommend you target 1.0, which is now the develop branch. Expect some more breaking changes in the coming weeks, but these will mostly be to individual functions, so they should be easy to adapt to. The issue list is here.

You should be aware of Stimulus, igraph’s interface generator. It can use the interface description here to generate bindings automatically. This interface description contains more information that a C function prototype can, e.g. it distinguishes between plain integers and vertex indices. It is currently used to generate the low-level bindings for igraph’s R interface, and a project is underway to also auto-generate the Python interface as well: GitHub - igraph/python-igraph-ctypes: Experimental pure Python ctypes-based interface for igraph

Stimulus should make it possible to create nicer Rust bindings, but keep in mind that this system is still in flux. It was originally created for igraph’s R interface, and there are parts that haven’t been adapted yet (e.g. leftover R code in places like this). Also, we make no stability promises for functions.yaml at this moment. That said, the long term goal is to make it easy to generate bindings for new languages, and to generate all of igraph’s existing interfaces using Stimulus.

1 Like