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
Am 10.01.19 um 13:48 schrieb Gerion Entrup:
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&> (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 main.cpp http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496146/main.cpp module.cpp http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/t496146/module.cpp
-- Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
Am 17.01.19 um 19:51 schrieb davidt:
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?
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!
-- Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/