diff --git a/back/data.js b/back/data.js index 176879f..3eab080 100644 --- a/back/data.js +++ b/back/data.js @@ -123,7 +123,7 @@ out body qt; const currentStop = stops[currentStopIndex]; const nextStop = stops[currentStopIndex + 1]; - const visited = new Set(); + const visitedEdges = new Set(); const stack = [{ currentNode: currentStop.id, way: [currentStop.id], @@ -134,7 +134,6 @@ out body qt; while (stack.length !== 0) { const {currentNode, way} = stack.pop(); - visited.add(currentNode); if (currentNode === nextStop.id) { @@ -148,8 +147,11 @@ out body qt; for (let nextNode of neighbors) { - if (!visited.has(nextNode)) + const edge = `${currentNode}-${nextNode}`; + + if (!visitedEdges.has(edge)) { + visitedEdges.add(edge); stack.push({ currentNode: nextNode, way: way.concat([nextNode]),