Skip to content

Commit

Permalink
Update build-layer-graph.js
Browse files Browse the repository at this point in the history
  • Loading branch information
RohitPaul0007 authored Sep 10, 2023
1 parent 215449a commit 29b0398
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/order/build-layer-graph.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var Graph = require("@dagrejs/graphlib").Graph;
var util = require("../util");
let Graph = require("@dagrejs/graphlib").Graph;
let util = require("../util");

module.exports = buildLayerGraph;

Expand Down Expand Up @@ -34,12 +34,12 @@ module.exports = buildLayerGraph;
* graph is not a multi-graph.
*/
function buildLayerGraph(g, rank, relationship) {
var root = createRootNode(g),
let root = createRootNode(g),
result = new Graph({ compound: true }).setGraph({ root: root })
.setDefaultNodeLabel(v => g.node(v));

g.nodes().forEach(v => {
var node = g.node(v),
let node = g.node(v),
parent = g.parent(v);

if (node.rank === rank || node.minRank <= rank && rank <= node.maxRank) {
Expand All @@ -48,7 +48,7 @@ function buildLayerGraph(g, rank, relationship) {

// This assumes we have only short edges!
g[relationship](v).forEach(e => {
var u = e.v === v ? e.w : e.v,
let u = e.v === v ? e.w : e.v,
edge = result.edge(u, v),
weight = edge !== undefined ? edge.weight : 0;
result.setEdge(u, v, { weight: g.edge(e).weight + weight });
Expand Down

0 comments on commit 29b0398

Please sign in to comment.