Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cytoscape.js - selector for edges attached to selected node

Tags:

cytoscape.js

I want to set the color of all edges that are attached to a selected node, so that each time a user selects a node any edges that the node is either a source or target of will be a different color. What would the selector look like for this, or is it not possible?

like image 358
Jeremy Avatar asked Dec 29 '14 22:12

Jeremy


1 Answers

You can't just use a selector, because you need a small graph traversal in addition to the initial filter, e.g.: cy.$('node:selected').neighborhood('edge'); i.e. for selected nodes get all connected edges

Or cy.$('node:selected').connectedEdges()

like image 59
maxkfranz Avatar answered Sep 30 '22 13:09

maxkfranz