Skip to content

Commit 75b5a02

Browse files
committed
fix(depgraph): tighten viewer rendering and simulation
1 parent d5ea785 commit 75b5a02

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎tools/depgraph-view/dominator.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ export function createDominatorAnalyzer(nodes, edges) {
66
if (kind === 0) valueOut[a].push(b);
77
}
88

9-
/**
10-
* Dominator tree of `entry` over value edges (Cooper–Harvey–Kennedy, walking reverse postorder):
11-
* every file in `d`'s dominated set stops being reachable from `entry` when `d` disappears, so
12-
* its size is the branch moving `d` behind `import()` would cut. Same query as
13-
* computeDominatorSummary, run live so any file can be the entry.
14-
*/
159
function reversePostorder(entry) {
1610
// iterative DFS -> postorder; reverse postorder is the fixpoint iteration order
1711
const post = [];
@@ -70,6 +64,12 @@ export function createDominatorAnalyzer(nodes, edges) {
7064
return idom;
7165
}
7266

67+
/**
68+
* Dominator tree of `entry` over value edges (Cooper–Harvey–Kennedy, walking reverse postorder):
69+
* every file in `d`'s dominated set stops being reachable from `entry` when `d` disappears, so
70+
* its size is the branch moving `d` behind `import()` would cut. Same query as
71+
* computeDominatorSummary, run live so any file can be the entry.
72+
*/
7373
function dominatorsOf(entry) {
7474
const order = reversePostorder(entry);
7575
const idom = immediateDominators(entry, order);

‎tools/depgraph-view/index.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@
150150
gap: 8px;
151151
padding: 3px 0;
152152
}
153-
.slider-row span {
153+
.slider-row span,
154+
.slider-row label {
154155
color: var(--muted);
155156
flex: 1;
156157
}

‎tools/depgraph-view/simulation.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export function createSimulation({ nodes, pairs, zones, hubs, zoneRect, pkgOfZone }) {
22
const sim = { alpha: 1, targetAlpha: 0.02, alphaDecay: 0.9825 };
3+
const maxRadius = nodes.reduce((max, node) => Math.max(max, node.r), 0);
4+
const cell = Math.sqrt(6) * (2 * maxRadius + 6);
35

46
function repelNode(n, m, a) {
57
if (m === n) return;
@@ -33,8 +35,6 @@ export function createSimulation({ nodes, pairs, zones, hubs, zoneRect, pkgOfZon
3335
}
3436

3537
function repelNodes(a) {
36-
const maxRadius = nodes.reduce((max, node) => Math.max(max, node.r), 0);
37-
const cell = Math.sqrt(6) * (2 * maxRadius + 6);
3838
const grid = new Map();
3939
for (const n of nodes) {
4040
const key = Math.floor(n.x / cell) + ':' + Math.floor(n.y / cell);

0 commit comments

Comments
 (0)