Skip to content

Commit

Permalink
Merge pull request #414 from RohitPaul0007/patch-57
Browse files Browse the repository at this point in the history
Update sort-subgraph.js
  • Loading branch information
rustedgrail authored Sep 11, 2023
2 parents 76ff416 + 4523846 commit cd5aeca
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/order/sort-subgraph.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
var barycenter = require("./barycenter");
var resolveConflicts = require("./resolve-conflicts");
var sort = require("./sort");
let barycenter = require("./barycenter");
let resolveConflicts = require("./resolve-conflicts");
let sort = require("./sort");

module.exports = sortSubgraph;

function sortSubgraph(g, v, cg, biasRight) {
var movable = g.children(v);
var node = g.node(v);
var bl = node ? node.borderLeft : undefined;
var br = node ? node.borderRight: undefined;
var subgraphs = {};
let movable = g.children(v);
let node = g.node(v);
let bl = node ? node.borderLeft : undefined;
let br = node ? node.borderRight: undefined;
let subgraphs = {};

if (bl) {
movable = movable.filter(w => w !== bl && w !== br);
}

var barycenters = barycenter(g, movable);
let barycenters = barycenter(g, movable);
barycenters.forEach(entry => {
if (g.children(entry.v).length) {
var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
let subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
subgraphs[entry.v] = subgraphResult;
if (subgraphResult.hasOwnProperty("barycenter")) {
mergeBarycenters(entry, subgraphResult);
}
}
});

var entries = resolveConflicts(barycenters, cg);
let entries = resolveConflicts(barycenters, cg);
expandSubgraphs(entries, subgraphs);

var result = sort(entries, biasRight);
let result = sort(entries, biasRight);

if (bl) {
result.vs = [bl, result.vs, br].flat(true);
if (g.predecessors(bl).length) {
var blPred = g.node(g.predecessors(bl)[0]),
let blPred = g.node(g.predecessors(bl)[0]),
brPred = g.node(g.predecessors(br)[0]);
if (!result.hasOwnProperty("barycenter")) {
result.barycenter = 0;
Expand Down

0 comments on commit cd5aeca

Please sign in to comment.