holoviews
holoviews copied to clipboard
Selection1D interfacing with Graph
Requesting that the ability to interface a Selection1D stream with a Graph be implemented. I am looking to be able to use the lasso, box, or tap select tools to highlight nodes (or edges), and be able to stream that information over to another display showing just those nodes (or edges). I believe there's an example on how to do this with Points, but I haven't found a way to do so with a Graph.
For reference see short conversation here:
How would one show a lasso selection of an hv.Graph in a separate hv.DynamicMap?
This is something that should be added at the bokeh level, and has been talked about in the past.
How would one show a lasso selection of an hv.Graph in a separate hv.DynamicMap?
I think there might be an issue that a Selection1D stream does not currently work with a Graph, you may have to add an invisible set of points on top and select on those instead.
Would be good to file an issue about the graph selection issue.
After a brief attempt at simply attaching a callback to the node source in GraphPlot it seems like this will need a change in bokeh, since it does not seem to be triggering events on selections.
Is there a corresponding bokeh issue we can link to?
@philippjfr As of 2022/12/14, this now works by attaching to the points itself (i.e. graph.nodes), but it still does not work when attaching to the graph. Also see https://discourse.holoviz.org/t/selection-on-graph-nodes-doesnt-work/3437
Here is some sample code showing that info is propagated from graph.nodes but not from graph as a whole:
This works:
full_graph = hv.Graph.from_networkx(nx.karate_club_graph(), nx.spring_layout)
def node_view(index):
return hv.Text(.5, .5, str(index))
selection_stream = hv.streams.Selection1D(source=full_graph.nodes)
full_graph.nodes + hv.DynamicMap(node_view, streams=[selection_stream])
Changingfull_graph.nodes to full_graph breaks it.
I'm having the same issue. Is this still a bokeh problem or can be fixed in holoviews?