Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tbo47 committed Nov 17, 2023
1 parent 67c5f0a commit 0d46d85
Show file tree
Hide file tree
Showing 37 changed files with 91 additions and 98 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: '' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
interval: 'weekly'
2 changes: 1 addition & 1 deletion src/dagre-js/arrows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as util from './util.js';

export { arrows, setArrows };

var arrows = {
let arrows = {
normal,
vee,
undirected,
Expand Down
2 changes: 1 addition & 1 deletion src/dagre-js/create-clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as util from './util.js';

export { createClusters, setCreateClusters };

var createClusters = function (selection, g) {
let createClusters = function (selection, g) {
const clusters = g.nodes().filter(function (v) {
return util.isSubgraph(g, v);
});
Expand Down
5 changes: 3 additions & 2 deletions src/dagre-js/create-edge-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ var createEdgePaths = function (selection, g, arrows) {
const newPaths = enter(previousPaths, g);
exit(previousPaths, g);

const svgPaths = previousPaths.merge !== undefined ? previousPaths.merge(newPaths) : previousPaths;
const svgPaths =
previousPaths.merge !== undefined ? previousPaths.merge(newPaths) : previousPaths;
util.applyTransition(svgPaths, g).style('opacity', 1);

// Save DOM element in the path group, and set ID and class
Expand All @@ -32,7 +33,7 @@ var createEdgePaths = function (selection, g, arrows) {
util.applyClass(
domEdge,
edge['class'],
(domEdge.classed('update') ? 'update ' : '') + 'edgePath'
(domEdge.classed('update') ? 'update ' : '') + 'edgePath',
);
});

Expand Down
6 changes: 3 additions & 3 deletions src/dagre-js/create-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as util from './util.js';

export { createNodes, setCreateNodes };

var createNodes = function (selection, g, shapes) {
let createNodes = function (selection, g, shapes) {
const simpleNodes = g.nodes().filter(function (v) {
return !util.isSubgraph(g, v);
});
Expand All @@ -28,7 +28,7 @@ var createNodes = function (selection, g, shapes) {
util.applyClass(
thisGroup,
node['class'],
(thisGroup.classed('update') ? 'update ' : '') + 'node'
(thisGroup.classed('update') ? 'update ' : '') + 'node',
);

thisGroup.select('g.label').remove();
Expand Down Expand Up @@ -61,7 +61,7 @@ var createNodes = function (selection, g, shapes) {
(node.paddingLeft - node.paddingRight) / 2 +
',' +
(node.paddingTop - node.paddingBottom) / 2 +
')'
')',
);

const root = d3.select(this);
Expand Down
33 changes: 15 additions & 18 deletions src/dagre-js/intersect/intersect-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ function intersectLine(p1, p2, q1, q2) {
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
// p7 and p473.

let a1, a2, b1, b2, c1, c2;
let r1, r2, r3, r4;
let denom, offset, num;
let x, y;
let num;

// Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x +
// b1 y + c1 = 0.
a1 = p2.y - p1.y;
b1 = p1.x - p2.x;
c1 = p2.x * p1.y - p1.x * p2.y;
const a1 = p2.y - p1.y;
const b1 = p1.x - p2.x;
const c1 = p2.x * p1.y - p1.x * p2.y;

// Compute r3 and r4.
r3 = a1 * q1.x + b1 * q1.y + c1;
r4 = a1 * q2.x + b1 * q2.y + c1;
const r3 = a1 * q1.x + b1 * q1.y + c1;
const r4 = a1 * q2.x + b1 * q2.y + c1;

// Check signs of r3 and r4. If both point 3 and point 4 lie on
// same side of line 1, the line segments do not intersect.
Expand All @@ -30,13 +27,13 @@ function intersectLine(p1, p2, q1, q2) {
}

// Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0
a2 = q2.y - q1.y;
b2 = q1.x - q2.x;
c2 = q2.x * q1.y - q1.x * q2.y;
const a2 = q2.y - q1.y;
const b2 = q1.x - q2.x;
const c2 = q2.x * q1.y - q1.x * q2.y;

// Compute r1 and r2
r1 = a2 * p1.x + b2 * p1.y + c2;
r2 = a2 * p2.x + b2 * p2.y + c2;
const r1 = a2 * p1.x + b2 * p1.y + c2;
const r2 = a2 * p2.x + b2 * p2.y + c2;

// Check signs of r1 and r2. If both point 1 and point 2 lie
// on same side of second line segment, the line segments do
Expand All @@ -46,21 +43,21 @@ function intersectLine(p1, p2, q1, q2) {
}

// Line segments intersect: compute intersection point.
denom = a1 * b2 - a2 * b1;
const denom = a1 * b2 - a2 * b1;
if (denom === 0) {
return /*COLLINEAR*/;
}

offset = Math.abs(denom / 2);
const offset = Math.abs(denom / 2);

// The denom/2 is to get rounding instead of truncating. It
// is added or subtracted to the numerator, depending upon the
// sign of the numerator.
num = b1 * c2 - b2 * c1;
x = num < 0 ? (num - offset) / denom : (num + offset) / denom;
const x = num < 0 ? (num - offset) / denom : (num + offset) / denom;

num = a2 * c1 - a1 * c2;
y = num < 0 ? (num - offset) / denom : (num + offset) / denom;
const y = num < 0 ? (num - offset) / denom : (num + offset) / denom;

return { x: x, y: y };
}
Expand Down
2 changes: 1 addition & 1 deletion src/dagre-js/intersect/intersect-polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function intersectPolygon(node, polyPoints, point) {
node,
point,
{ x: left + p1.x, y: top + p1.y },
{ x: left + p2.x, y: top + p2.y }
{ x: left + p2.x, y: top + p2.y },
);
if (intersect) {
intersections.push(intersect);
Expand Down
4 changes: 2 additions & 2 deletions src/dagre-js/shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { intersectRect } from './intersect/intersect-rect.js';

export { shapes, setShapes };

var shapes = {
let shapes = {
rect,
ellipse,
circle,
Expand Down Expand Up @@ -83,7 +83,7 @@ function diamond(parent, bbox, node) {
.map(function (p) {
return p.x + ',' + p.y;
})
.join(' ')
.join(' '),
);

node.intersect = function (p) {
Expand Down
2 changes: 1 addition & 1 deletion src/dagre/greedy-fas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function greedyFAS(g, weightFn?) {
return _.flatten(
_.map(results, function (e) {
return g.outEdges(e.v, e.w);
})
}),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dagre/layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ function extractCoordinates(g) {
nodes,
_.map(nodes, function (v) {
return _.pick(g.node(v), ['x', 'y']);
})
}),
);
}
6 changes: 3 additions & 3 deletions src/dagre/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function buildLayoutGraph(inputGraph) {
const graph = canonicalize(inputGraph.graph());

g.setGraph(
_.merge({}, graphDefaults, selectNumberAttrs(graph, graphNumAttrs), _.pick(graph, graphAttrs))
_.merge({}, graphDefaults, selectNumberAttrs(graph, graphNumAttrs), _.pick(graph, graphAttrs)),
);

_.forEach(inputGraph.nodes(), function (v) {
Expand All @@ -189,7 +189,7 @@ function buildLayoutGraph(inputGraph) {
const edge = canonicalize(inputGraph.edge(e));
g.setEdge(
e,
_.merge({}, edgeDefaults, selectNumberAttrs(edge, edgeNumAttrs), _.pick(edge, edgeAttrs))
_.merge({}, edgeDefaults, selectNumberAttrs(edge, edgeNumAttrs), _.pick(edge, edgeAttrs)),
);
});

Expand Down Expand Up @@ -421,7 +421,7 @@ function insertSelfEdges(g) {
e: selfEdge.e,
label: selfEdge.label,
},
'_se'
'_se',
);
});
delete node.selfEdges;
Expand Down
2 changes: 1 addition & 1 deletion src/dagre/nesting-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function sumWeights(g) {
function (acc, e) {
return acc + g.edge(e).weight;
},
0
0,
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dagre/order/add-subgraph-constraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export const addSubgraphConstraints = (g, cg, vs) => {
}
dfs(undefined);
*/
}
};
4 changes: 2 additions & 2 deletions src/dagre/order/barycenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const barycenter = (g, movable) => {
weight: acc.weight + edge.weight,
};
},
{ sum: 0, weight: 0 }
{ sum: 0, weight: 0 },
);

return {
Expand All @@ -26,4 +26,4 @@ export const barycenter = (g, movable) => {
};
}
});
}
};
3 changes: 1 addition & 2 deletions src/dagre/order/build-layer-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ describe('order/buildLayerGraph', function () {
g.setNode('c', { rank: 2 });
g.setNode('d', { rank: 3 });

let lg;
lg = buildLayerGraph(g, 1, 'inEdges');
const lg = buildLayerGraph(g, 1, 'inEdges');
expect(lg.hasNode(lg.graph().root));
expect(lg.children()).eqls([lg.graph().root]);
expect(lg.children(lg.graph().root)).eqls(['a', 'b']);
Expand Down
12 changes: 6 additions & 6 deletions src/dagre/order/cross-count.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('crossCount', function () {
crossCount(g, [
['a1', 'a2'],
['b1', 'b2'],
])
]),
).equals(0);
});

