javascriptcytoscape.jscytoscapecytoscape-web

Select leaf node in compound nodes with cytoscape.js


I have several compound nodes (A contains B, and B contains C)and I want to select the leaf node (C). How to do that?

Thanks!


Solution

  • What you mean by selecting isn't clear, but I'm guessing you mean how to query the graph:

    cy.nodes().not(':parent'); // all nodes who are not themselves a parent
    // or //
    cy.nodes(':child').not(':parent'); // all descendant nodes who are not themselves a parent