javascript - How to find subgraph -


i trying show specific subgraph of disconnected directed graph containing selected node user. parents, parents of parents... , children, children of children until roots , leaves. need hide rest of graph.

any appreciated.

as @aksam suggested, like:

var selectednode = cy.$('node:selected'); var visitedarr = [ selectednode ];  cy.elements().bfs({ // or dfs   roots: selectednode,   visit: function(i, depth, v, e, u){     visitedarr.push( v );   },   directed: false // or preference });  var subgraph = cy.collection( visitedarr );  cy.batch(function(){   cy.elements().not( subgraph ).addclass('hidden');   subgraph.removeclass('hidden'); }); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -