0

I am using reactflow to create a system of sequences, each with their own "levels"

I need to only allow sequences to connect to others of a lower level than their own. For example, A level 5 sequence should be able to connect to sequences of level 4, 3, 2 or 1. It should not be able to connect to a level 6 sequence. Users are also able to change the sequence level

Since connections are created between two nodes using their respective ids, I've tried using those to validate connections, but this presents two problems.

A) Ids would need to be changed every time the user updates the sequence level
B) Two level 2 sequences could not exist at the same time, as they would have identical ids

All of my work thus far has been based on the reactflow documentation "Custom Node Example"
https://reactflow.dev/docs/examples/nodes/custom-node/
and the "Validation Example"
https://reactflow.dev/docs/examples/interaction/validation/

New nodes are added to the reactflow instance with the following code
New Node Code

Any help in setting up validation based on 'levels' is appreciated. Thanks!

1 Answers1

0

yes. you could use d3-hierarchy or dagre.js to maintain hierarchy.