How to read and set selected nodes in hv.Graph?

  1. Can I read the selected nodes (using “tap” tool) from hv.Graph object?
  2. Can I update the list of selected nodes programmatically? At or after initialization.
# ---- cell #1 ----
import hvplot.networkx as hvnx
import numpy as np
import networkx as nx
import holoviews as hv

np.random.seed(1)
G = nx.bull_graph()
fig = hvnx.draw(G, with_labels=True)

fig

# ---- cell #2 ----
# (1) Can I read the selected nodes from `fig` that a user tapped?
# * e.g. smth like print(fig.tap_tool.selected) to return [1,4]
# (2) Can I update the list of selected nodes programmatically?
# * e.g. smth like fig.tap_tool.selected = [1,2,4]
1 Like