问题
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?
回答1:
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()
来源:https://stackoverflow.com/questions/27696950/cytoscape-js-selector-for-edges-attached-to-selected-node