graph_tool.run_action - Inline C++ code embedding

This module implements support for automatic ad-hoc code embedding into graph-tool.


inline Compile (if necessary) and run the C++ code specified by ‘code’, using weave.


graph_tool.run_action.inline(code, arg_names=None, local_dict=None, global_dict=None, force=False, compiler='gcc', verbose=False, auto_downcast=1, support_code='', libraries=None, library_dirs=None, extra_compile_args=None, runtime_library_dirs=None, extra_objects=None, extra_link_args=None, mask_ret=None, debug=False)

Compile (if necessary) and run the C++ code specified by ‘code’, using weave. The (possibly modified) variables in ‘arg_names’ are returned.

See scipy.weave.inline() for detailed parameter documentation.


Graphs and property maps are automatically converted to appropriate [Boost] graph types. For convenience, the graph types are automatically typedef’d to ${name}_graph_t, where ${name} is the graph’s variable name passed to arg_names. Property map types are typedef’d to vprop_${val_type}_t, eprop_${val_type}_t or gprop_${val_type}_t, for vertex, edge or graph properties, where ${val_type} specifies the value type (e.g. int, bool, double, etc.). In the case of vector types, the “<” and “>” symbols are replaced by underscores (“_”).


[Boost](1, 2)


>>> from numpy.random import seed
>>> seed(42)
>>> g = gt.random_graph(100, lambda: (3, 3))
>>> nv = 0
>>> ret = gt.inline("nv = num_vertices(g);", ['g', 'nv'])
>>> print(ret["nv"])
>>> prop = g.new_vertex_property("vector<double>")
>>> prop[g.vertex(0)] = [1.0, 4.2]
>>> val = 0.0
>>> ret = gt.inline("val = prop[vertex(0,g)][1];", ['g', 'prop', 'val'])
>>> print(ret["val"])

Table Of Contents

Previous topic

graph_tool.generation - Random graph generation

Next topic - Search algorithms

This Page

Latest development version docs are also available.