Extract C++ edge from graph_tool.libgraph_tool_core.Edge

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Extract C++ edge from graph_tool.libgraph_tool_core.Edge

Gerion Entrup
Hi,

I'm using graph-tool from both Python and C++. Normally, all works well
with the dispatch function. But now I came to a situation, where I get
an edge object (graph_tool.libgraph_tool_core.Edge) and want to use
this from C++. Is there a way to do this?

This is the same question as: I have a function `void do_stuff(PyObject* foo)`
where `foo` is a `graph_tool.libgraph_tool_core.Edge`. Can I extract the
boost::detail::adj_edge_descriptor somehow (or whatever is the correct
edge type)?

Kind regards
Gerion

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (673 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Extract C++ edge from graph_tool.libgraph_tool_core.Edge

Gerion Entrup
Am Montag, 7. September 2020, 22:04:36 CEST schrieb Gerion Entrup:

> Hi,
>
> I'm using graph-tool from both Python and C++. Normally, all works well
> with the dispatch function. But now I came to a situation, where I get
> an edge object (graph_tool.libgraph_tool_core.Edge) and want to use
> this from C++. Is there a way to do this?
>
> This is the same question as: I have a function `void do_stuff(PyObject* foo)`
> where `foo` is a `graph_tool.libgraph_tool_core.Edge`. Can I extract the
> boost::detail::adj_edge_descriptor somehow (or whatever is the correct
> edge type)?
>
> Kind regards
> Gerion
Found out by myself. It is actually fairly simple.

void extract_edge(PyObject* py_edge) {
    graph_tool::EdgeBase& edge_base = boost::python::extract<graph_tool::EdgeBase&>(py_edge);
    graph_tool::GraphInterface::edge_t edge = edge_base.get_descriptor());
}


Best,
Gerion

_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (673 bytes) Download Attachment