Expand All @@ -34,7 +34,7 @@ describe('crossCount', function () {
crossCount(g, [
['a1', 'a2'],
['b2', 'b1'],
])
]),
).equals(1);
});

Expand All @@ -45,7 +45,7 @@ describe('crossCount', function () {
crossCount(g, [
['a1', 'a2'],
['b2', 'b1'],
])
]),
).equals(6);
});

Expand All @@ -57,7 +57,7 @@ describe('crossCount', function () {
['a1', 'a2'],
['b2', 'b1'],
['c1', 'c2'],
])
]),
).equals(2);
});

Expand All @@ -71,14 +71,14 @@ describe('crossCount', function () {
['a', 'd'],
['b', 'e', 'f'],
['c', 'i'],
])
]),
).equals(1);
expect(
crossCount(g, [
['d', 'a'],
['e', 'b', 'f'],
['c', 'i'],
])
]),
).equals(0);
});
});
8 changes: 4 additions & 4 deletions src/dagre/order/cross-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ function twoLayerCrossCount(g, northLayer, southLayer) {
southLayer,
_.map(southLayer, function (v, i) {
return i;
})
}),
);
const southEntries = _.flatten(
_.map(northLayer, function (v) {
return _.sortBy(
_.map(g.outEdges(v), function (e) {
return { pos: southPos[e.w], weight: g.edge(e).weight };
}),
'pos'
'pos',
);
})
}),
);

