From b1923467635e80156fab0bb9c9194a5fd2c81af6 Mon Sep 17 00:00:00 2001 From: Rohit Paul <113459757+RohitPaul0007@users.noreply.github.com> Date: Sat, 9 Sep 2023 19:10:20 +0530 Subject: [PATCH] Update parent-dummy-chains.js --- lib/parent-dummy-chains.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/parent-dummy-chains.js b/lib/parent-dummy-chains.js index 59e95ab4..58a6a44a 100644 --- a/lib/parent-dummy-chains.js +++ b/lib/parent-dummy-chains.js @@ -1,17 +1,17 @@ module.exports = parentDummyChains; function parentDummyChains(g) { - var postorderNums = postorder(g); + let postorderNums = postorder(g); g.graph().dummyChains.forEach(v => { - var node = g.node(v); - var edgeObj = node.edgeObj; - var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w); - var path = pathData.path; - var lca = pathData.lca; - var pathIdx = 0; - var pathV = path[pathIdx]; - var ascending = true; + let node = g.node(v); + let edgeObj = node.edgeObj; + let pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w); + let path = pathData.path; + let lca = pathData.lca; + let pathIdx = 0; + let pathV = path[pathIdx]; + let ascending = true; while (v !== edgeObj.w) { node = g.node(v); @@ -44,12 +44,12 @@ function parentDummyChains(g) { // Find a path from v to w through the lowest common ancestor (LCA). Return the // full path and the LCA. function findPath(g, postorderNums, v, w) { - var vPath = []; - var wPath = []; - var low = Math.min(postorderNums[v].low, postorderNums[w].low); - var lim = Math.max(postorderNums[v].lim, postorderNums[w].lim); - var parent; - var lca; + let vPath = []; + let wPath = []; + let low = Math.min(postorderNums[v].low, postorderNums[w].low); + let lim = Math.max(postorderNums[v].lim, postorderNums[w].lim); + let parent; + let lca; // Traverse up from v to find the LCA parent = v; @@ -70,11 +70,11 @@ function findPath(g, postorderNums, v, w) { } function postorder(g) { - var result = {}; - var lim = 0; + let result = {}; + let lim = 0; function dfs(v) { - var low = lim; + let low = lim; g.children(v).forEach(dfs); result[v] = { low: low, lim: lim++ }; }