MCPcopy Create free account
hub / github.com/nodejs/node / placeNodes

Method placeNodes

deps/v8/tools/turbolizer/src/graph-layout.ts:192–229  ·  view source on GitHub ↗
(rankSets: Array<Array<GraphNode>>, showTypes: boolean)

Source from the content-addressed store, hash-verified

190 }
191
192 private placeNodes(rankSets: Array<Array<GraphNode>>, showTypes: boolean): void {
193 // Iterate backwards from highest to lowest rank, placing nodes so that they
194 // spread out from the "center" as much as possible while still being
195 // compact and not overlapping live input lines.
196 rankSets.reverse().forEach((rankSet: Array<GraphNode>) => {
197 for (const node of rankSet) {
198 this.layoutOccupation.clearOutputs(node, showTypes);
199 }
200
201 this.traceOccupation("After clearing outputs");
202
203 let placedCount = 0;
204 rankSet = rankSet.sort((a: GraphNode, b: GraphNode) => a.compare(b));
205 for (const node of rankSet) {
206 if (node.visible) {
207 node.x = this.layoutOccupation.occupy(node);
208 this.trace(`Node ${node.id} is placed between [${node.x}, ${node.x + node.getWidth()})`);
209 const staggeredFlooredI = Math.floor(placedCount++ % 3);
210 const delta = C.MINIMUM_EDGE_SEPARATION * staggeredFlooredI;
211 node.outputApproach += delta;
212 } else {
213 node.x = 0;
214 }
215 }
216
217 this.traceOccupation("Before clearing nodes");
218
219 this.layoutOccupation.clearOccupied();
220
221 this.traceOccupation("After clearing nodes");
222
223 for (const node of rankSet) {
224 this.layoutOccupation.occupyInputs(node, showTypes);
225 }
226
227 this.traceOccupation("After occupying inputs and determining bounding box");
228 });
229 }
230
231 private calculateBackEdgeNumbers(): void {
232 this.graph.maxBackEdgeNumber = 0;

Callers 1

fullRebuildMethod · 0.95

Calls 10

traceOccupationMethod · 0.95
traceMethod · 0.95
clearOutputsMethod · 0.80
sortMethod · 0.80
occupyMethod · 0.80
clearOccupiedMethod · 0.80
occupyInputsMethod · 0.80
forEachMethod · 0.65
compareMethod · 0.65
getWidthMethod · 0.45

Tested by

no test coverage detected