// Build the accumulator tree
Expand Down Expand Up @@ -75,7 +75,7 @@ function twoLayerCrossCount(g, northLayer, southLayer) {
tree[index] += entry.weight;
}
cc += entry.weight * weightSum;
})
}),
);

return cc;
Expand Down
2 changes: 1 addition & 1 deletion src/dagre/order/init-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function initOrder(g) {
const maxRank = _.max(
_.map(simpleNodes, function (v) {
return g.node(v).rank;
})
}),
);
const layers = _.map(_.range(maxRank + 1), function () {
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/dagre/order/resolve-conflicts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function doResolveConflicts(sourceSet) {
}),
function (entry) {
return _.pick(entry, ['vs', 'i', 'barycenter', 'weight']);
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/dagre/order/sort-subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function expandSubgraphs(entries, subgraphs) {
return subgraphs[v].vs;
}
return v;
})
}),
);
});
}
Expand Down
7 changes: 3 additions & 4 deletions src/dagre/position/bk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ function alignCoordinates(xss, alignTo) {

_.forEach(['u', 'd'], function (vert) {
_.forEach(['l', 'r'], function (horiz) {
let alignment = vert + horiz,
xs = xss[alignment],
delta;
const alignment = vert + horiz,
xs = xss[alignment];
if (xs === alignTo) return;

const xsVals = _.values(xs);
delta = horiz === 'l' ? alignToMin - _.min(xsVals) : alignToMax - _.max(xsVals);
const delta = horiz === 'l' ? alignToMin - _.min(xsVals) : alignToMax - _.max(xsVals);

if (delta) {
xss[alignment] = _.mapValues(xs, function (x) {
Expand Down
2 changes: 1 addition & 1 deletion src/dagre/position/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function positionY(g) {
const maxHeight = _.max(
_.map(layer, function (v) {
return g.node(v).height;
})
}),
);
_.forEach(layer, function (v) {
g.node(v).y = prevY + maxHeight / 2;
Expand Down
Loading

0 comments on commit 0d46d85

Please sign in to comment.