@neo4j-nvl/base 1.2.0-d671dd1f → 1.2.0-dbc13ec2
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 +16 -0
- package/dist/base.mjs +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/layouts/forcedirectedlayout/{physlayout/PhysLayout.d.ts → PhysLayout.d.ts} +48 -19
- package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/ClusterByMerger.d.ts +15 -14
- package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/SolarMerger.d.ts +2 -1
- package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/clustering-utils.d.ts +40 -9
- package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/types.d.ts +6 -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/hierarchicallayout/HierarchicalLayout.d.ts +5 -0
- package/dist/types/modules/NvlController.d.ts +49 -5
- package/dist/types/modules/state/types.d.ts +92 -21
- package/dist/types/modules/state/utils.d.ts +2 -2
- package/dist/types/renderers/ClusterOverlay.d.ts +80 -0
- package/dist/types/renderers/ClusterOverlay.test.d.ts +1 -0
- package/dist/types/renderers/webglrenderer/Controller.d.ts +3 -2
- package/dist/types/renderers/webglrenderer/Renderer.d.ts +10 -0
- 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/utils/clusterGeometry.d.ts +14 -0
- package/dist/types/utils/clusterGeometry.test.d.ts +1 -0
- package/dist/types/utils/geometry.d.ts +13 -0
- package/package.json +2 -2
- 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/PhysLayout.test.d.ts → PhysLayout.test.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/ClusterByMerger.test.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/SolarMerger.bench.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/SolarMerger.test.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/clustering-utils.test.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/glwrapper.d.ts → glwrapper.d.ts} +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/multilevel-update-fragment.d.ts +0 -0
- /package/dist/types/layouts/forcedirectedlayout/{physlayout/shaders → shaders}/sim-vertex.d.ts +0 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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, 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';
|
|
@@ -416,5 +416,5 @@ declare const colorMapperFunctions: {
|
|
|
416
416
|
*/
|
|
417
417
|
type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
|
|
418
418
|
export default NVL;
|
|
419
|
-
export type { NvlOptions, Renderer, Node, NodeWithClientPosition, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
419
|
+
export type { NvlOptions, Renderer, Node, NodeWithClientPosition, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, ClusteringOptions, ClusterByFn, ClusterId, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
|
|
420
420
|
export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
|
package/dist/types/layouts/forcedirectedlayout/{physlayout/PhysLayout.d.ts → PhysLayout.d.ts}
RENAMED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import type { ForceDirectedOptions, NvlState } from '
|
|
2
|
-
import type { Node, PartialNode, Relationship } from '
|
|
3
|
-
import { type Point } from '
|
|
1
|
+
import type { ForceDirectedOptions, NvlState } from '../../modules/state/types';
|
|
2
|
+
import type { Node, PartialNode, Relationship } from '../../types/graph-element';
|
|
3
|
+
import { type Point } from '../../utils/geometry';
|
|
4
4
|
import type { CoarsenedGraph } from './clustering/types';
|
|
5
|
+
/**
|
|
6
|
+
* Collision multipliers below this are floored to 0, which makes the shader skip its
|
|
7
|
+
* all-pairs collision loop. Every fine-level force in that loop is scaled by the same
|
|
8
|
+
* multiplier, so at this strength they move nothing worth the O(n^2) cost.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CollisionMultiplierSkipThreshold = 0.05;
|
|
5
11
|
export declare const ConvergenceCheckInterval = 20;
|
|
6
12
|
/**
|
|
7
13
|
* Number of consecutive convergence checks that must report a below-threshold
|
|
@@ -34,9 +40,6 @@ export declare class PhysLayout {
|
|
|
34
40
|
private numNodes;
|
|
35
41
|
private subGraphs;
|
|
36
42
|
private firstUpdate;
|
|
37
|
-
private precomputeMs;
|
|
38
|
-
private precomputeStarted;
|
|
39
|
-
private precomputing;
|
|
40
43
|
private curPhysData;
|
|
41
44
|
private apprxRepForceShader;
|
|
42
45
|
private levelsClusterTexture;
|
|
@@ -51,8 +54,12 @@ export declare class PhysLayout {
|
|
|
51
54
|
private updateShader;
|
|
52
55
|
private physPositions;
|
|
53
56
|
private physDirty;
|
|
57
|
+
private positionsCacheVersion;
|
|
54
58
|
private convergencePbo;
|
|
55
59
|
private convergenceFence;
|
|
60
|
+
private convergenceSnapshot;
|
|
61
|
+
private readonly cpuWritesSinceAsyncReadback;
|
|
62
|
+
private hadSyncReadback;
|
|
56
63
|
private graphIsStableCount;
|
|
57
64
|
private springTexture;
|
|
58
65
|
private sizeTexture;
|
|
@@ -61,7 +68,9 @@ export declare class PhysLayout {
|
|
|
61
68
|
private addedNodes;
|
|
62
69
|
private seedingMethod;
|
|
63
70
|
private clusterBy?;
|
|
71
|
+
private crossClusterRelationshipMultiplier;
|
|
64
72
|
private lastClusterByAssignments;
|
|
73
|
+
private sunMap;
|
|
65
74
|
private updateTexture;
|
|
66
75
|
private physVao;
|
|
67
76
|
private physSmallVao;
|
|
@@ -76,7 +85,10 @@ export declare class PhysLayout {
|
|
|
76
85
|
* @param initial - Whether this is the first setting of options.
|
|
77
86
|
*/
|
|
78
87
|
setOptions(options?: ForceDirectedOptions, initial?: boolean): void;
|
|
79
|
-
private
|
|
88
|
+
private applyClusteringOptions;
|
|
89
|
+
private applyCrossClusterMultiplier;
|
|
90
|
+
private applyClusterBy;
|
|
91
|
+
private wakeLayout;
|
|
80
92
|
private coarsenGraph;
|
|
81
93
|
/**
|
|
82
94
|
* Sets graph data to be used
|
|
@@ -87,17 +99,6 @@ export declare class PhysLayout {
|
|
|
87
99
|
nodes: Node[];
|
|
88
100
|
rels: Relationship[];
|
|
89
101
|
}): CoarsenedGraph;
|
|
90
|
-
/**
|
|
91
|
-
* Synchronously runs physics simulation for the configured time budget before
|
|
92
|
-
* the layout is first rendered.
|
|
93
|
-
* Sets `getComputing()` to `true` while running and clears
|
|
94
|
-
* it when precompute finishes (including early exit when the layout halts).
|
|
95
|
-
*/
|
|
96
|
-
private runPrecompute;
|
|
97
|
-
private isPrecomputeEnabled;
|
|
98
|
-
private hasPendingPrecompute;
|
|
99
|
-
private hasInteractingNodes;
|
|
100
|
-
private shouldRunPrecompute;
|
|
101
102
|
/**
|
|
102
103
|
* Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
|
|
103
104
|
* @param refreshPositions whether the entire layout should be reheated
|
|
@@ -137,6 +138,12 @@ export declare class PhysLayout {
|
|
|
137
138
|
* must build their sampling indices from this.
|
|
138
139
|
*/
|
|
139
140
|
getNodeTexelIndices(): Readonly<Record<Node['id'], number>>;
|
|
141
|
+
/**
|
|
142
|
+
* Multilevel coarsening hierarchy produced by {@link SolarMerger} / {@link ClusterByMerger}.
|
|
143
|
+
* @returns The coarsened graph hierarchy.
|
|
144
|
+
* @see {@link CoarsenedGraph}
|
|
145
|
+
*/
|
|
146
|
+
getSubGraphs(): CoarsenedGraph[];
|
|
140
147
|
private shouldCheckConvergence;
|
|
141
148
|
/** Allocates the pixel-pack buffer used for the async convergence readback. */
|
|
142
149
|
private setupConvergencePbo;
|
|
@@ -151,6 +158,7 @@ export declare class PhysLayout {
|
|
|
151
158
|
* @returns Whether fresh velocity data was consumed this call.
|
|
152
159
|
*/
|
|
153
160
|
private consumeConvergenceReadback;
|
|
161
|
+
private restoreCpuWrittenPositions;
|
|
154
162
|
/** Drops any in-flight readback fence (on stop, reset, or destroy). */
|
|
155
163
|
private cancelConvergenceReadback;
|
|
156
164
|
/**
|
|
@@ -159,15 +167,31 @@ export declare class PhysLayout {
|
|
|
159
167
|
*/
|
|
160
168
|
getShouldUpdate(): boolean;
|
|
161
169
|
/**
|
|
162
|
-
*
|
|
170
|
+
* Returns whether the current layout is computing.
|
|
171
|
+
* Always returns false because the force-directed layout has no computing step.
|
|
172
|
+
* @returns Whether the layout is computing.
|
|
163
173
|
*/
|
|
164
174
|
getComputing(): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Version of the CPU position cache. Advances on GPU readback, CPU-mirror
|
|
177
|
+
* writes, and physics buffer reset.
|
|
178
|
+
* @returns The current cache version.
|
|
179
|
+
*/
|
|
180
|
+
getPositionsCacheVersion(): number;
|
|
165
181
|
/**
|
|
166
182
|
* Adds the current x,y coordinates for each node to a given list of nodes.
|
|
183
|
+
* Forces a synchronous GPU readback when the cache is dirty.
|
|
167
184
|
* @param nodeList - The list of nodes to get positions for.
|
|
168
185
|
* @returns The list of nodes containing the x,y coordinates on each node object.
|
|
169
186
|
*/
|
|
170
187
|
getNodePositions(nodeList: Node[]): (Node & Point)[];
|
|
188
|
+
/**
|
|
189
|
+
* Maps {@link physPositions} onto a node list without forcing a GPU readback.
|
|
190
|
+
* Positions may lag behind the live GPU texture until the next sync/async refresh.
|
|
191
|
+
* @param nodeList - The list of nodes to get positions for.
|
|
192
|
+
* @returns The list of nodes containing the cached x,y coordinates.
|
|
193
|
+
*/
|
|
194
|
+
getCachedNodePositions(nodeList: Node[]): (Node & Point)[];
|
|
171
195
|
/**
|
|
172
196
|
* Reheats the layout
|
|
173
197
|
* @param fullData - The entire graph object.
|
|
@@ -181,6 +205,11 @@ export declare class PhysLayout {
|
|
|
181
205
|
* @param nodeList - The list of updates.
|
|
182
206
|
*/
|
|
183
207
|
updateNodes(nodeList: PartialNode[]): void;
|
|
208
|
+
/**
|
|
209
|
+
* Writes a node position into the current phys position texture and CPU mirror.
|
|
210
|
+
* Caller must bind {@link getPositionTexture} first.
|
|
211
|
+
*/
|
|
212
|
+
private writePhysPosition;
|
|
184
213
|
/**
|
|
185
214
|
* Adds and removes nodes from the graph based on given updates
|
|
186
215
|
* @param fullData - The entire graph object.
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ClusterByFn, ClusterId } from '../../../modules/state/types';
|
|
2
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
3
|
import type { CoarsenedGraph } from './types';
|
|
3
|
-
type ClusterByFn = (nodeId: string) => string | number | undefined;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* separation isn't fought by relationships that happen to link different clusters. Edges within
|
|
7
|
-
* the same cluster are unaffected (always full strength) — relationships still get to shape how a
|
|
8
|
-
* cluster's own members arrange themselves. Non-clusterBy (SolarMerger) layouts always get full
|
|
9
|
-
* spring strength on every edge.
|
|
5
|
+
* Default value for {@link ForceDirectedOptions.crossClusterRelationshipMultiplier}.
|
|
10
6
|
*/
|
|
11
|
-
export declare const
|
|
7
|
+
export declare const DEFAULT_CROSS_CLUSTER_RELATIONSHIP_MULTIPLIER = 0;
|
|
12
8
|
/**
|
|
13
9
|
* Builds a two-level Sun/Planet hierarchy from semantic cluster identifiers.
|
|
14
|
-
* Nodes sharing the same cluster id become planets orbiting a cluster sun
|
|
15
|
-
* without a cluster id remain independent suns.
|
|
10
|
+
* Nodes sharing the same cluster id become planets orbiting a new synthetic cluster sun.
|
|
11
|
+
* Nodes without a cluster id remain independent suns.
|
|
16
12
|
*/
|
|
17
13
|
export default class ClusterByMerger {
|
|
18
14
|
subGraphs: CoarsenedGraph[];
|
|
19
15
|
sunMap: Record<string, string>;
|
|
16
|
+
memberMap: Record<string, string[]>;
|
|
20
17
|
relIdMap: string[][];
|
|
21
|
-
clusterAssignments: Map<string,
|
|
18
|
+
clusterAssignments: Map<string, ClusterId | undefined>;
|
|
22
19
|
private nodeSortMap;
|
|
23
20
|
/**
|
|
24
21
|
* Coarsens the input graph into a property-based solar hierarchy.
|
|
@@ -50,11 +47,15 @@ export default class ClusterByMerger {
|
|
|
50
47
|
private groupNodesByCluster;
|
|
51
48
|
/**
|
|
52
49
|
* Converts cluster buckets into a Sun/Planet hierarchy for the first coarsening level.
|
|
53
|
-
*
|
|
50
|
+
* Each bucket with more than one node gets a synthetic Sun and the members become its planets.
|
|
51
|
+
* Single-member buckets keep the real node as Sun.
|
|
54
52
|
* @param buckets - Node index groups produced by {@link groupNodesByCluster}.
|
|
55
53
|
* @param nodes - Input graph nodes indexed by position.
|
|
56
|
-
* @
|
|
54
|
+
* @param solarNodes - Solar nodes to extend with synth suns.
|
|
55
|
+
* @param relationships - Adjacency lists to extend with rows for synth suns.
|
|
56
|
+
* @param relIdMap - Relationship id lists to extend with rows for synth suns.
|
|
57
|
+
* @returns Cluster suns, index maps for node-sun and relationship ids and
|
|
58
|
+
* copies of solar nodes / adjacency / rel id lists with synth suns appended.
|
|
57
59
|
*/
|
|
58
60
|
private buildPropertyHierarchy;
|
|
59
61
|
}
|
|
60
|
-
export {};
|
package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/SolarMerger.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Relationship } from '
|
|
1
|
+
import type { Node, Relationship } from '../../../types/graph-element';
|
|
2
2
|
import type { CoarsenedGraph, SolarRelationship } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Coarsens a graph into a hierarchy of "solar systems", following the sun/planet/moon partitioning scheme from
|
|
@@ -14,6 +14,7 @@ export default class SolarMerger {
|
|
|
14
14
|
};
|
|
15
15
|
subGraphs: CoarsenedGraph[];
|
|
16
16
|
sunMap: Record<string, string>;
|
|
17
|
+
memberMap: Record<string, string[]>;
|
|
17
18
|
relIdMap: string[][];
|
|
18
19
|
nodeSortMap?: Record<number, number>;
|
|
19
20
|
constructor(inputGraph: {
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import type { Node, Relationship } from '
|
|
2
|
-
import type { CoarsenedGraph,
|
|
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[];
|
|
3
11
|
/**
|
|
4
12
|
* How many times a node's degree must exceed the graph's average degree before it is treated as a hub, see
|
|
5
13
|
* {@link isHub}.
|
|
@@ -57,16 +65,33 @@ export declare const createPlanet: (params: {
|
|
|
57
65
|
originalId: string;
|
|
58
66
|
finestIndex?: number;
|
|
59
67
|
size?: () => number;
|
|
60
|
-
}) =>
|
|
68
|
+
}) => PartialPlanet;
|
|
61
69
|
/**
|
|
62
70
|
* Finalises a sun's planets list, weight/size/children closures, and back-links parent on each planet.
|
|
63
|
-
* @param
|
|
64
|
-
* @param planets - The planets to attach to the sun.
|
|
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).
|
|
65
73
|
* @param centreWeight - The weight of the sun itself, added to the sum of its planets' weights.
|
|
66
74
|
* @param centreSize - The size of the sun itself, added to the sum of its planets' sizes.
|
|
67
|
-
* @returns
|
|
75
|
+
* @returns A new sun object with planets attached. `previousIndex` is a placeholder until
|
|
76
|
+
* {@link sortHierarchyForShaderLayout} assigns the real value.
|
|
68
77
|
*/
|
|
69
|
-
export declare const attachPlanetsToSun: (
|
|
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;
|
|
70
95
|
/**
|
|
71
96
|
* Rolls node-level adjacency up to sun-level adjacency between clusters.
|
|
72
97
|
* When `weakLinkSunIds` is provided, edges where either endpoint is a Sun are skipped.
|
|
@@ -89,10 +114,14 @@ export declare const remapAdjacencyWithSortMap: (relationships: number[][], node
|
|
|
89
114
|
relationships: number[][];
|
|
90
115
|
relIdMap: string[][];
|
|
91
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
|
+
};
|
|
92
121
|
export type SortHierarchyOptions = {
|
|
93
122
|
suns: Sun[];
|
|
94
123
|
solarNodes: SolarNode[];
|
|
95
|
-
sourceNodes?:
|
|
124
|
+
sourceNodes?: SourceNode[];
|
|
96
125
|
relationships: number[][];
|
|
97
126
|
relIdMap: string[][];
|
|
98
127
|
idToRel: Record<string, SolarRelationship>;
|
|
@@ -102,11 +131,13 @@ export type SortHierarchyOptions = {
|
|
|
102
131
|
/**
|
|
103
132
|
* Sorts suns, planets, and optionally moons into shader layout order and builds the finest subgraph.
|
|
104
133
|
* @param options - Hierarchy members and adjacency data to sort.
|
|
105
|
-
* @returns The finest subgraph, sort map, sun
|
|
134
|
+
* @returns The finest subgraph, sort map, member-sun maps, and remapped relationship ids.
|
|
106
135
|
*/
|
|
107
136
|
export declare const sortHierarchyForShaderLayout: ({ suns, solarNodes, sourceNodes, relationships, relIdMap, idToRel, firstIteration, includeMoons }: SortHierarchyOptions) => {
|
|
108
137
|
sortedInput: CoarsenedGraph;
|
|
109
138
|
nodeSortMap: Record<number, number>;
|
|
110
139
|
sunMap: Record<string, string>;
|
|
140
|
+
memberMap: Record<string, string[]>;
|
|
111
141
|
relIdMap: string[][];
|
|
112
142
|
};
|
|
143
|
+
export {};
|
package/dist/types/layouts/forcedirectedlayout/{physlayout/clustering → clustering}/types.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node } from '
|
|
1
|
+
import type { Node } from '../../../types/graph-element';
|
|
2
2
|
export interface SolarNode extends Omit<Node, 'id' | 'size'> {
|
|
3
3
|
id: number;
|
|
4
4
|
weight?: number;
|
|
@@ -13,6 +13,7 @@ export interface SolarNode extends Omit<Node, 'id' | 'size'> {
|
|
|
13
13
|
y: number;
|
|
14
14
|
};
|
|
15
15
|
size?: number | (() => number);
|
|
16
|
+
synthetic?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface SolarRelationship {
|
|
18
19
|
id: string;
|
|
@@ -35,6 +36,8 @@ export interface Sun extends SolarNode {
|
|
|
35
36
|
children: () => Planet[];
|
|
36
37
|
previousIndex: number;
|
|
37
38
|
}
|
|
39
|
+
/** Sun fields known before {@link attachPlanetsToSun} fills planets/size/children/weight. */
|
|
40
|
+
export type PartialSun = Omit<Sun, 'planets' | 'size' | 'children' | 'previousIndex' | 'weight'>;
|
|
38
41
|
export interface Planet extends SolarNode {
|
|
39
42
|
parent: Sun;
|
|
40
43
|
sunId: number;
|
|
@@ -42,6 +45,8 @@ export interface Planet extends SolarNode {
|
|
|
42
45
|
size: () => number;
|
|
43
46
|
children: () => Moon[];
|
|
44
47
|
}
|
|
48
|
+
/** Planet fields known before {@link attachPlanetsToSun} sets parent. */
|
|
49
|
+
export type PartialPlanet = Omit<Planet, 'parent'>;
|
|
45
50
|
export interface Moon extends SolarNode {
|
|
46
51
|
parent: Planet;
|
|
47
52
|
sunId: number;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_physData;\nuniform sampler2D u_connections;\nuniform sampler2D u_connectionOffsets;\nuniform sampler2D u_pinnedNodes;\nuniform sampler2D u_sizeTexture;\nuniform float u_baseLength;\nuniform float u_curIteration;\nuniform float u_iterationMultiplier;\nuniform vec2 u_gravityCenter;\nuniform float u_numNodes;\nuniform float u_gravity;\n\nuniform sampler2D u_clusterData;\nuniform sampler2D u_prevForce;\nuniform float u_collisionMultiplier;\nuniform float u_maxNodeSize;\nuniform float u_crossClusterRelationshipMultiplier;\n\nout vec4 fragColor;\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0.6;\nfloat accLimitLow = 500000.0;\nfloat accLimitHigh = 750000.0;\nfloat accLimitPosHigh = 10000000.0;\n\nconst float denseNodeThreshold = 1000.0;\nconst float MIN_DISTANCE = 0.00000001;\nconst float MAX_DISTANCE = 1000000000.0;\nconst float MAX_ACCELERATION = 50000.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nbool isNan(float val) {\n return (val < 0.0 || 0.0 < val || val == 0.0) ? false : true;\n}\n\nconst float BIG_NUMBER = 999999999999999999.0;\nbool isInf(float val) {\n return val > BIG_NUMBER || val < -BIG_NUMBER;\n}\n\nvec2 getDelta(vec2 v1, vec2 v2) {\n vec2 delta = v1 - v2;\n float dist = length(delta);\n if (dist < MIN_DISTANCE || isNan(dist)) {\n return vec2(MIN_DISTANCE, MIN_DISTANCE);\n }\n if (dist > MAX_DISTANCE) {\n vec2 normDelta = delta / dist;\n return normDelta * MAX_DISTANCE;\n }\n return delta;\n}\n\nvec4 getOtherNodePosition(float i) {\n return getTextureData(u_physData, i, 256.0);\n}\n\nfloat getCombinedNodeSize(float i, float nodeSize) {\n float otherNodeSize = getTextureData(u_sizeTexture, i, 256.0).r;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i, float myClusterStartIndex) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).r;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).r;\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).r;\n float avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree) * u_collisionMultiplier;\n\n // u_crossClusterRelationshipMultiplier only damps edges that cross a cluster boundary\n if (u_crossClusterRelationshipMultiplier < 1.0) {\n float otherClusterStartIndex = getTextureData(u_clusterData, curSpring, 256.0).y;\n F *= otherClusterStartIndex == myClusterStartIndex ? 1.0 : u_crossClusterRelationshipMultiplier;\n }\n\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist) * u_collisionMultiplier;\n return (delta * collisionForce * fScale * combinedNodeSize) / (combinedNodeSize + 1.0);\n}\n\nvec2 getRepulsionForce(float dist, float fScale, vec2 delta) {\n float F = (u_baseLength * u_baseLength * fScale) / (dist) * u_collisionMultiplier;\n return (delta / dist) * F * 0.05;\n}\n\nvoid main(void) {\n float textureSide = 256.0; //#TEXTURE_SIDE#;\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * textureSide;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n\n vec4 myPosition = getTextureData(u_physData, index, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n\n vec2 acceleration = previousForce.xy;\n\n float isPinned = getTextureData(u_pinnedNodes, index, 256.0).r;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).r;\n\n if (isPinned > 0.5) {\n fragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n // Prime the second ping-pong texture with the initial state without calculating forces\n // that would otherwise be discarded at the end of this first iteration.\n if (u_curIteration == 0.0) {\n fragColor = vec4(myPosition.xy, myPosition.zw);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).r;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).r;\n\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n float springFScale = fScale;\n\n if (numConnections > denseNodeThreshold) {\n springFScale = sqrt(fScale);\n }\n\n float numOfRels = 0.0;\n\n // Springs\n for (float i = 1.0; i <= 256.0 * 256.0; i++) {\n if (numOfRels >= numConnections) {\n break;\n }\n acceleration += getSpringForce(curConnection, numConnections, springFScale, myPosition, i, clusterStartIndex);\n numOfRels += 1.0;\n }\n\n // Repulsion && collision detection.\n if (u_collisionMultiplier > 0.0) {\n float number_of_collisions = 0.0;\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= u_numNodes) {\n break;\n }\n\n if (i == index) {\n continue;\n }\n\n vec4 otherPosition = getOtherNodePosition(i);\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n if (number_of_collisions < 40.0 && dist < (nodeSize + u_maxNodeSize) * 2.0) {\n float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n if (dist < combinedNodeSize) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n }\n\n // Gravity\n vec2 delta = getDelta(u_gravityCenter, myPosition.xy);\n float dist = length(delta);\n\n vec2 grav = (delta / dist) * u_gravity * fScale * (dist / 1000.0);\n acceleration += grav;\n\n float accMagnitude = length(acceleration);\n acceleration *= min(MAX_ACCELERATION, accMagnitude) / accMagnitude;\n\n float iterationFrictionThreshold = 1000.0;\n\n if (u_curIteration > iterationFrictionThreshold) {\n float friction = 1.0 + pow((u_curIteration - iterationFrictionThreshold), 2.0) / 100.0;\n acceleration *= 1.0 / friction;\n }\n\n float TEMP = max(0.02, pow(COOL, u_curIteration));\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n fragColor = vec4(newPos, newVelocity);\n}";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "#version 300 es\nprecision mediump float;\nuniform sampler2D u_physData;\nuniform sampler2D u_clusterData;\nuniform sampler2D u_finestIndexes;\nuniform sampler2D u_prevForce;\n\nuniform float u_baseLength;\nuniform float u_numNodes;\nuniform float u_iterationMultiplier;\nuniform float u_isTopLevel;\n\nout vec4 fragColor;\n\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 1.0;\n\nvec4 getTextureData(sampler2D tex, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture(tex, vec2(x + 0.5, y + 0.5) / base);\n}\n\nfloat getAdjustedClusterWeight(float clusterWeight) {\n return (clusterWeight * clusterWeight) / (clusterWeight + 1.0);\n}\n\n// Repulsion area from peer mass (weight). .z size is only for mid-level loop bounds.\nfloat getPeerFootprintArea(float peerWeight) {\n return pow(sqrt(peerWeight) * 4.0 + u_baseLength * 2.0, 2.0);\n}\n\nvoid main(void) {\n float index = (gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * 256.0;\n\n if (index >= u_numNodes) {\n discard;\n }\n\n vec4 clusterData = getTextureData(u_clusterData, index, 256.0);\n bool isTopLevel = u_isTopLevel == 1.0;\n\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float singleNodeRepulsionScale = isTopLevel && clusterSize == 1.0 ? 0.5 : 1.0;\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).r;\n vec4 myPosition = getTextureData(u_physData, finestIndex, 256.0);\n vec4 previousForce = getTextureData(u_prevForce, clusterIndex, 256.0);\n float fScale = 1.0 + sqrt(u_iterationMultiplier);\n\n vec2 acceleration = previousForce.xy;\n\n float loopEnd = isTopLevel ? u_numNodes : (clusterStartIndex + clusterSize);\n\n // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= loopEnd || i >= u_numNodes) {\n break;\n }\n if ((!isTopLevel && i < clusterStartIndex) || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getAdjustedClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).r;\n vec4 otherPosition = getTextureData(u_physData, otherFinestIndex, 256.0);\n\n vec2 delta = myPosition.xy - otherPosition.xy;\n float dist = max(length(delta), 0.0000001);\n float maxDist = 25.0;\n float repulsionForceScale = 0.1;\n\n float area = getPeerFootprintArea(otherClusterData.w);\n float F = (area * fScale) / (dist * dist);\n\n if (isTopLevel) {\n repulsionForceScale = 0.2;\n }\n\n acceleration += ((delta / sqrt(dist)) * F) * repulsionForceScale * otherClusterWeight * singleNodeRepulsionScale;\n\n if (dist < maxDist) {\n float collide = (maxDist - dist) / (dist * dist);\n acceleration += delta * collide * fScale * maxDist / (maxDist + 1.0);\n }\n }\n\n fragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
|
|
2
|
+
export default _default;
|
|
@@ -7,6 +7,8 @@ type HierarchicalLayoutConfig = {
|
|
|
7
7
|
export declare class HierarchicalLayout extends AnimatedLayout {
|
|
8
8
|
private direction;
|
|
9
9
|
private packing;
|
|
10
|
+
private clusterBy?;
|
|
11
|
+
private lastClusterByAssignments;
|
|
10
12
|
private stateDisposers;
|
|
11
13
|
private oldComputing;
|
|
12
14
|
private computing;
|
|
@@ -14,9 +16,12 @@ export declare class HierarchicalLayout extends AnimatedLayout {
|
|
|
14
16
|
private worker;
|
|
15
17
|
private directionChanged;
|
|
16
18
|
private packingChanged;
|
|
19
|
+
private clusterByChanged;
|
|
17
20
|
private workersDisabled;
|
|
18
21
|
constructor(config: HierarchicalLayoutConfig);
|
|
19
22
|
setOptions(options: LayoutOptions): void;
|
|
23
|
+
private applyClusterByOption;
|
|
24
|
+
private buildClusterAssignments;
|
|
20
25
|
update(refreshPositions?: boolean): void;
|
|
21
26
|
getShouldUpdate(): boolean;
|
|
22
27
|
getComputing(): boolean;
|
|
@@ -31,10 +31,13 @@ export default class NvlController {
|
|
|
31
31
|
private readonly forceLayout;
|
|
32
32
|
private readonly canvasRenderer;
|
|
33
33
|
private readonly svgRenderer;
|
|
34
|
+
private clusterOverlay;
|
|
34
35
|
private readonly glCanvas;
|
|
35
36
|
private canvasRect;
|
|
36
37
|
private readonly glMinimapCanvas;
|
|
37
38
|
private readonly c2dCanvas;
|
|
39
|
+
private clusterOverlayCanvas;
|
|
40
|
+
private readonly canvasParent;
|
|
38
41
|
private readonly svg;
|
|
39
42
|
private isInRenderSwitchAnimation;
|
|
40
43
|
private previousRenderer;
|
|
@@ -61,8 +64,10 @@ export default class NvlController {
|
|
|
61
64
|
private layoutComputingCallback;
|
|
62
65
|
private currentLayoutType;
|
|
63
66
|
private descriptionElement;
|
|
64
|
-
/** True when a minimap container was provided
|
|
67
|
+
/** True when a minimap container was provided at construction. */
|
|
65
68
|
private readonly hasMinimap;
|
|
69
|
+
private lastMinimapPositions;
|
|
70
|
+
private lastMinimapCacheVersion;
|
|
66
71
|
constructor(state: NvlState, frame: HTMLElement, options: NvlOptions);
|
|
67
72
|
private onWebGLContextLost;
|
|
68
73
|
private fpsToFrameBudgetMs;
|
|
@@ -81,11 +86,46 @@ export default class NvlController {
|
|
|
81
86
|
private usesGpuSimulation;
|
|
82
87
|
/**
|
|
83
88
|
* Whether the GPU-texture fast path can be taken this frame.
|
|
84
|
-
* Requires the WebGL renderer, GPU layout active,
|
|
85
|
-
* (layout-step callback, HTML overlays).
|
|
89
|
+
* Requires the WebGL renderer, GPU layout active, and no CPU-position consumers
|
|
90
|
+
* (layout-step callback, HTML overlays). A provided minimap no longer blocks this path;
|
|
91
|
+
* the minimap and cluster overlay are updated from the lagged async position cache instead.
|
|
86
92
|
* @returns `true` when rendering directly from the GPU position texture is safe.
|
|
87
93
|
*/
|
|
88
94
|
private canRenderFromGpuTexture;
|
|
95
|
+
/**
|
|
96
|
+
* Uploads lagged PhysLayout cache positions to the minimap when the cache version changed.
|
|
97
|
+
* @returns `true` when positions were refreshed this call.
|
|
98
|
+
*/
|
|
99
|
+
private refreshMinimapFromCacheIfStale;
|
|
100
|
+
/**
|
|
101
|
+
* Fits, renders, and caches minimap positions (and PhysLayout cache version when applicable).
|
|
102
|
+
*/
|
|
103
|
+
private syncMinimap;
|
|
104
|
+
/** Whether either cluster decoration is enabled in the current layout options. */
|
|
105
|
+
private hasClusterDecorations;
|
|
106
|
+
/**
|
|
107
|
+
* Creates the decoration canvas and its overlay.
|
|
108
|
+
* @returns The overlay to draw with.
|
|
109
|
+
*/
|
|
110
|
+
private createClusterOverlay;
|
|
111
|
+
/**
|
|
112
|
+
* Resolves the overlay to draw into, allocating it on first use and tearing it down again
|
|
113
|
+
* while cluster decorations are off.
|
|
114
|
+
* @returns The overlay to draw with, or null when decorations are disabled.
|
|
115
|
+
*/
|
|
116
|
+
private ensureClusterOverlay;
|
|
117
|
+
/** Tears the overlay and its canvas back down once decorations are switched off. */
|
|
118
|
+
private destroyClusterOverlay;
|
|
119
|
+
/**
|
|
120
|
+
* Draws (or clears) cluster decorations on the Canvas2D overlay from explicit positions.
|
|
121
|
+
* @param positions - CPU node positions for this frame, or null to clear.
|
|
122
|
+
*/
|
|
123
|
+
private renderClusterOverlay;
|
|
124
|
+
/**
|
|
125
|
+
* Draws cluster decorations from PhysLayout's lagged async PBO cache without a sync dump.
|
|
126
|
+
* @param forceLayout - The PhysLayout instance to render the cluster overlay from.
|
|
127
|
+
*/
|
|
128
|
+
private renderClusterOverlayFromCache;
|
|
89
129
|
/** Syncs idToPosition from the GPU layout on demand; no-op for CPU layouts. */
|
|
90
130
|
syncPositionsFromLayout(): void;
|
|
91
131
|
private updateMinimapZoom;
|
|
@@ -122,7 +162,7 @@ export default class NvlController {
|
|
|
122
162
|
};
|
|
123
163
|
registerDoneCallback(cb: NvlController['layoutDoneCallback']): void;
|
|
124
164
|
registerComputingCallback(cb: NvlController['layoutComputingCallback']): void;
|
|
125
|
-
getPosition(nodeId: string): Node;
|
|
165
|
+
getPosition(nodeId: string): Node & Point;
|
|
126
166
|
getScale(): number;
|
|
127
167
|
getPan(): {
|
|
128
168
|
x: number;
|
|
@@ -142,7 +182,11 @@ export default class NvlController {
|
|
|
142
182
|
getCanvasNodesAt(point: Point, hitNodeMarginWidth?: number): import("..").HitTargetNode[];
|
|
143
183
|
private getLayout;
|
|
144
184
|
setLayout(layoutType: Layout): void;
|
|
145
|
-
setLayoutOptions(options
|
|
185
|
+
setLayoutOptions(options?: LayoutOptions): void;
|
|
186
|
+
/**
|
|
187
|
+
* Syncs positions if needed and redraws (or clears) the cluster overlay from current state.
|
|
188
|
+
*/
|
|
189
|
+
private refreshClusterOverlay;
|
|
146
190
|
private getDataUrlForCanvas;
|
|
147
191
|
private initiateFileDownload;
|
|
148
192
|
private updateLayoutAndPositions;
|
|
@@ -34,36 +34,88 @@ export type DisabledItemStyles = {
|
|
|
34
34
|
fontColor: string;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Identifier returned by {@link ClusterByFn} to group nodes into physical clusters.
|
|
38
|
+
* Nodes sharing the same string or number are clustered together.
|
|
38
39
|
*/
|
|
39
|
-
export
|
|
40
|
+
export type ClusterId = string | number;
|
|
41
|
+
/**
|
|
42
|
+
* Function that maps a node id to a {@link ClusterId} for force-directed clustering.
|
|
43
|
+
* Returns `undefined` for nodes that should remain independent.
|
|
44
|
+
*/
|
|
45
|
+
export type ClusterByFn = (nodeId: string) => ClusterId | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Options that control physical clustering and cluster decorations for the force-directed layout.
|
|
48
|
+
*/
|
|
49
|
+
export interface ClusteringOptions {
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
51
|
+
* Optional function to group nodes into physical clusters based on a custom identifier.
|
|
52
|
+
* Nodes returning the same string or number will be grouped together in the layout.
|
|
53
|
+
* Nodes returning undefined will be treated as independent.
|
|
54
|
+
*
|
|
55
|
+
* @note Ensure this function has a stable reference to avoid evaluation on every render.
|
|
43
56
|
*/
|
|
44
|
-
|
|
57
|
+
clusterBy?: ClusterByFn;
|
|
45
58
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
59
|
+
* Draws a convex-hull outline around each cluster.
|
|
60
|
+
*
|
|
61
|
+
* @note Outline color is the same as the nodes in the cluster.
|
|
62
|
+
* If the nodes in the cluster have different colors, the outline uses
|
|
63
|
+
* {@link NvlOptions.styling.overlayLineColor}.
|
|
64
|
+
* @defaultValue false
|
|
48
65
|
*/
|
|
49
|
-
|
|
66
|
+
drawOutline?: boolean;
|
|
50
67
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
68
|
+
* Fills a soft glowing halo around each cluster.
|
|
69
|
+
*
|
|
70
|
+
* @note Halo color is the same as the nodes in the cluster.
|
|
71
|
+
* If the nodes in the cluster have different colors, the halo won't be shown.
|
|
72
|
+
* @defaultValue false
|
|
73
|
+
*/
|
|
74
|
+
drawHalo?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Spring force multiplier for relationships that cross a {@link ClusteringOptions.clusterBy}
|
|
77
|
+
* cluster boundary.
|
|
78
|
+
* Capped between `0` and `1`.
|
|
79
|
+
* `0` disables cross-cluster spring pull. `1` is full strength. Intra-cluster edges are always
|
|
80
|
+
* full strength. Only applies when {@link ClusteringOptions.clusterBy} is set.
|
|
54
81
|
* @defaultValue 0
|
|
55
|
-
* @
|
|
82
|
+
* @experimental
|
|
83
|
+
* @note Can cause unstable layouts when set to close to `1` in highly connected graphs.
|
|
56
84
|
*/
|
|
57
|
-
|
|
85
|
+
crossClusterRelationshipMultiplier?: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The options for the force directed layout
|
|
89
|
+
*/
|
|
90
|
+
export interface ForceDirectedOptions {
|
|
58
91
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* Nodes returning undefined will be treated as independent.
|
|
62
|
-
*
|
|
63
|
-
* @note Ensure this function has a stable reference to avoid evaluation on every render.
|
|
92
|
+
* How initial node positions are seeded before the physics simulation runs.
|
|
93
|
+
* @defaultValue 'box'
|
|
64
94
|
*/
|
|
65
|
-
|
|
95
|
+
seedingMethod?: 'box' | 'circle';
|
|
96
|
+
/**
|
|
97
|
+
* Physical clustering and cluster decoration options.
|
|
98
|
+
*/
|
|
99
|
+
clustering?: ClusteringOptions;
|
|
66
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the clustering options from force-directed layout options, if present.
|
|
103
|
+
* @param layoutOptions - The layout options to read from.
|
|
104
|
+
* @returns The clustering options, or undefined when absent / not force-directed.
|
|
105
|
+
*/
|
|
106
|
+
export declare const getClusteringOptions: (layoutOptions?: LayoutOptions) => ClusteringOptions | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
109
|
+
* @param layoutOptions - The layout options to check.
|
|
110
|
+
* @returns Whether {@link ClusteringOptions.drawOutline} is enabled on the given layout options.
|
|
111
|
+
*/
|
|
112
|
+
export declare const isDrawClusterOutlineEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
115
|
+
* @param layoutOptions - The layout options to check.
|
|
116
|
+
* @returns Whether {@link ClusteringOptions.drawHalo} is enabled on the given layout options.
|
|
117
|
+
*/
|
|
118
|
+
export declare const isDrawClusterHaloEnabled: (layoutOptions?: LayoutOptions) => boolean;
|
|
67
119
|
/**
|
|
68
120
|
* The options for the hierarchical layout
|
|
69
121
|
*/
|
|
@@ -72,6 +124,16 @@ export interface HierarchicalOptions {
|
|
|
72
124
|
direction?: 'up' | 'down' | 'left' | 'right';
|
|
73
125
|
/** The packing method to be used */
|
|
74
126
|
packing?: 'bin' | 'stack';
|
|
127
|
+
/**
|
|
128
|
+
* Optional function to group nodes into semantic clusters based on a custom identifier.
|
|
129
|
+
* Nodes returning the same string or number will be grouped together in the layout via
|
|
130
|
+
* dagre compound subgraphs. Nodes returning undefined will be treated as independent.
|
|
131
|
+
*
|
|
132
|
+
* @note Ensure this function has a stable reference to avoid evaluation on every render.
|
|
133
|
+
*
|
|
134
|
+
* @experimental
|
|
135
|
+
*/
|
|
136
|
+
clusterBy?: (nodeId: string) => string | number | undefined;
|
|
75
137
|
}
|
|
76
138
|
export declare const isHierarchicalLayoutOptions: (options: LayoutOptions) => options is HierarchicalOptions;
|
|
77
139
|
/**
|
|
@@ -233,7 +295,16 @@ export interface NvlOptions {
|
|
|
233
295
|
disabledItemColor?: string;
|
|
234
296
|
/** The color to use for the labels of the disabled nodes and relationships */
|
|
235
297
|
disabledItemFontColor?: string;
|
|
236
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* Stroke color for overlay UI lines (e.g. minimap viewport box).
|
|
300
|
+
* Use a dark color on light backgrounds and a light color on dark backgrounds.
|
|
301
|
+
* @defaultValue `#1A1B1D`
|
|
302
|
+
*/
|
|
303
|
+
overlayLineColor?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The color to use for the viewport box in the minimap.
|
|
306
|
+
* @deprecated Use {@link overlayLineColor}.
|
|
307
|
+
*/
|
|
237
308
|
minimapViewportBoxColor?: string;
|
|
238
309
|
};
|
|
239
310
|
/**
|
|
@@ -339,6 +410,6 @@ export interface NvlState {
|
|
|
339
410
|
disabledItemStyles: DisabledItemStyles;
|
|
340
411
|
defaultNodeColor: string;
|
|
341
412
|
defaultRelationshipColor: string;
|
|
342
|
-
|
|
413
|
+
overlayLineColor: string;
|
|
343
414
|
}
|
|
344
415
|
export {};
|