Hi @optmat
Great question. You can see the available widgets in the Panel reference Gallery. It sounds like the one you are looking for is the MultiSelect widget.
import panel as pn
import numpy as np
import holoviews as hv
pn.extension()
# produces a small graph and colors one of the nodes red and the others black
# Ideally, I would like to select multiple nodes from the given node set to be colored red
def hv_graph(color_these_nodes):
# set up the graph
color_these_nodes = list(color_these_nodes)
node_indices = np.arange(3, dtype=np.int32)
source = np.zeros(3, dtype=np.int32)
target = node_indices
# color all given nodes
node_colors = []
for node in node_indices:
# below the squared brackets are required as this example only allows one node to be colored
if node in color_these_nodes: # color the chosen node red
node_colors.append("red")
else:
node_colors.append("black") # color all other nodes with any other color
# create graph
x, y = [0, 1, 1], [0, 1, 2] # some coordinates
nodes = hv.Nodes((x, y, node_indices, node_colors), vdims="color")
graph = hv.Graph(((source, target), nodes)).opts(node_color="color")
return graph
all_nodes = pn.widgets.MultiSelect(options=[0, 1, 2], name="Node(s)")
h = pn.bind(hv_graph, color_these_nodes=all_nodes)
layout = pn.Column(all_nodes, h).servable()