Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build-layer-graph.js #396

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading