From fc99aa7636f9eb9864b856eda0930afc4b146c31 Mon Sep 17 00:00:00 2001 From: Rohit Paul <113459757+RohitPaul0007@users.noreply.github.com> Date: Sun, 10 Sep 2023 21:54:01 +0530 Subject: [PATCH] Update acyclic.js --- lib/acyclic.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/acyclic.js b/lib/acyclic.js index b78ad7b7..a67f71f1 100644 --- a/lib/acyclic.js +++ b/lib/acyclic.js @@ -1,7 +1,7 @@ "use strict"; -var greedyFAS = require("./greedy-fas"); -var uniqueId = require("./util").uniqueId; +let greedyFAS = require("./greedy-fas"); +let uniqueId = require("./util").uniqueId; module.exports = { run: run, @@ -9,11 +9,11 @@ module.exports = { }; function run(g) { - var fas = (g.graph().acyclicer === "greedy" + let fas = (g.graph().acyclicer === "greedy" ? greedyFAS(g, weightFn(g)) : dfsFAS(g)); fas.forEach(e => { - var label = g.edge(e); + let label = g.edge(e); g.removeEdge(e); label.forwardName = e.name; label.reversed = true; @@ -28,9 +28,9 @@ function run(g) { } function dfsFAS(g) { - var fas = []; - var stack = {}; - var visited = {}; + let fas = []; + let stack = {}; + let visited = {}; function dfs(v) { if (visited.hasOwnProperty(v)) { @@ -54,11 +54,11 @@ function dfsFAS(g) { function undo(g) { g.edges().forEach(e => { - var label = g.edge(e); + let label = g.edge(e); if (label.reversed) { g.removeEdge(e); - var forwardName = label.forwardName; + let forwardName = label.forwardName; delete label.reversed; delete label.forwardName; g.setEdge(e.w, e.v, label, forwardName);