Accessibility from C++

Hi,

I need a graph library that is accessible for both Python and C++
together with a few other requirements.

graph-tool seems to fulfill all this requirements. However, I don't find
any information whether the library is usable from C++ code as well.

My project consists out of several modules that are all aware a one main
graph object. Each module can be written either in Python or C++. The
modules itself are managed with some Python code.

So my question is: Is it possible to get the C++ graph object out of the
Python graph object? Is it possible to fill the C++ graph object
directly with nodes and edges?

Another point is that I need to attach a pointer (or shared_ptr) to a
custom C++ type to some nodes. The pointer does not need to be
accessible or visible from Python. Is this possible in a simple way?
(Of course I can workaround with an e.g. map of type (vertex id,
pointer).)

Regards,
Gerion

So my question is: Is it possible to get the C++ graph object out of the
Python graph object? Is it possible to fill the C++ graph object
directly with nodes and edges?

This is possible, and not very difficult. However, it's undocumented at the
moment.

I'm working on some documentation, and I'll release it soon.

Another point is that I need to attach a pointer (or shared_ptr) to a
custom C++ type to some nodes. The pointer does not need to be
accessible or visible from Python. Is this possible in a simple way?
(Of course I can workaround with an e.g. map of type (vertex id,
pointer).)

You can either use a property map of type int64_t, which is enough to hold
pointers. You can also use type python::object, which will hold whatever you
can express in python, inclusive custom classes.

Hello

I have exactly the same requirement, but perhaps more specifically: how do I
get hold of the underlying boost::adjacency_list object to pass to C++ and
then extract from a boost::python::object?

To do this I just need to know two things: “stuff” and “command” in

typedef boost::adjacency_list< stuff > Graph;

and

boost::python::eval(“command”,main_namespace)

respectively. I could then extract the adjacency_list object of a graph
created with graph-tool using boost::python::extract as follows:

boost::python::object python_graph =
boost::python::eval(“command”,main_namespace);

Graph &cpp_graph = boost::python::extract<Graph&amp;> (python_graph);

I have attached some complete sample code that does this for a class Dog
that is wrapped as a python module manually. If you could provide me with
what I could use for the equivalent graph-tool “command” and “stuff”
(obviously the later will vary depending on the graph type, but let’s say
just for the default type initially) that would be great thanks!

David

  Dog.h
<http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496146/Dog.h&gt;
main.cpp
<http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496146/main.cpp&gt;
module.cpp
<http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496146/module.cpp&gt;

As I said before, I will provide documentation on this soon. Please have
some patience.

Best,
Tiago

I'm looking forward to this as well. Information on compiling c++ libraries
modularly would be appreciated as well. For example, I only need the core
functionality and not the inference modules.

Thank you!