I want to write interactive simulation using graph-tool. What I would like to do is first to visualize the graph, then pick nodes as an input for later actual simulation. How do I pass information from plot to function?
What I did so far - I looked through documentation and examples which do not provide such info.
Thanks!
If you invoke graph_draw
with output
parameter set to None
(which is the default), it returns a:
Boolean-valued vertex property map marking the vertices which were selected interactively.
If output
is not given, the graph "will be displayed via interactive_window()
" whose documentation points to GraphWidget
for key bindings information:
A group of vertices may be selected by holding the “shift” button while the pointer is dragged while pressing the left button.
For example:
import numpy as np
import graph_tool.all as gt
points = np.random.random((25, 2))
g, pos = gt.geometric_graph(points, 0.3)
_, selected = gt.graph_draw(g, pos=pos)
print(*selected.a)
Outputs:
1 0 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0