0

I'm looking to select the successors and the predecessors from a selected node within my graph. Essentially what I need my code to do is select the full path in and out of a note right to the end nodes.

I know how to select one or the other (successors or predecessors) but not both,

i'm currently using :

var nhood = node.successors();   
cy.batch(function(){
cy.elements().not( nhood ).removeClass('highlighted').addClass('faded');
nhood.removeClass('faded').addClass('highlighted');

I'm very new to JS and I'm pretty much fumbling around in the dark just now, learning as I go, so please excuse me if this is a simple question.

Thanks.

AndyP
  • 1

1 Answers1

0

You look like you want a BFS instead, because you want the entire connected component essentially. See http://js.cytoscape.org/#collection/algorithms/eles.breadthFirstSearch

You can keep an array and put visited nodes into them.

maxkfranz
  • 11,896
  • 1
  • 27
  • 36