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
Post a Comment