From b62510443392398e7f31ddee28a1e0c8a1edf74b Mon Sep 17 00:00:00 2001 From: YISH Date: Mon, 11 Mar 2024 20:00:43 +0800 Subject: [PATCH] Update index.ts --- packages/server/src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utils/index.ts b/packages/server/src/utils/index.ts index c96139d7..656e11a3 100644 --- a/packages/server/src/utils/index.ts +++ b/packages/server/src/utils/index.ts @@ -300,7 +300,7 @@ export const buildFlow = async ( } const initializedNodes: Set = new Set() - const nonDirectedGraph = constructGraphs(reactFlowNodes, reactFlowEdges, { isReversed: true }).graph + const reversedGraph = constructGraphs(reactFlowNodes, reactFlowEdges, { isReversed: true }).graph while (nodeQueue.length) { const { nodeId, depth } = nodeQueue.shift() as INodeQueue @@ -410,7 +410,7 @@ export const buildFlow = async ( const neighNodeId = neighbourNodeIds[i] if (ignoreNodeIds.includes(neighNodeId)) continue if (initializedNodes.has(neighNodeId)) continue - if (nonDirectedGraph[neighNodeId].some((dependId) => !initializedNodes.has(dependId))) continue + if (reversedGraph[neighNodeId].some((dependId) => !initializedNodes.has(dependId))) continue // If nodeId has been seen, cycle detected if (Object.prototype.hasOwnProperty.call(exploredNode, neighNodeId)) { const { remainingLoop, lastSeenDepth } = exploredNode[neighNodeId]