Skip to content

Commit

Permalink
Merge pull request #418 from RohitPaul0007/patch-61
Browse files Browse the repository at this point in the history
Update acyclic.js
  • Loading branch information
rustedgrail authored Sep 11, 2023
2 parents 254fae9 + c6c8d0e commit eb5b9f0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/acyclic.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"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,
undo: undo
};

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;
Expand All @@ -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)) {
Expand All @@ -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);
Expand Down

0 comments on commit eb5b9f0

Please sign in to comment.