I'd like code to show, when I click on the node of a graph network it highlights the graph that the node belongs to in vispy
I tried this code but the node doesn't get colored nor the neighbored nodes
def on_mouse_press(event):
if event.button == 1:
# Get the node that was clicked on and its index in the
# graph's list of nodes
node = event.pos
# Highlight all edges connected to this node by setting
# their widths to 5
for edge in self.edges:
if edge[0] == node or edge[1] == node:
edge[2].width = 5
self.canvas.update()
# Connect the callback function to the 'on_mouse_press'
# event of the graph object
events.on_mouse_press.connect(on_mouse_press)
# Show the canvas with all of its elements
self.canvas.show()