@neo4j-nvl/base 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +21 -16
- package/dist/types/layouts/animatedlayout/AnimatedLayout.d.ts +2 -2
- package/dist/types/layouts/d3forcelayout/constants.d.ts +0 -1
- package/dist/types/layouts/d3forcelayout/d3ForceLayout.d.ts +3 -3
- package/dist/types/layouts/forcedirectedlayout/PhysLayout.d.ts +275 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/ClusterByMerger.d.ts +62 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/SolarMerger.d.ts +56 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.d.ts +143 -0
- package/dist/types/layouts/forcedirectedlayout/clustering/clustering-utils.test.d.ts +1 -0
- package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger → clustering}/types.d.ts +11 -1
- package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-repulsive-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/shaders/multilevel-update-fragment.d.ts +2 -0
- package/dist/types/layouts/forcedirectedlayout/shaders/sim-vertex.d.ts +2 -0
- package/dist/types/layouts/freeLayout/FreeLayout.d.ts +2 -4
- package/dist/types/layouts/gridLayout/GridLayout.d.ts +2 -6
- package/dist/types/layouts/hierarchicallayout/HierarchicalLayout.d.ts +5 -0
- package/dist/types/modules/ExternalCallbackHandler.d.ts +3 -3
- package/dist/types/modules/NvlController.d.ts +85 -5
- package/dist/types/modules/Shader.d.ts +1 -1
- package/dist/types/modules/dataset.d.ts +4 -2
- package/dist/types/modules/state/types.d.ts +129 -27
- package/dist/types/modules/state/utils.d.ts +2 -2
- package/dist/types/renderers/ClusterOverlay.d.ts +73 -0
- package/dist/types/renderers/ClusterOverlay.test.d.ts +1 -0
- package/dist/types/renderers/domrenderer/shared/ImageCache.d.ts +1 -0
- package/dist/types/renderers/domrenderer/shared/types.d.ts +1 -2
- package/dist/types/renderers/webglrenderer/Controller.d.ts +27 -6
- package/dist/types/renderers/webglrenderer/IconLayerRegistry.d.ts +14 -0
- package/dist/types/renderers/webglrenderer/IconLayerRegistry.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +43 -3
- package/dist/types/renderers/webglrenderer/node-animation-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-animation-vertex.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-fragment-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/node-vertex-point.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/rel-fragment-line.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/rel-glsl-utils.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-arrow.d.ts +2 -0
- package/dist/types/renderers/webglrenderer/rel-vertex-line.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-fragment.d.ts +1 -1
- package/dist/types/renderers/webglrenderer/viewport-box-vertex.d.ts +1 -1
- package/dist/types/types/graph-element.d.ts +9 -1
- package/dist/types/types/nvl-window-functions.d.ts +2 -2
- package/dist/types/utils/canvasManagement.d.ts +1 -1
- package/dist/types/utils/clusterGeometry.d.ts +14 -0
- package/dist/types/utils/clusterGeometry.test.d.ts +1 -0
- package/dist/types/utils/clusterHitRegions.d.ts +42 -0
- package/dist/types/utils/clusterHitRegions.test.d.ts +1 -0
- package/dist/types/utils/constants.d.ts +6 -0
- package/dist/types/utils/geometry.d.ts +44 -1
- package/dist/types/utils/hittest.d.ts +30 -4
- package/dist/types/utils/jsDriverResultTransformer.d.ts +11 -9
- package/dist/types/utils/layoutSeeding.d.ts +7 -0
- package/dist/types/utils/layoutSeeding.test.d.ts +1 -0
- package/dist/types/utils/webWorkerUtils.d.ts +1 -1
- package/dist/types/utils/zoomFunctions.d.ts +9 -2
- package/package.json +3 -3
- package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +0 -22
- package/dist/types/layouts/forcedirectedlayout/cosebilkentlayout/CoseBilkentLayout.d.ts +0 -33
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +0 -174
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-update-fragment.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/sim-vertex.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/workaround-fragment.d.ts +0 -2
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +0 -21
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +0 -2
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/PhysLayout.test.d.ts → PhysLayout.test.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/SolarMerger.bench.d.ts → clustering/ClusterByMerger.test.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/SolarMerger.test.d.ts → clustering/SolarMerger.bench.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/solarmerger/solar-placer.test.d.ts → clustering/SolarMerger.test.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/glwrapper.d.ts → glwrapper.d.ts} +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
|
|
2
|
-
import type { CircularOptions, ForceDirectedOptions, HierarchicalOptions, Renderer as InternalRenderer, Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './modules/state/types';
|
|
2
|
+
import type { CircularOptions, Cluster, ClusterByFn, ClusterId, ClusteringOptions, ForceDirectedOptions, HierarchicalOptions, Renderer as InternalRenderer, Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './modules/state/types';
|
|
3
3
|
import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, SvgRendererType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
|
|
4
4
|
import { drawCircleBand } from './renderers/domrenderer/canvasrenderer/nodeDrawing';
|
|
5
5
|
import type { StyledCaption } from './renderers/domrenderer/shared/types';
|
|
6
|
-
import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
|
|
6
|
+
import type { Node, NodeWithClientPosition, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
|
|
7
7
|
import { CompatibilityError } from './utils/errors';
|
|
8
8
|
import type { Point } from './utils/geometry';
|
|
9
|
-
import type { HitTargetNode, HitTargetRelationship, HitTargets } from './utils/hittest';
|
|
9
|
+
import type { HitTargetCluster, HitTargetNode, HitTargetRelationship, HitTargets, HitTestTarget } from './utils/hittest';
|
|
10
10
|
import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
|
|
11
11
|
import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
|
|
12
12
|
/**
|
|
@@ -139,9 +139,10 @@ declare class NVL {
|
|
|
139
139
|
removeRelationshipsWithIds(relationshipIds: string[]): void;
|
|
140
140
|
/**
|
|
141
141
|
* Returns all nodes that is currently stored in the visualisation.
|
|
142
|
-
*
|
|
142
|
+
* Each node includes layout coordinates (`x`, `y`) and a `clientPosition` in screen space.
|
|
143
|
+
* @returns The array of {@link NodeWithClientPosition nodes}.
|
|
143
144
|
*/
|
|
144
|
-
getNodes():
|
|
145
|
+
getNodes(): NodeWithClientPosition[];
|
|
145
146
|
/**
|
|
146
147
|
* Returns the relationships that are currently in the visualization.
|
|
147
148
|
* @returns An array of the {@link Relationship relationships} in the visualization.
|
|
@@ -178,7 +179,7 @@ declare class NVL {
|
|
|
178
179
|
*/
|
|
179
180
|
deselectAll(): void;
|
|
180
181
|
/**
|
|
181
|
-
* Updates pan and zoom fit the specified nodes in the viewport.
|
|
182
|
+
* Updates pan and zoom to fit the specified nodes in the viewport.
|
|
182
183
|
* @param nodeIds - The ids of the nodes to fit on the screen.
|
|
183
184
|
* @param zoomOptions - Specific options on how to transition the zoom.
|
|
184
185
|
*
|
|
@@ -298,11 +299,15 @@ declare class NVL {
|
|
|
298
299
|
*
|
|
299
300
|
* @example
|
|
300
301
|
* ```typescript
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
302
|
+
* import { NVL } from '@neo4j-nvl/base'
|
|
303
|
+
*
|
|
304
|
+
* const nvl = new NVL(document.getElementById('frame'), [{ id: '0' }], [])
|
|
305
|
+
* const renderSvg = async () => {
|
|
306
|
+
* const svgDataUrl = await nvl.getSvgDataUrl({ backgroundColor: '#ffffff' })
|
|
307
|
+
* const img = document.createElement('img')
|
|
308
|
+
* img.src = svgDataUrl
|
|
309
|
+
* document.body.appendChild(img)
|
|
310
|
+
* }
|
|
306
311
|
* ```
|
|
307
312
|
*/
|
|
308
313
|
getSvgDataUrl(options?: {
|
|
@@ -373,12 +378,12 @@ declare class NVL {
|
|
|
373
378
|
*/
|
|
374
379
|
getPan(): Point;
|
|
375
380
|
/**
|
|
376
|
-
* Gets the nodes and
|
|
381
|
+
* Gets the nodes, relationships, and clusters that have been hit by a pointer event.
|
|
377
382
|
* @param evt - The mouse event.
|
|
378
|
-
* @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship'].
|
|
383
|
+
* @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship', 'cluster'].
|
|
379
384
|
* @param hitOptions - Options for the hit test.
|
|
380
385
|
* @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
|
|
381
|
-
* containing the nodes and
|
|
386
|
+
* containing the nodes, relationships, and clusters that have been hit by the pointer event.
|
|
382
387
|
*
|
|
383
388
|
* @example
|
|
384
389
|
* ```js
|
|
@@ -392,7 +397,7 @@ declare class NVL {
|
|
|
392
397
|
* })
|
|
393
398
|
* ```
|
|
394
399
|
*/
|
|
395
|
-
getHits(evt: MouseEvent, targets?:
|
|
400
|
+
getHits(evt: MouseEvent, targets?: HitTestTarget[], hitOptions?: {
|
|
396
401
|
hitNodeMarginWidth: number;
|
|
397
402
|
}): NvlMouseEvent;
|
|
398
403
|
/**
|
|
@@ -415,5 +420,5 @@ declare const colorMapperFunctions: {
|
|
|
415
420
|
*/
|
|
416
421
|
type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
|
|
417
422
|
export default NVL;
|
|
418
|
-
export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
423
|
+
export type { NvlOptions, Renderer, Node, NodeWithClientPosition, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, ClusteringOptions, Cluster, ClusterByFn, ClusterId, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, HitTargetCluster, HitTestTarget, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
419
424
|
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NvlState } from '../../modules/state/types';
|
|
2
|
-
import type { Node } from '../../types/graph-element';
|
|
2
|
+
import type { Node, PartialNode } from '../../types/graph-element';
|
|
3
3
|
export default class AnimatedLayout {
|
|
4
4
|
positions: Record<string, Node>;
|
|
5
5
|
oldPositions: Record<string, Node>;
|
|
@@ -20,6 +20,6 @@ export default class AnimatedLayout {
|
|
|
20
20
|
updateOldPositionFromState(): void;
|
|
21
21
|
startAnimation(): void;
|
|
22
22
|
update(): void;
|
|
23
|
-
updateNodes(positionList:
|
|
23
|
+
updateNodes(positionList: PartialNode[]): void;
|
|
24
24
|
getNodePositions(nodeList: Node[]): Node[];
|
|
25
25
|
}
|
|
@@ -12,7 +12,6 @@ export declare const BARNES_HUT_THETA = 1.2;
|
|
|
12
12
|
export declare const FORCE_LINK_DISTANCE: (relationship: SimulationLinkDatum<D3Node>) => number;
|
|
13
13
|
export declare const FORCE_LINK_STRENGTH: (link: SimulationLinkDatum<SimulationNodeDatum>, count: number[]) => number;
|
|
14
14
|
export declare const FORCE_COLLIDE_RADIUS: (node: D3Node) => number;
|
|
15
|
-
export declare const LAYOUT_RADIUS: (numberOfNodes: number) => number;
|
|
16
15
|
export declare const FORCE_CHARGE: () => number;
|
|
17
16
|
export declare const FORCE_CHARGE_START: () => number;
|
|
18
17
|
export declare const FORCE_CENTER_X = 0.03;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Simulation, SimulationLinkDatum, SimulationNodeDatum } from 'd3-force';
|
|
2
2
|
import type { NvlState } from '../../modules/state/types';
|
|
3
|
-
import type { Node, Relationship } from '../../types/graph-element';
|
|
4
|
-
import type
|
|
3
|
+
import type { Node, PartialNode, Relationship } from '../../types/graph-element';
|
|
4
|
+
import { type Point } from '../../utils/geometry';
|
|
5
5
|
import type { D3Node } from './types';
|
|
6
6
|
export declare class D3ForceLayout {
|
|
7
7
|
state: NvlState;
|
|
@@ -20,7 +20,7 @@ export declare class D3ForceLayout {
|
|
|
20
20
|
state: NvlState;
|
|
21
21
|
});
|
|
22
22
|
setOptions(options: any): void;
|
|
23
|
-
updateNodes(positionList:
|
|
23
|
+
updateNodes(positionList: PartialNode[]): void;
|
|
24
24
|
update(refreshPositions?: boolean): void;
|
|
25
25
|
layout(_nodes: Node[], _rels: Relationship[], firstTimeAddingNodes: boolean): void;
|
|
26
26
|
getNodePositions(nodeList: D3Node[]): any[];
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import type { ForceDirectedOptions, NvlState } from '../../modules/state/types';
|
|
2
|
+
import type { Node, PartialNode, Relationship } from '../../types/graph-element';
|
|
3
|
+
import { type ClusterHitRegion } from '../../utils/clusterHitRegions';
|
|
4
|
+
import { type Point } from '../../utils/geometry';
|
|
5
|
+
import type { CoarsenedGraph } from './clustering/types';
|
|
6
|
+
/**
|
|
7
|
+
* Collision multipliers below this are floored to 0, which makes the shader skip its
|
|
8
|
+
* all-pairs collision loop. Every fine-level force in that loop is scaled by the same
|
|
9
|
+
* multiplier, so at this strength they move nothing worth the O(n^2) cost.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CollisionMultiplierSkipThreshold = 0.05;
|
|
12
|
+
export declare const ConvergenceCheckInterval = 20;
|
|
13
|
+
/**
|
|
14
|
+
* Number of consecutive convergence checks that must report a below-threshold
|
|
15
|
+
* graph speed before the layout is considered settled. This debounces a single
|
|
16
|
+
* lucky-low reading so a still-moving graph isn't stopped prematurely.
|
|
17
|
+
*/
|
|
18
|
+
export declare const StableChecksToConverge = 3;
|
|
19
|
+
export declare class PhysLayout {
|
|
20
|
+
private physVbo;
|
|
21
|
+
private physSmallVbo;
|
|
22
|
+
private physProjection;
|
|
23
|
+
private physSmallProjection;
|
|
24
|
+
private gl;
|
|
25
|
+
private averageNodeSize;
|
|
26
|
+
private shouldUpdate;
|
|
27
|
+
private iterationCount;
|
|
28
|
+
private nodeVariation;
|
|
29
|
+
private nodeCenterPoint;
|
|
30
|
+
private peakIterationMultiplier;
|
|
31
|
+
private stateDisposers;
|
|
32
|
+
private state;
|
|
33
|
+
private dpr;
|
|
34
|
+
private maxGlNodeSize;
|
|
35
|
+
private simulationStopVelocitySquared;
|
|
36
|
+
private gravity;
|
|
37
|
+
private force;
|
|
38
|
+
private nodeIdToIndex;
|
|
39
|
+
private nodeIndexToId;
|
|
40
|
+
private flatRelationshipKeys;
|
|
41
|
+
private numNodes;
|
|
42
|
+
private subGraphs;
|
|
43
|
+
private firstUpdate;
|
|
44
|
+
private curPhysData;
|
|
45
|
+
private apprxRepForceShader;
|
|
46
|
+
private levelsClusterTexture;
|
|
47
|
+
private levelsFinestIndexTexture;
|
|
48
|
+
private initalLevelTexture;
|
|
49
|
+
private levelsData;
|
|
50
|
+
private collisionDetectionMultiplier;
|
|
51
|
+
private physShader;
|
|
52
|
+
private physData;
|
|
53
|
+
private pinData;
|
|
54
|
+
private updateData;
|
|
55
|
+
private updateShader;
|
|
56
|
+
private physPositions;
|
|
57
|
+
private physDirty;
|
|
58
|
+
private positionsCacheVersion;
|
|
59
|
+
private convergencePbo;
|
|
60
|
+
private convergenceFence;
|
|
61
|
+
private convergenceSnapshot;
|
|
62
|
+
private readonly cpuWritesSinceAsyncReadback;
|
|
63
|
+
private hadSyncReadback;
|
|
64
|
+
private graphIsStableCount;
|
|
65
|
+
private springTexture;
|
|
66
|
+
private sizeTexture;
|
|
67
|
+
private offsetTexture;
|
|
68
|
+
private pinTexture;
|
|
69
|
+
private addedNodes;
|
|
70
|
+
private seedingMethod;
|
|
71
|
+
private clusterBy?;
|
|
72
|
+
private crossClusterRelationshipMultiplier;
|
|
73
|
+
private lastClusterByAssignments;
|
|
74
|
+
private lastClusterIdsBySun;
|
|
75
|
+
private sunMap;
|
|
76
|
+
private cachedClusterHitRegions;
|
|
77
|
+
private cachedClusterHitRegionsVersion;
|
|
78
|
+
private updateTexture;
|
|
79
|
+
private physVao;
|
|
80
|
+
private physSmallVao;
|
|
81
|
+
private updateVao;
|
|
82
|
+
constructor(config: ForceDirectedOptions & {
|
|
83
|
+
webGLContext: WebGL2RenderingContext;
|
|
84
|
+
state: NvlState;
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Sets the layout options.
|
|
88
|
+
* @param options - The object with the options.
|
|
89
|
+
* @param initial - Whether this is the first setting of options.
|
|
90
|
+
*/
|
|
91
|
+
setOptions(options?: ForceDirectedOptions, initial?: boolean): void;
|
|
92
|
+
private applyClusteringOptions;
|
|
93
|
+
private applyCrossClusterMultiplier;
|
|
94
|
+
private applyClusterBy;
|
|
95
|
+
private wakeLayout;
|
|
96
|
+
private coarsenGraph;
|
|
97
|
+
/**
|
|
98
|
+
* Sets graph data to be used
|
|
99
|
+
* @param {{ nodes: Node[]; rels: Relationship[] }} data the graph object
|
|
100
|
+
* @returns The top level graph of the subgraphs created by the solar merger.
|
|
101
|
+
*/
|
|
102
|
+
setData(data: {
|
|
103
|
+
nodes: Node[];
|
|
104
|
+
rels: Relationship[];
|
|
105
|
+
}): CoarsenedGraph;
|
|
106
|
+
/**
|
|
107
|
+
* Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
|
|
108
|
+
* @param refreshPositions whether the entire layout should be reheated
|
|
109
|
+
* @returns Whether the layout should update in the following step.
|
|
110
|
+
*/
|
|
111
|
+
update(refreshPositions?: boolean): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Stops the layout
|
|
114
|
+
*/
|
|
115
|
+
terminateUpdate(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Synchronously reads the latest node positions/velocities from the GPU into
|
|
118
|
+
* this.physPositions.
|
|
119
|
+
*/
|
|
120
|
+
private readbackPositions;
|
|
121
|
+
/**
|
|
122
|
+
* Drives the convergence-readback state machine for the current iteration:
|
|
123
|
+
* consumes a pending fence if one is ready, otherwise starts a new readback
|
|
124
|
+
* when a convergence check is due.
|
|
125
|
+
* @returns Whether fresh velocity data is available.
|
|
126
|
+
*/
|
|
127
|
+
private tryConsumeConvergenceReadback;
|
|
128
|
+
/**
|
|
129
|
+
* The GPU texture holding the latest node positions (xy) and velocities (zw).
|
|
130
|
+
* @returns The RGBA32F position texture.
|
|
131
|
+
*
|
|
132
|
+
* @note Texel layout matches the WebGL renderer's `u_positions` sampler, so it
|
|
133
|
+
* can be bound directly to webgl renderer.
|
|
134
|
+
*/
|
|
135
|
+
getPositionTexture(): WebGLTexture;
|
|
136
|
+
/**
|
|
137
|
+
* Maps node id to its texel index in the position texture.
|
|
138
|
+
* @returns The node-id-to-texel-index map.
|
|
139
|
+
*
|
|
140
|
+
* @note This is the coarsening / solar-hierarchy order (re-derived on add/remove), which
|
|
141
|
+
* differs from the renderer's insertion order. Consumers rendering from {@link getPositionTexture}
|
|
142
|
+
* must build their sampling indices from this.
|
|
143
|
+
*/
|
|
144
|
+
getNodeTexelIndices(): Readonly<Record<Node['id'], number>>;
|
|
145
|
+
/**
|
|
146
|
+
* Multilevel coarsening hierarchy produced by {@link SolarMerger} / {@link ClusterByMerger}.
|
|
147
|
+
* @returns The coarsened graph hierarchy.
|
|
148
|
+
* @see {@link CoarsenedGraph}
|
|
149
|
+
*/
|
|
150
|
+
getSubGraphs(): CoarsenedGraph[];
|
|
151
|
+
/**
|
|
152
|
+
* Fitted convex-hull hit regions for multi-member {@link ClusteringOptions.clusterBy} clusters.
|
|
153
|
+
* Results are cached against {@link getPositionsCacheVersion}.
|
|
154
|
+
* @returns Cluster hit regions, or an empty array when clustering is inactive.
|
|
155
|
+
*/
|
|
156
|
+
getClusterByHitRegions(): ClusterHitRegion[];
|
|
157
|
+
private shouldCheckConvergence;
|
|
158
|
+
/** Allocates the pixel-pack buffer used for the async convergence readback. */
|
|
159
|
+
private setupConvergencePbo;
|
|
160
|
+
/**
|
|
161
|
+
* Kicks off an async copy of the position texture into the pixel-pack buffer
|
|
162
|
+
* and fences it. Only issued when no readback is already in flight.
|
|
163
|
+
*/
|
|
164
|
+
private issueConvergenceReadback;
|
|
165
|
+
/**
|
|
166
|
+
* Polls the in-flight fence without blocking; if the readback is ready,
|
|
167
|
+
* copies it into physPositions and clears the fence.
|
|
168
|
+
* @returns Whether fresh velocity data was consumed this call.
|
|
169
|
+
*/
|
|
170
|
+
private consumeConvergenceReadback;
|
|
171
|
+
private restoreCpuWrittenPositions;
|
|
172
|
+
/** Drops any in-flight readback fence (on stop, reset, or destroy). */
|
|
173
|
+
private cancelConvergenceReadback;
|
|
174
|
+
/**
|
|
175
|
+
* Returns whether the current layout needs to be updated in the next iteration step.
|
|
176
|
+
* @returns Whether the layout should update in the following step.
|
|
177
|
+
*/
|
|
178
|
+
getShouldUpdate(): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Returns whether the current layout is computing.
|
|
181
|
+
* Always returns false because the force-directed layout has no computing step.
|
|
182
|
+
* @returns Whether the layout is computing.
|
|
183
|
+
*/
|
|
184
|
+
getComputing(): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Version of the CPU position cache. Advances on GPU readback, CPU-mirror
|
|
187
|
+
* writes, and physics buffer reset.
|
|
188
|
+
* @returns The current cache version.
|
|
189
|
+
*/
|
|
190
|
+
getPositionsCacheVersion(): number;
|
|
191
|
+
/**
|
|
192
|
+
* Adds the current x,y coordinates for each node to a given list of nodes.
|
|
193
|
+
* Forces a synchronous GPU readback when the cache is dirty.
|
|
194
|
+
* @param nodeList - The list of nodes to get positions for.
|
|
195
|
+
* @returns The list of nodes containing the x,y coordinates on each node object.
|
|
196
|
+
*/
|
|
197
|
+
getNodePositions(nodeList: Node[]): (Node & Point)[];
|
|
198
|
+
/**
|
|
199
|
+
* Maps {@link physPositions} onto a node list without forcing a GPU readback.
|
|
200
|
+
* Positions may lag behind the live GPU texture until the next sync/async refresh.
|
|
201
|
+
* @param nodeList - The list of nodes to get positions for.
|
|
202
|
+
* @returns The list of nodes containing the cached x,y coordinates.
|
|
203
|
+
*/
|
|
204
|
+
getCachedNodePositions(nodeList: Node[]): (Node & Point)[];
|
|
205
|
+
/**
|
|
206
|
+
* Reheats the layout
|
|
207
|
+
* @param fullData - The entire graph object.
|
|
208
|
+
*/
|
|
209
|
+
reheat(fullData: {
|
|
210
|
+
nodes: Node[];
|
|
211
|
+
rels?: Relationship[];
|
|
212
|
+
}): void;
|
|
213
|
+
/**
|
|
214
|
+
* Updates the existing nodes of a graph with a given list of updates
|
|
215
|
+
* @param nodeList - The list of updates.
|
|
216
|
+
*/
|
|
217
|
+
updateNodes(nodeList: PartialNode[]): void;
|
|
218
|
+
/**
|
|
219
|
+
* Writes a node position into the current phys position texture and CPU mirror.
|
|
220
|
+
* Caller must bind {@link getPositionTexture} first.
|
|
221
|
+
*/
|
|
222
|
+
private writePhysPosition;
|
|
223
|
+
/**
|
|
224
|
+
* Adds and removes nodes from the graph based on given updates
|
|
225
|
+
* @param fullData - The entire graph object.
|
|
226
|
+
* @param fullData.nodes - The nodes in the graph.
|
|
227
|
+
* @param fullData.rels - The relationships in the graph.
|
|
228
|
+
* @param nodeChanges - The changes in the graph.
|
|
229
|
+
* @param nodeChanges.adds - A list of nodes to be added.
|
|
230
|
+
* @param nodeChanges.removes - A list of nodes to be removed.
|
|
231
|
+
*/
|
|
232
|
+
addRemoveData(fullData: {
|
|
233
|
+
nodes: Node[];
|
|
234
|
+
rels: Relationship[];
|
|
235
|
+
}, nodeChanges: {
|
|
236
|
+
adds: Record<string, Node>;
|
|
237
|
+
removes: Record<string, Node>;
|
|
238
|
+
}, relationshipChanges: {
|
|
239
|
+
adds: Record<string, Relationship>;
|
|
240
|
+
removes: Record<string, Relationship>;
|
|
241
|
+
}): CoarsenedGraph;
|
|
242
|
+
/**
|
|
243
|
+
* Destroys the class and all buffers and textures.
|
|
244
|
+
*/
|
|
245
|
+
destroy(): void;
|
|
246
|
+
/**
|
|
247
|
+
* Takes the new flat key set of relationships and the current relationship changes
|
|
248
|
+
* and checks whether removed relationships are still in the new flat key set.
|
|
249
|
+
* and whether added relationships were already in the old flat key set.
|
|
250
|
+
* @param newFlatKeySet The new flat key set of relationships.
|
|
251
|
+
* @param relationshipChanges The changes in the relationships.
|
|
252
|
+
* @returns Whether the relationship flat map has changed.
|
|
253
|
+
*/
|
|
254
|
+
private hasRelationshipFlatMapChanged;
|
|
255
|
+
private dumpTexture;
|
|
256
|
+
private getScaleNumber;
|
|
257
|
+
private getBaseLength;
|
|
258
|
+
private checkForUpdates;
|
|
259
|
+
private getNodePosition;
|
|
260
|
+
private getMaxSpeedSquared;
|
|
261
|
+
private getPhysData;
|
|
262
|
+
private newTexture;
|
|
263
|
+
private newFramebuffer;
|
|
264
|
+
private checkCompatibility;
|
|
265
|
+
private printGlStats;
|
|
266
|
+
private adjustToGlSize;
|
|
267
|
+
private setupSize;
|
|
268
|
+
private setupSprings;
|
|
269
|
+
private setupPhysics;
|
|
270
|
+
private setupPhysicsForNodes;
|
|
271
|
+
private setupPhysicsForCoarse;
|
|
272
|
+
private setupPinData;
|
|
273
|
+
private setupUpdates;
|
|
274
|
+
private definePhysicsArrays;
|
|
275
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ClusterByFn, ClusterId } from '../../../modules/state/types';
|
|
2
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
|
+
import type { CoarsenedGraph } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Default value for {@link ForceDirectedOptions.crossClusterRelationshipMultiplier}.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_CROSS_CLUSTER_RELATIONSHIP_MULTIPLIER = 0;
|
|
8
|
+
/**
|
|
9
|
+
* Builds a two-level Sun/Planet hierarchy from semantic cluster identifiers.
|
|
10
|
+
* Nodes sharing the same cluster id become planets orbiting a new synthetic cluster sun.
|
|
11
|
+
* Nodes without a cluster id remain independent suns.
|
|
12
|
+
*/
|
|
13
|
+
export default class ClusterByMerger {
|
|
14
|
+
subGraphs: CoarsenedGraph[];
|
|
15
|
+
sunMap: Record<string, string>;
|
|
16
|
+
memberMap: Record<string, string[]>;
|
|
17
|
+
relIdMap: string[][];
|
|
18
|
+
clusterAssignments: Map<string, ClusterId | undefined>;
|
|
19
|
+
clusterIdsBySun: Map<string, ClusterId>;
|
|
20
|
+
private nodeSortMap;
|
|
21
|
+
/**
|
|
22
|
+
* Coarsens the input graph into a property-based solar hierarchy.
|
|
23
|
+
* @param inputGraph - The nodes and relationships to coarsen.
|
|
24
|
+
* @param nodeIdToIndex - Maps node ids to contiguous array indices.
|
|
25
|
+
* @param clusterBy - Returns a cluster id for each node, or undefined for independent nodes.
|
|
26
|
+
*/
|
|
27
|
+
constructor(inputGraph: {
|
|
28
|
+
nodes: Node[];
|
|
29
|
+
rels: Relationship[];
|
|
30
|
+
}, nodeIdToIndex: Record<string, number>, clusterBy: ClusterByFn);
|
|
31
|
+
/**
|
|
32
|
+
* Clones the finest adjacency and adds an undirected "star" edge from each cluster member to its
|
|
33
|
+
* Sun, skipping any pair already connected by a real edge.
|
|
34
|
+
* Layout-only: fed to the spring solver, never written back into the real
|
|
35
|
+
* adjacency and never rendered.
|
|
36
|
+
* @param suns - The cluster suns, each with its planets, post-sort.
|
|
37
|
+
* @param finestRelationships - The finest-level real adjacency (sorted index space).
|
|
38
|
+
* @returns A cloned adjacency augmented with intra-cluster star edges.
|
|
39
|
+
*/
|
|
40
|
+
private buildClusterSpringRelationships;
|
|
41
|
+
/**
|
|
42
|
+
* Groups node indices into buckets by cluster id, preserving first-seen order.
|
|
43
|
+
* Nodes without a cluster id each get their own single-node bucket.
|
|
44
|
+
* @param nodes - Input graph nodes indexed by position.
|
|
45
|
+
* @param clusterBy - Returns a cluster id for each node, or undefined for independent nodes.
|
|
46
|
+
* @returns Arrays of node indices, one bucket per cluster or independent node.
|
|
47
|
+
*/
|
|
48
|
+
private groupNodesByCluster;
|
|
49
|
+
/**
|
|
50
|
+
* Converts cluster buckets into a Sun/Planet hierarchy for the first coarsening level.
|
|
51
|
+
* Each bucket with more than one node gets a synthetic Sun and the members become its planets.
|
|
52
|
+
* Single-member buckets keep the real node as Sun.
|
|
53
|
+
* @param buckets - Node index groups produced by {@link groupNodesByCluster}.
|
|
54
|
+
* @param nodes - Input graph nodes indexed by position.
|
|
55
|
+
* @param solarNodes - Solar nodes to extend with synth suns.
|
|
56
|
+
* @param relationships - Adjacency lists to extend with rows for synth suns.
|
|
57
|
+
* @param relIdMap - Relationship id lists to extend with rows for synth suns.
|
|
58
|
+
* @returns Cluster suns, index maps for node-sun and relationship ids and
|
|
59
|
+
* copies of solar nodes / adjacency / rel id lists with synth suns appended.
|
|
60
|
+
*/
|
|
61
|
+
private buildPropertyHierarchy;
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
|
+
import type { CoarsenedGraph, SolarRelationship } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Coarsens a graph into a hierarchy of "solar systems", following the sun/planet/moon partitioning scheme from
|
|
5
|
+
* Hachul and Jünger, "Drawing Large Graphs with a Potential-Field-Based Multilevel Algorithm".
|
|
6
|
+
*
|
|
7
|
+
* @see {@link https://kups.ub.uni-koeln.de/1409/ Drawing Large Graphs with a Potential-Field-Based Multilevel Algorithm}
|
|
8
|
+
*/
|
|
9
|
+
export default class SolarMerger {
|
|
10
|
+
graph: {
|
|
11
|
+
nodes: Node[];
|
|
12
|
+
relationships: number[][];
|
|
13
|
+
idToRel: Record<string, SolarRelationship>;
|
|
14
|
+
};
|
|
15
|
+
subGraphs: CoarsenedGraph[];
|
|
16
|
+
sunMap: Record<string, string>;
|
|
17
|
+
memberMap: Record<string, string[]>;
|
|
18
|
+
relIdMap: string[][];
|
|
19
|
+
nodeSortMap?: Record<number, number>;
|
|
20
|
+
constructor(inputGraph: {
|
|
21
|
+
nodes: Node[];
|
|
22
|
+
rels: Relationship[];
|
|
23
|
+
}, nodeIdToIndex: Record<string, number>);
|
|
24
|
+
/**
|
|
25
|
+
* Repeatedly coarsens the graph, one solar-system level at a time, until it has at most `targetSize` nodes or
|
|
26
|
+
* cannot be coarsened further. Each level's result is recorded in {@link SolarMerger.subGraphs}.
|
|
27
|
+
*
|
|
28
|
+
* @param targetSize - The node count to coarsen down to.
|
|
29
|
+
* @returns The coarsest graph reached.
|
|
30
|
+
*/
|
|
31
|
+
coarsenTo(targetSize: number): CoarsenedGraph;
|
|
32
|
+
/**
|
|
33
|
+
* Repeatedly coarsens the graph by exactly `levelToCoarsenBy` solar-system levels, regardless of the resulting
|
|
34
|
+
* node count. Each level's result is recorded in {@link SolarMerger.subGraphs}.
|
|
35
|
+
*
|
|
36
|
+
* @param levelToCoarsenBy - The number of levels to coarsen by.
|
|
37
|
+
* @returns The coarsest graph reached.
|
|
38
|
+
*/
|
|
39
|
+
coarsenBy(levelToCoarsenBy: number): CoarsenedGraph;
|
|
40
|
+
/**
|
|
41
|
+
* Partitions `graph` into one level of solar systems and collapses each into a single node, producing the next
|
|
42
|
+
* coarser graph.
|
|
43
|
+
*
|
|
44
|
+
* Follows the three-step solar-system construction from Hachul and Jünger, "Drawing Large Graphs with a
|
|
45
|
+
* Potential-Field-Based Multilevel Algorithm" (create suns, label their neighbors as planets, assign
|
|
46
|
+
* remaining nodes as moons of their nearest planet).
|
|
47
|
+
*
|
|
48
|
+
* @param graph - The graph to coarsen by one level.
|
|
49
|
+
* @param firstIteration - Whether `graph` is the original, uncoarsened input graph.
|
|
50
|
+
* @returns The collapsed graph (`output`), the input graph with nodes reordered by solar system (`sortedInput`),
|
|
51
|
+
* and a map from the input graph's node ids to their position in `sortedInput` (`nodeSortMap`).
|
|
52
|
+
* @see {@link https://kups.ub.uni-koeln.de/1409/ Drawing Large Graphs with a Potential-Field-Based Multilevel Algorithm}
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
private coarsen;
|
|
56
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
|
+
import type { CoarsenedGraph, PartialPlanet, PartialSun, SolarNode, SolarRelationship, Sun } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the original node ids belonging to a sun and its planets and moons.
|
|
5
|
+
* @param sun - The sun to get the original node ids for.
|
|
6
|
+
* @returns The original node ids belonging to the sun system.
|
|
7
|
+
*
|
|
8
|
+
* @note Synthetic suns are not included in the returned array.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSunSystemOriginalIds: (sun: Sun) => string[];
|
|
11
|
+
/**
|
|
12
|
+
* How many times a node's degree must exceed the graph's average degree before it is treated as a hub, see
|
|
13
|
+
* {@link isHub}.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Mi et al., "Interactive Graph Layout of a Million Nodes", Sec. 4.3, proposes capping cluster *size* to avoid
|
|
17
|
+
* the outlier clusters this multiplier targets. `HubDegreeMultiplier` targets this problem by checking a node's
|
|
18
|
+
* own degree at claim time, before moon-matching runs.
|
|
19
|
+
* @see {@link https://www.mdpi.com/2227-9709/3/4/23 Interactive Graph Layout of a Million Nodes} Sec. 4.3
|
|
20
|
+
*/
|
|
21
|
+
export declare const HubDegreeMultiplier = 3;
|
|
22
|
+
/**
|
|
23
|
+
* @param relationships - The graph's adjacency list, indexed by node id.
|
|
24
|
+
* @returns The degree a node must exceed to be treated as a hub by {@link isHub}.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getHubDegreeThreshold: (relationships: number[][]) => number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a node's degree is enough of an outlier that it must become its own sun rather than being absorbed as
|
|
29
|
+
* a planet/moon of another sun.
|
|
30
|
+
*
|
|
31
|
+
* @param index - The node id to check.
|
|
32
|
+
* @param relationships - The graph's adjacency list, indexed by node id.
|
|
33
|
+
* @param hubDegreeThreshold - The threshold from {@link getHubDegreeThreshold}.
|
|
34
|
+
* @see {@link HubDegreeMultiplier}
|
|
35
|
+
*/
|
|
36
|
+
export declare const isHub: (index: number, relationships: number[][], hubDegreeThreshold: number) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Builds adjacency lists and relationship id maps from the input graph.
|
|
39
|
+
* @param inputGraph - The nodes and relationships to convert.
|
|
40
|
+
* @param nodeIdToIndex - Maps node ids to contiguous array indices.
|
|
41
|
+
* @returns Parsed adjacency data for coarsening.
|
|
42
|
+
*/
|
|
43
|
+
export declare const buildAdjacencyGraph: (inputGraph: {
|
|
44
|
+
nodes: Node[];
|
|
45
|
+
rels: Relationship[];
|
|
46
|
+
}, nodeIdToIndex: Record<string, number>) => {
|
|
47
|
+
nodes: Node[];
|
|
48
|
+
relationships: number[][];
|
|
49
|
+
relIdMap: string[][];
|
|
50
|
+
idToRel: Record<string, SolarRelationship>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Wraps input nodes as {@link SolarNode}s indexed by their original position.
|
|
54
|
+
* @param nodes - The input graph nodes.
|
|
55
|
+
* @returns {SolarNode[]} Solar nodes with positional ids and original ids preserved.
|
|
56
|
+
*/
|
|
57
|
+
export declare const createSolarNodesFromInput: (nodes: Node[]) => SolarNode[];
|
|
58
|
+
/**
|
|
59
|
+
* Creates a Planet with an unsettled parent link (caller must attach via {@link attachPlanetsToSun}).
|
|
60
|
+
*/
|
|
61
|
+
export declare const createPlanet: (params: {
|
|
62
|
+
id: number;
|
|
63
|
+
sunId: number;
|
|
64
|
+
weight: number;
|
|
65
|
+
originalId: string;
|
|
66
|
+
finestIndex?: number;
|
|
67
|
+
size?: () => number;
|
|
68
|
+
}) => PartialPlanet;
|
|
69
|
+
/**
|
|
70
|
+
* Finalises a sun's planets list, weight/size/children closures, and back-links parent on each planet.
|
|
71
|
+
* @param partialSun - The sun under construction (planets/size/children/weight not yet set).
|
|
72
|
+
* @param planets - The planets to attach to the sun (parent not yet set).
|
|
73
|
+
* @param centreWeight - The weight of the sun itself, added to the sum of its planets' weights.
|
|
74
|
+
* @param centreSize - The size of the sun itself, added to the sum of its planets' sizes.
|
|
75
|
+
* @returns A new sun object with planets attached. `previousIndex` is a placeholder until
|
|
76
|
+
* {@link sortHierarchyForShaderLayout} assigns the real value.
|
|
77
|
+
*/
|
|
78
|
+
export declare const attachPlanetsToSun: (partialSun: PartialSun, planets: PartialPlanet[], centreWeight: number, centreSize: number) => Sun;
|
|
79
|
+
/**
|
|
80
|
+
* Appends a synthetic sun node to the finest-level arrays for a multi-member clusterBy cluster.
|
|
81
|
+
* Uses a reserved {@link SolarNode.originalId} (`synth-sun:${clusterId}`) so it cannot collide with
|
|
82
|
+
* real node ids; {@link SolarNode.synthetic} marks it for detection.
|
|
83
|
+
* @param params.clusterId - Semantic cluster id embedded in the synth sun's stable originalId.
|
|
84
|
+
* @param params.solarNodesWithSynths - Finest solar nodes; the synth sun is appended here.
|
|
85
|
+
* @param params.relationshipsWithSynths - Finest adjacency lists; an empty row is appended for the synth sun.
|
|
86
|
+
* @param params.relIdMapWithSynths - Finest relationship id lists; an empty row is appended for the synth sun.
|
|
87
|
+
* @returns A sun under construction, ready for {@link attachPlanetsToSun} (separate from the finest SolarNode).
|
|
88
|
+
*/
|
|
89
|
+
export declare const createSynthClusterSun: (params: {
|
|
90
|
+
clusterId: string | number;
|
|
91
|
+
solarNodesWithSynths: SolarNode[];
|
|
92
|
+
relationshipsWithSynths: number[][];
|
|
93
|
+
relIdMapWithSynths: string[][];
|
|
94
|
+
}) => PartialSun;
|
|
95
|
+
/**
|
|
96
|
+
* Rolls node-level adjacency up to sun-level adjacency between clusters.
|
|
97
|
+
* When `weakLinkSunIds` is provided, edges where either endpoint is a Sun are skipped.
|
|
98
|
+
* @param relationships - Node adjacency lists indexed by node position.
|
|
99
|
+
* @param nodeIndexToSunIndex - Maps each node index to its sun index.
|
|
100
|
+
* @param sunCount - Number of suns in the coarse graph.
|
|
101
|
+
* @param weakLinkSunIds - Optional set of node indices that are Suns. When set, Sun-leaf and Sun-Sun edges are ignored.
|
|
102
|
+
* @returns {number[][]} Sun-level adjacency lists without duplicate edges.
|
|
103
|
+
*/
|
|
104
|
+
export declare const rollupInterSunRelationships: (relationships: number[][], nodeIndexToSunIndex: Record<number, number>, sunCount: number, weakLinkSunIds?: Set<number>) => number[][];
|
|
105
|
+
/**
|
|
106
|
+
* Remaps adjacency lists to a sorted node order.
|
|
107
|
+
* @param relationships - Node adjacency lists in the pre-sort index order.
|
|
108
|
+
* @param nodeSortMap - Maps old node indices to sorted indices.
|
|
109
|
+
* @param relIdMap - Relationship ids aligned with adjacency lists.
|
|
110
|
+
* @param remapRelIds - Whether relationship ids should be remapped as well.
|
|
111
|
+
* @returns {{ relationships: number[][]; relIdMap: string[][] }} Remapped adjacency data.
|
|
112
|
+
*/
|
|
113
|
+
export declare const remapAdjacencyWithSortMap: (relationships: number[][], nodeSortMap: Record<number, number>, relIdMap: string[][], remapRelIds?: boolean) => {
|
|
114
|
+
relationships: number[][];
|
|
115
|
+
relIdMap: string[][];
|
|
116
|
+
};
|
|
117
|
+
/** Input nodes that may receive a layout `finestIndex` during sorting (plain Node on first pass). */
|
|
118
|
+
type SourceNode = (Node | SolarNode) & {
|
|
119
|
+
finestIndex?: number;
|
|
120
|
+
};
|
|
121
|
+
export type SortHierarchyOptions = {
|
|
122
|
+
suns: Sun[];
|
|
123
|
+
solarNodes: SolarNode[];
|
|
124
|
+
sourceNodes?: SourceNode[];
|
|
125
|
+
relationships: number[][];
|
|
126
|
+
relIdMap: string[][];
|
|
127
|
+
idToRel: Record<string, SolarRelationship>;
|
|
128
|
+
firstIteration?: boolean;
|
|
129
|
+
includeMoons?: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Sorts suns, planets, and optionally moons into shader layout order and builds the finest subgraph.
|
|
133
|
+
* @param options - Hierarchy members and adjacency data to sort.
|
|
134
|
+
* @returns The finest subgraph, sort map, member-sun maps, and remapped relationship ids.
|
|
135
|
+
*/
|
|
136
|
+
export declare const sortHierarchyForShaderLayout: ({ suns, solarNodes, sourceNodes, relationships, relIdMap, idToRel, firstIteration, includeMoons }: SortHierarchyOptions) => {
|
|
137
|
+
sortedInput: CoarsenedGraph;
|
|
138
|
+
nodeSortMap: Record<number, number>;
|
|
139
|
+
sunMap: Record<string, string>;
|
|
140
|
+
memberMap: Record<string, string[]>;
|
|
141
|
+
relIdMap: string[][];
|
|
142
|
+
};
|
|
143
|
+
export {};
|