How does js detect whether there is a closed-loop circuit in a flow chart similar to a neural network?

< H2 > question: as shown below: < / H2 >
this is a flowchart configuration page. The nodes in the whole flowchart can be connected in a lifetime.

I can traverse all the lines in the whole graph, and each line has two anchor points: sourceId and targetId.

the red connection in the figure is a closed-loop circuit that is not allowed, that is, an endless loop is not allowed in the whole flowchart.

js

Oct.08,2021

this is the current train of thought:

    
        :
        1hasCheckedTarget1122
            223hasCheckedTarget
                
                2(1)hasCheckedTarget2233
                        
Menu