Search code examples
cytoscape.js

CytoscapeJs - full Neighborhood


When using the neighborhood(), Cytoscape only provides the direct surrounding nodes.

Is there a built in option to receive the full neighborhood / connected nodes as well? The docs don't specify anything around the neighborhood section.


Solution

  • I'm using this as workaround

    cy.on('tap', 'node', (e) => {
      const selected = e.target;
      const predecessors = selected.predecessors();
      const successors = selected.successors();
      ...
    });