Search code examples
javascriptjointjs

JointJS - get all successors with links


To get successors of element I'm using:

const successors = graph.getSuccessors(element);

But it returns elements without links. Is it some way to specify this function with options joint.dia.Graph.ExploreOptions to return also links? Or is it some other way to get successors elements with links together?

Thanks

Rafal


Solution

  • You are looking for graph.getSubgraph(cells, [, opt]) method (documentation).

    var elements = graph.getSuccessors(element).concat(element);
    // find all the links between successors and the element
    var subgraph = graph.getSubgraph(elements);
    // remove the element itself
    subgraph.splice(subgraph.indexOf(element), 1);