Skip to content

Finding all connected elements between 2 elements #1750

Answered by kumilingus
alexandernst asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, I would use Dijkstra's shortest path algorithm to receive the Option A (docs, demo). And Option B could be derived from A as discussed here (the descendants of the local hierarchical roots could be filtered out).

const optionBResult = optionAResult.filter((e1, _, elements) => {
    const isEmbeddedInElements = [el, ...elements].find(e2 => e1 !== e2 && e1.isEmbeddedIn(e2));
    return !isEmbeddedInElements;
});

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@alexandernst
Comment options

@kumilingus
Comment options

@alexandernst
Comment options

@kumilingus
Comment options

@alexandernst
Comment options

Answer selected by alexandernst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants