Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function sortLayerSubgraph(g, sg, cg, weights) {
cg = cg ? cg.filterNodes(nodesFromList(g.children(sg))) : new Digraph();
var nodeData = {};
g.children(sg).forEach(function(u) {
if (g.children(u).length) {
nodeData[u] = sortLayerSubgraph(g, u, cg, weights);
nodeData[u].firstSG = u;
nodeData[u].lastSG = u;
} else {
var ws = weights[u];
nodeData[u] = {
degree: ws.length,
barycenter: util.sum(ws) / ws.length,
order: g.node(u).order,
orderCount: 1,
list: [u]
};
function feasibleTree(g) {
var remaining = new Set(g.nodes()),
tree = new Digraph();
if (remaining.size() === 1) {
var root = g.nodes()[0];
tree.addNode(root, {});
tree.graph({ root: root });
return tree;
}
function addTightEdges(v) {
var continueToScan = true;
g.predecessors(v).forEach(function(u) {
if (remaining.has(u) && !slack(g, u, v)) {
if (remaining.has(v)) {
tree.addNode(v, {});
remaining.remove(v);
tree.graph({ root: v });
function feasibleTree(g) {
var remaining = new Set(g.nodes()),
tree = new Digraph();
if (remaining.size() === 1) {
var root = g.nodes()[0];
tree.addNode(root, {});
tree.graph({ root: root });
return tree;
}
function addTightEdges(v) {
var continueToScan = true;
g.predecessors(v).forEach(function(u) {
if (remaining.has(u) && !slack(g, u, v)) {
if (remaining.has(v)) {
tree.addNode(v, {});
remaining.remove(v);
tree.graph({ root: v });
function feasibleTree(g) {
var remaining = new Set(g.nodes()),
tree = new Digraph();
if (remaining.size() === 1) {
var root = g.nodes()[0];
tree.addNode(root, {});
tree.graph({ root: root });
return tree;
}
function addTightEdges(v) {
var continueToScan = true;
g.predecessors(v).forEach(function(u) {
if (remaining.has(u) && !slack(g, u, v)) {
if (remaining.has(v)) {
tree.addNode(v, {});
remaining.remove(v);
tree.graph({ root: v });
Graph.prototype.asDirected = function() {
var g = new Digraph();
this.eachNode(function(u, value) { g.addNode(u, value); });
this.eachEdge(function(e, u, v, value) {
g.addEdge(null, u, v, value);
g.addEdge(null, v, u, value);
});
return g;
};
function mergeNodeData(g, lhs, rhs) {
var cg = mergeDigraphs(lhs.constraintGraph, rhs.constraintGraph);
if (lhs.lastSG !== undefined && rhs.firstSG !== undefined) {
if (cg === undefined) {
cg = new Digraph();
}
if (!cg.hasNode(lhs.lastSG)) { cg.addNode(lhs.lastSG); }
cg.addNode(rhs.firstSG);
cg.addEdge(null, lhs.lastSG, rhs.firstSG);
}
return {
degree: lhs.degree + rhs.degree,
barycenter: (lhs.barycenter * lhs.degree + rhs.barycenter * rhs.degree) /
(lhs.degree + rhs.degree),
order: (lhs.order * lhs.orderCount + rhs.order * rhs.orderCount) /
(lhs.orderCount + rhs.orderCount),
orderCount: lhs.orderCount + rhs.orderCount,
list: lhs.list.concat(rhs.list),
firstSG: lhs.firstSG !== undefined ? lhs.firstSG : rhs.firstSG,
lastSG: rhs.lastSG !== undefined ? rhs.lastSG : lhs.lastSG,
function feasibleTree(g) {
var remaining = new Set(g.nodes()),
tree = new Digraph();
if (remaining.size() === 1) {
var root = g.nodes()[0];
tree.addNode(root, {});
tree.graph({ root: root });
return tree;
}
function addTightEdges(v) {
var continueToScan = true;
g.predecessors(v).forEach(function(u) {
if (remaining.has(u) && !slack(g, u, v)) {
if (remaining.has(v)) {
tree.addNode(v, {});
remaining.remove(v);
tree.graph({ root: v });
Graph.prototype.asDirected = function() {
var g = new Digraph();
this.eachNode(function(u, value) { g.addNode(u, value); });
this.eachEdge(function(e, u, v, value) {
g.addEdge(null, u, v, value);
g.addEdge(null, v, u, value);
});
return g;
};