@neo4j-nvl/base 1.2.2 → 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 +31 -1
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +21 -20
- 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 +4 -10
- 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 +118 -25
- 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,13 +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
|
-
* `x` and `
|
|
143
|
-
* @returns The array of {@link
|
|
144
|
-
*
|
|
145
|
-
* @note In the next major release, `x` and `y` become layout coordinates and
|
|
146
|
-
* screen coordinates move to a `clientPosition` field.
|
|
142
|
+
* Each node includes layout coordinates (`x`, `y`) and a `clientPosition` in screen space.
|
|
143
|
+
* @returns The array of {@link NodeWithClientPosition nodes}.
|
|
147
144
|
*/
|
|
148
|
-
getNodes():
|
|
145
|
+
getNodes(): NodeWithClientPosition[];
|
|
149
146
|
/**
|
|
150
147
|
* Returns the relationships that are currently in the visualization.
|
|
151
148
|
* @returns An array of the {@link Relationship relationships} in the visualization.
|
|
@@ -182,7 +179,7 @@ declare class NVL {
|
|
|
182
179
|
*/
|
|
183
180
|
deselectAll(): void;
|
|
184
181
|
/**
|
|
185
|
-
* Updates pan and zoom fit the specified nodes in the viewport.
|
|
182
|
+
* Updates pan and zoom to fit the specified nodes in the viewport.
|
|
186
183
|
* @param nodeIds - The ids of the nodes to fit on the screen.
|
|
187
184
|
* @param zoomOptions - Specific options on how to transition the zoom.
|
|
188
185
|
*
|
|
@@ -302,11 +299,15 @@ declare class NVL {
|
|
|
302
299
|
*
|
|
303
300
|
* @example
|
|
304
301
|
* ```typescript
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
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
|
+
* }
|
|
310
311
|
* ```
|
|
311
312
|
*/
|
|
312
313
|
getSvgDataUrl(options?: {
|
|
@@ -377,12 +378,12 @@ declare class NVL {
|
|
|
377
378
|
*/
|
|
378
379
|
getPan(): Point;
|
|
379
380
|
/**
|
|
380
|
-
* Gets the nodes and
|
|
381
|
+
* Gets the nodes, relationships, and clusters that have been hit by a pointer event.
|
|
381
382
|
* @param evt - The mouse event.
|
|
382
|
-
* @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'].
|
|
383
384
|
* @param hitOptions - Options for the hit test.
|
|
384
385
|
* @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
|
|
385
|
-
* containing the nodes and
|
|
386
|
+
* containing the nodes, relationships, and clusters that have been hit by the pointer event.
|
|
386
387
|
*
|
|
387
388
|
* @example
|
|
388
389
|
* ```js
|
|
@@ -396,7 +397,7 @@ declare class NVL {
|
|
|
396
397
|
* })
|
|
397
398
|
* ```
|
|
398
399
|
*/
|
|
399
|
-
getHits(evt: MouseEvent, targets?:
|
|
400
|
+
getHits(evt: MouseEvent, targets?: HitTestTarget[], hitOptions?: {
|
|
400
401
|
hitNodeMarginWidth: number;
|
|
401
402
|
}): NvlMouseEvent;
|
|
402
403
|
/**
|
|
@@ -419,5 +420,5 @@ declare const colorMapperFunctions: {
|
|
|
419
420
|
*/
|
|
420
421
|
type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
|
|
421
422
|
export default NVL;
|
|
422
|
-
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 };
|
|
423
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
|
+
}
|