@neo4j-nvl/base 0.3.9 → 1.0.0-08b14670

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/base.mjs +1 -1
  3. package/dist/types/index.d.ts +101 -78
  4. package/dist/types/layouts/animatedlayout/animationUtils.d.ts +3 -3
  5. package/dist/types/layouts/circularLayout/CircularLayout.d.ts +18 -0
  6. package/dist/types/layouts/forcedirectedlayout/ForceCytoLayout.d.ts +1 -1
  7. package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +27 -22
  8. package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-fragment-verlet.d.ts +1 -1
  9. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +17 -39
  10. package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/types.d.ts +49 -0
  11. package/dist/types/modules/CallbackHelper.d.ts +5 -5
  12. package/dist/types/modules/ExternalCallbackHandler.d.ts +7 -0
  13. package/dist/types/modules/NvlController.d.ts +11 -7
  14. package/dist/types/modules/dataset.d.ts +1 -1
  15. package/dist/types/modules/state/state.d.ts +2 -2
  16. package/dist/types/modules/state/types.d.ts +73 -61
  17. package/dist/types/modules/state/utils.d.ts +8 -6
  18. package/dist/types/renderers/domrenderer/BaseRenderer.d.ts +66 -0
  19. package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/Animation.d.ts +8 -11
  20. package/dist/types/renderers/{canvasrenderer → domrenderer/canvasrenderer}/AnimationHandler.d.ts +15 -16
  21. package/dist/types/renderers/domrenderer/canvasrenderer/CanvasRenderer.d.ts +153 -0
  22. package/dist/types/renderers/domrenderer/canvasrenderer/canvasUtils.d.ts +56 -0
  23. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/ImageCache.d.ts +1 -1
  24. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundle.d.ts +17 -17
  25. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/ArrowBundler.d.ts +9 -9
  26. package/dist/types/renderers/domrenderer/shared/arrows/arrows.d.ts +148 -0
  27. package/dist/types/renderers/domrenderer/shared/nodes/nodeUtils.d.ts +28 -0
  28. package/dist/types/renderers/domrenderer/shared/nodes/nodes.d.ts +58 -0
  29. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/types.d.ts +8 -6
  30. package/dist/types/renderers/domrenderer/shared/util.d.ts +11 -0
  31. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/vectorUtils.d.ts +1 -1
  32. package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/wordwrap.d.ts +13 -13
  33. package/dist/types/renderers/domrenderer/shared/wordwrap.test.d.ts +1 -0
  34. package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.d.ts +27 -0
  35. package/dist/types/renderers/domrenderer/svgrenderer/SvgRenderer.test.d.ts +1 -0
  36. package/dist/types/renderers/domrenderer/svgrenderer/svgUtils.d.ts +191 -0
  37. package/dist/types/renderers/webglrenderer/Renderer.d.ts +5 -1
  38. package/dist/types/renderers/webglrenderer/Renderer.test.d.ts +1 -0
  39. package/dist/types/types/graph-element.d.ts +16 -7
  40. package/dist/types/utils/canvasManagement.d.ts +18 -2
  41. package/dist/types/utils/circularUtils.d.ts +3 -0
  42. package/dist/types/utils/circularUtils.test.d.ts +1 -0
  43. package/dist/types/utils/colorUtils.d.ts +3 -3
  44. package/dist/types/utils/constants.d.ts +6 -4
  45. package/dist/types/utils/errors.d.ts +2 -1
  46. package/dist/types/utils/geometry.d.ts +31 -30
  47. package/dist/types/utils/graphObjectUtils.d.ts +5 -5
  48. package/dist/types/utils/hittest.d.ts +2 -0
  49. package/dist/types/utils/jsDriverResultTransformer.d.ts +14 -7
  50. package/dist/types/utils/segmentAnalytics.d.ts +8 -8
  51. package/dist/types/utils/zoomFunctions.d.ts +30 -23
  52. package/package.json +25 -24
  53. package/dist/types/modules/performance.d.ts +0 -93
  54. package/dist/types/renderers/canvasrenderer/CanvasRenderer.d.ts +0 -93
  55. package/dist/types/renderers/canvasrenderer/arrows/arrows.d.ts +0 -55
  56. package/dist/types/renderers/canvasrenderer/nodes/nodes.d.ts +0 -59
  57. package/dist/types/renderers/canvasrenderer/util.d.ts +0 -69
  58. /package/dist/types/{renderers/canvasrenderer/Animation.test.d.ts → layouts/d3forcelayout/circularLayout.test.d.ts} +0 -0
  59. /package/dist/types/renderers/{canvasrenderer/CanvasRenderer.test.d.ts → domrenderer/canvasrenderer/Animation.test.d.ts} +0 -0
  60. /package/dist/types/renderers/{canvasrenderer/ImageCache.test.d.ts → domrenderer/canvasrenderer/CanvasRenderer.test.d.ts} +0 -0
  61. /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundle.test.d.ts → domrenderer/shared/ImageCache.test.d.ts} +0 -0
  62. /package/dist/types/renderers/{canvasrenderer/arrows/ArrowBundler.test.d.ts → domrenderer/shared/arrows/ArrowBundle.test.d.ts} +0 -0
  63. /package/dist/types/renderers/{canvasrenderer/arrows/arrows.test.d.ts → domrenderer/shared/arrows/ArrowBundler.test.d.ts} +0 -0
  64. /package/dist/types/renderers/{canvasrenderer/nodes/nodes.test.d.ts → domrenderer/shared/arrows/arrows.test.d.ts} +0 -0
  65. /package/dist/types/renderers/{canvasrenderer → domrenderer/shared}/arrows/constants.d.ts +0 -0
  66. /package/dist/types/renderers/{canvasrenderer/util.test.d.ts → domrenderer/shared/nodes/nodes.test.d.ts} +0 -0
  67. /package/dist/types/renderers/{canvasrenderer/wordwrap.test.d.ts → domrenderer/shared/util.test.d.ts} +0 -0
@@ -1,8 +1,8 @@
1
1
  import type { ExternalCallbacks } from './modules/ExternalCallbackHandler';
2
- import type { ForceDirectedOptions, HierarchicalOptions, Layout, LayoutOptions, NvlOptions, NvlState, Renderer, ZoomOptions } from './modules/state/types';
3
- import { CanvasRendererType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
4
- import type { StyledCaption } from './renderers/canvasrenderer/types';
5
- import { drawCircleBand } from './renderers/canvasrenderer/util';
2
+ import type { CircularOptions, ForceDirectedOptions, HierarchicalOptions, Renderer as InternalRenderer, Layout, LayoutOptions, NvlOptions, NvlState, ZoomOptions } from './modules/state/types';
3
+ import { CanvasRendererType, CircularLayoutType, ForceDirectedLayoutType, FreeLayoutType, GridLayoutType, HierarchicalLayoutType, SvgRendererType, WebGLRendererType, d3ForceLayoutType } from './modules/state/types';
4
+ import { drawCircleBand } from './renderers/domrenderer/canvasrenderer/canvasUtils';
5
+ import type { StyledCaption } from './renderers/domrenderer/shared/types';
6
6
  import type { Node, PartialNode, PartialRelationship, Relationship } from './types/graph-element';
7
7
  import { CompatibilityError } from './utils/errors';
8
8
  import type { Point } from './utils/geometry';
@@ -11,9 +11,10 @@ import { nvlResultTransformer } from './utils/jsDriverResultTransformer';
11
11
  import { getZoomTargetForNodePositions } from './utils/zoomFunctions';
12
12
  /**
13
13
  * Extends the MouseEvent interface with the {@link HitTargets} property.
14
- * The result of a _.{@link NVL.getHits} call.
14
+ * The result of a {@link NVL.getHits} call.
15
15
  */
16
16
  interface NvlMouseEvent extends MouseEvent {
17
+ /** The graph elements that have been hit by the pointer event. */
17
18
  nvlTargets: HitTargets;
18
19
  }
19
20
  /**
@@ -39,24 +40,24 @@ declare class NVL {
39
40
  #private;
40
41
  /**
41
42
  * Creates a new NVL instance.
42
- * @param {HTMLElement} frame - The DOM element to display the graph in
43
- * @param {Node[]} nvlNodes - An Array of nodes
44
- * @param {Relationship[]} nvlRels - An Array of relationships
45
- * @param {NvlOptions} options - Options for the NVL instance
46
- * @param {ExternalCallbackHandler} callbacks - Callbacks triggered on NVL events
43
+ * @param frame - The DOM element to display the graph in.
44
+ * @param nvlNodes - An array of {@link Node nodes}.
45
+ * @param nvlRels - An array of {@link Relationship relationships}.
46
+ * @param options - The {@link NvlOptions options} for the NVL instance.
47
+ * @param callbacks - Callbacks triggered on NVL events.
47
48
  */
48
49
  constructor(frame: HTMLElement, nvlNodes?: Node[], nvlRels?: Relationship[], options?: NvlOptions, callbacks?: ExternalCallbacks);
49
50
  /**
50
51
  * Restarts the NVL instance.
51
- * @param {NvlOptions} options - new options for the NVL instance
52
- * @param {boolean} retainPositions - whether or not to retain the current node positions
52
+ * @param options - New {@link NvlOptions} for the NVL instance.
53
+ * @param retainPositions - Whether or not to retain the current node positions.
53
54
  * New options will be merged with current options
54
55
  */
55
56
  restart(options?: NvlOptions, retainPositions?: boolean): void;
56
57
  /**
57
58
  * Adds nodes and relationships to NVL and updates existing nodes and relationships.
58
- * @param {Node[] | PartialNode[]} nodes - An Array of nodes to be added or updated
59
- * @param {Relationship[] | PartialRelationship[]} relationships - An Array of relationships to be added or updated
59
+ * @param nodes - An Array of {@link Node nodes} to be added or updated.
60
+ * @param relationships - An Array of {@link Relationship relationships} to be added or updated.
60
61
  * To update nodes or relationships, they must have an id that matches the id of the
61
62
  * node or relationship to be updated.
62
63
  * Only the properties that are provided will be updated.
@@ -84,18 +85,18 @@ declare class NVL {
84
85
  addAndUpdateElementsInGraph(nodes?: Node[] | PartialNode[], relationships?: Relationship[] | PartialRelationship[]): void;
85
86
  /**
86
87
  * Gets the currently selected nodes.
87
- * @returns {(Node & Point)[]} An array of all currently selected nodes and their positions.
88
+ * @returns An array of all currently selected {@link Node nodes} and their positions.
88
89
  */
89
90
  getSelectedNodes(): (Node & Point)[];
90
91
  /**
91
92
  * Gets the currently selected relationships.
92
- * @returns {Relationship[]} An array of all currently selected relationships.
93
+ * @returns An array of all currently selected {@link Relationship relationships}.
93
94
  */
94
95
  getSelectedRelationships(): Relationship[];
95
96
  /**
96
97
  * Updates relationships in the current scene with the provided array of nodes and relationships.
97
- * @param {Node[] | PartialNode[]} nodes The updated nodes.
98
- * @param {Relationship[] | PartialRelationship[]} relationships The updated relationships.
98
+ * @param nodes - The updated {@link Node nodes}.
99
+ * @param relationships - The updated {@link Relationship relationships}.
99
100
  * Ignores any nodes or relationships that do not exist in the current scene.
100
101
  * To update nodes or relationships, they must have an id that matches the id of the
101
102
  * node or relationship to be updated.
@@ -121,54 +122,53 @@ declare class NVL {
121
122
  updateElementsInGraph(nodes: Node[] | PartialNode[], relationships: Relationship[] | PartialRelationship[]): void;
122
123
  /**
123
124
  * Adds nodes and relationships in the current scene.
124
- * @param {Node[]} nodes The nodes to be added.
125
- * @param {Relationship[]} relationships The relationships to be added.
125
+ * @param nodes - The nodes to be added.
126
+ * @param relationships - The relationships to be added.
126
127
  */
127
128
  addElementsToGraph(nodes: Node[], relationships: Relationship[]): void;
128
129
  /**
129
130
  * Removes the specified nodes from the current scene.
130
- * @param {string[]} nodeIds The node ids to be removed.
131
+ * @param nodeIds - The node ids to be removed.
131
132
  * Adjacent relationships will also be removed.
132
133
  */
133
134
  removeNodesWithIds(nodeIds: string[]): void;
134
135
  /**
135
136
  * Removes the specified relationships from the current scene.
136
- * @param {string[]} relationshipIds The relationship ids to be removed.
137
+ * @param relationshipIds - The relationship ids to be removed.
137
138
  */
138
139
  removeRelationshipsWithIds(relationshipIds: string[]): void;
139
140
  /**
140
141
  * Returns all nodes that is currently stored in the visualisation.
141
- * @returns {Node[]} The array of nodes.
142
+ * @returns The array of {@link Node nodes}.
142
143
  */
143
144
  getNodes(): Node[];
144
145
  /**
145
146
  * Returns the relationships that are currently in the visualization.
146
- * @returns {Relationship[]} An array of the relationships in the visualization.
147
+ * @returns An array of the {@link Relationship relationships} in the visualization.
147
148
  */
148
149
  getRelationships(): Relationship[];
149
150
  /**
150
151
  * Returns the node data that is currently stored in the visualisation for a given id.
151
- * @param {string} id The id of the node that should be returned.
152
- * @returns {Node} The node or undefined if there is no node with the given id.
152
+ * @param id - The id of the {@link Node node} that should be returned.
153
+ * @returns The {@link Node node} or undefined if there is no node with the given id.
153
154
  */
154
155
  getNodeById(id: string): Node;
155
156
  /**
156
157
  * Returns the relationship data that is currently stored in the visualisation for a given id.
157
- * @param {string} id The id of the relationship that should be returned.
158
- * @returns {Relationship} The relationship or undefined if there is no relationship with the given id.
158
+ * @param id - The id of the {@link Relationship relationship} that should be returned.
159
+ * @returns The {@link Relationship relationship} or undefined if there is no relationship with the given id.
159
160
  */
160
161
  getRelationshipById(id: string): Relationship;
161
162
  /**
162
163
  * Returns the node position that is currently stored in the visualisation for a given id.
163
- * @param {string} id The id of the node position that should be returned.
164
- * @returns {Node} The position information for the given id, or undefined if there is no such node
164
+ * @param id - The id of the node position that should be returned.
165
+ * @returns The position information for the given id, or undefined if there is no such {@link Node node}.
165
166
  * or the layout has not yet run with that node.
166
167
  */
167
168
  getPositionById(id: string): Node;
168
169
  /**
169
170
  * Returns the current options.
170
- * @returns {NvlOptions} The current options.
171
- * @internal
171
+ * @returns The current options.
172
172
  */
173
173
  getCurrentOptions(): NvlOptions;
174
174
  /** Removes the graph visualization from the DOM and cleans up everything. */
@@ -179,26 +179,21 @@ declare class NVL {
179
179
  deselectAll(): void;
180
180
  /**
181
181
  * Updates pan and zoom fit the specified nodes in the viewport.
182
- * @param {string[]} nodeIds The ids of the nodes to fit on the screen,
183
- * @param {NvlState['zoomOptions']} zoomOptions specific options on how to transition the zoom
182
+ * @param nodeIds - The ids of the nodes to fit on the screen.
183
+ * @param zoomOptions - Specific options on how to transition the zoom.
184
+ *
185
+ * @remarks
184
186
  * If the zoom level required to fit the provided nodes is outside of the range provided by the
185
- * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
186
- * and {@link NvlOptions.allowDynamicMinZoom} is set to `false`,
187
+ * {@link NvlOptions.minZoom minZoom} and {@link NvlOptions.maxZoom maxZoom} options, and the
188
+ * {@link NvlOptions.allowDynamicMinZoom allowDynamicMinZoom} option is set to `false`,
187
189
  * the zoom level will be set to the closest valid zoom level,
188
190
  * even if the given nodes do not fit the viewport yet.
189
191
  */
190
192
  fit(nodeIds: string[], zoomOptions?: NvlState['zoomOptions']): void;
191
193
  /**
192
- * Resets the zoom of the viewport back to the default zoom level of 0.75
194
+ * Resets the zoom of the viewport back to the default zoom level of 0.75.
193
195
  */
194
196
  resetZoom(): void;
195
- /**
196
- * Toggles between the WebGL and Canvas rendering.
197
- * @deprecated use {@link setRenderer} instead.
198
- * @param {boolean} enabled Whether or not WebGL renderer should be used.
199
- * @internal
200
- */
201
- setUseWebGLRenderer(enabled: boolean): void;
202
197
  /**
203
198
  * Switches between rendering methods
204
199
  * @param renderer - which rendering method to use
@@ -206,79 +201,99 @@ declare class NVL {
206
201
  setRenderer(renderer: string): void;
207
202
  /**
208
203
  * Restarts NVL with or without WebGL support.
209
- * @param {boolean} disabled Whether or not WebGL should be disabled.
210
- * Not to be confused with {@link setUseWebGLRenderer}, which only affects the rendering method
204
+ * @param disabled - Whether or not WebGL should be disabled.
211
205
  * @experimental
212
206
  */
213
207
  setDisableWebGL(disabled?: boolean): void;
214
208
  /**
215
209
  * Pins the specified node so it is not affected by layout forces.
216
- * @param {string} nodeId The id of the node to be pinned.
210
+ * @param nodeId - The id of the node to be pinned.
217
211
  */
218
212
  pinNode(nodeId: string): void;
219
213
  /**
220
214
  * Un-pins the specified nodes so it is affected by layout forces again.
221
- * @param {string[]} nodeIds The ids of the nodes to be un-pinned.
215
+ * @param nodeIds The ids of the nodes to be un-pinned.
222
216
  */
223
217
  unPinNode(nodeIds: string[]): void;
224
218
  /**
225
219
  * Changes the layout type.
226
- * @param {Layout} layout The layout type.
220
+ * @param layout - The {@link Layout} type.
227
221
  */
228
222
  setLayout(layout: Layout): void;
229
223
  /**
230
224
  * Updates the configuration of the current layout.
231
- * @param {LayoutOptions} options The layout configuration.
225
+ * @param options - The {@link LayoutOptions} configuration.
232
226
  */
233
227
  setLayoutOptions(options: LayoutOptions): void;
234
228
  /**
235
229
  * Returns the nodes that are currently in the visualization.
236
230
  * The `rels` property of the returned object is always empty.
237
- * @returns {{ nodes: Node[], rels: Relationship [] }} An array of the nodes in the visualization.
231
+ * @returns An object containing the nodes and relationships in the visualization.
238
232
  */
239
233
  getNodesOnScreen(): {
234
+ /** The nodes in the visualization. */
240
235
  nodes: Node[];
236
+ /** The relationships in the visualization. */
241
237
  rels: Relationship[];
242
238
  };
243
239
  /**
244
240
  * Fetches and returns the current positions of all nodes as an array of coordinates.
245
- * @returns {(Node & Point)[]} An array of node positions.
241
+ * @returns An array of {@link Node node} positions.
246
242
  */
247
243
  getNodePositions(): (Node & Point)[];
248
244
  /**
249
- * Sets the node positions based on data provided
250
- * @param {Node[]} data The positions that the nodes should be set to.
251
- * @param {boolean} updateLayout whether or not the current layout algorithm
245
+ * Sets the node positions based on data provided.
246
+ * @param data - The positions that the nodes should be set to.
247
+ * @param updateLayout - Whether or not the current layout algorithm
252
248
  * should update the graph after setting the node positions.
253
- * For node positions to be unaffected by layout algorithms, use the {@link FreeLayoutType}
249
+ *
250
+ * @remarks
251
+ * For node positions to be unaffected by layout algorithms, use the 'free' layout type
254
252
  * or use {@link pinNode} to pin the nodes that should remain still.
255
253
  * False by default.
256
254
  */
257
255
  setNodePositions(data: Node[], updateLayout?: boolean): void;
258
256
  /**
259
257
  * Checks and returns whether the current layout is still in flux.
260
- * @returns {boolean} Whether or not the layout is moving.
258
+ * @returns Whether or not the layout is moving.
261
259
  */
262
260
  isLayoutMoving(): boolean;
263
261
  /**
264
262
  * Saves the current view of the graph visualization canvas as a png to the client.
265
263
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
266
- * @param {string} options.filename The filename of the png file.
267
- * @param {string} options.backgroundColor - The background color of the png file.
264
+ * @param options.filename - The filename of the png file.
265
+ * @param options.backgroundColor - The background color of the png file.
268
266
  * The size of the png file will be the size of the canvas in the DOM.
269
267
  */
270
268
  saveToFile(options?: {
271
269
  filename?: string;
272
270
  backgroundColor?: string;
273
271
  }): void;
272
+ /**
273
+ * Saves the entire graph visualization as an SVG file to the client.
274
+ * @param options - Options for the SVG export
275
+ * @param options.filename - The filename of the SVG file.
276
+ * @param options.backgroundColor - The background color of the SVG file.
277
+ * @experimental
278
+ */
279
+ saveToSvg(options?: {
280
+ filename?: string;
281
+ backgroundColor?: string;
282
+ }): void;
283
+ /**
284
+ * Returns the current view of the graph visualization canvas as a data URL.
285
+ * @param options - The options for the image.
286
+ * @param options.backgroundColor - The background color of the data URL.
287
+ * @returns A data URL of the current view of the graph visualization canvas.
288
+ */
274
289
  getImageDataUrl(options?: {
275
290
  backgroundColor?: string;
276
291
  }): string;
277
292
  /**
278
293
  * Saves the entire graph visualization canvas as a png to the client.
279
294
  * @param {{ filename: string, backgroundColor: string }} options The filename and background color of the png.
280
- * @param {string} options.filename The filename of the png file.
281
- * @param {string} options.backgroundColor - The background color of the png file.
295
+ * @param options.filename - The filename of the png file.
296
+ * @param options.backgroundColor - The background color of the png file.
282
297
  * The size of the png file will be as large as the entire graph at the default zoom level.
283
298
  * Can result in a very large file.
284
299
  */
@@ -288,32 +303,35 @@ declare class NVL {
288
303
  }): void;
289
304
  /**
290
305
  * Sets the zoom of the viewport to a specific value.
291
- * @param {number} absolute The desired zoom level.
306
+ * @param zoomValue - The desired zoom level.
307
+ * @remarks
308
+ *
292
309
  * When updating both the zoom level and pan coordinates,
293
310
  * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
294
311
  * separately to avoid jittering.
312
+ *
295
313
  * If the zoom level is outside of the range provided by the
296
314
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
297
315
  * the zoom level will be set to the closest valid zoom level.
298
316
  * If {@link NvlOptions.allowDynamicMinZoom} is set to true,
299
317
  * the {@link NvlOptions.minZoom} option will be ignored of the current graph does not fit the viewport.
300
318
  */
301
- setZoom(absolute: number): void;
319
+ setZoom(zoomValue: number): void;
302
320
  /**
303
321
  * Sets the zoom of the viewport to a specific value.
304
- * @param {number} panX The desired panX value.
305
- * @param {number} panY The desired panY value.
306
- * When updating both the zoom level and pan coordinates,
307
- * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan}
308
- * separately to avoid jittering.
322
+ * @param panX - The desired panX value.
323
+ * @param panY - The desired panY value.
324
+ * @remarks When updating both the zoom level and pan coordinates,
325
+ * use {@link setZoomAndPan} instead of calling {@link setZoom} and {@link setPan} separately to avoid jittering.
309
326
  */
310
327
  setPan(panX: number, panY: number): void;
311
328
  /**
312
329
  * Sets the zoom and pan of the viewport to specific values.
313
- * @param {number} zoom The desired zoom level.
314
- * @param {number} panX The desired panX value.
315
- * @param {number} panY The desired panY value.
316
- * When only updating the zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
330
+ * @param zoom - The desired zoom level.
331
+ * @param panX - The desired panX value.
332
+ * @param panY - The desired panY value.
333
+ * @remarks When only updating zoom level or pan coordinates, use {@link setZoom} or {@link setPan} instead.
334
+ *
317
335
  * If the zoom level is outside of the range provided by the
318
336
  * {@link NvlOptions.minZoom} and {@link NvlOptions.maxZoom} options,
319
337
  * the zoom level will be set to the closest valid zoom level.
@@ -323,18 +341,18 @@ declare class NVL {
323
341
  setZoomAndPan(zoom: number, panX: number, panY: number): void;
324
342
  /**
325
343
  * Get the current zoom level of the viewport.
326
- * @returns {number} The current zoom level
344
+ * @returns The current zoom level.
327
345
  */
328
346
  getScale(): number;
329
347
  /**
330
348
  * Returns the current pan of the viewport.
331
- * @returns {Point} The current pan of the viewport.
349
+ * @returns The current pan of the viewport.
332
350
  */
333
351
  getPan(): Point;
334
352
  /**
335
353
  * Gets the nodes and relationships that have been hit by a pointer event.
336
- * @param evt The mouse event.
337
- * @param targets The graph elements to check for hits. Defaults to ['node', 'relationship'].
354
+ * @param evt - The mouse event.
355
+ * @param targets - The graph elements to check for hits. Defaults to ['node', 'relationship'].
338
356
  * @param hitOptions - Options for the hit test.
339
357
  * @returns A {@link NvlMouseEvent} with the {@link HitTargets} property
340
358
  * containing the nodes and relationships that have been hit by the pointer event.
@@ -364,10 +382,15 @@ declare class NVL {
364
382
  /**
365
383
  * Functions for mapping colors.
366
384
  * @internal
385
+ * @hidden
367
386
  */
368
387
  declare const colorMapperFunctions: {
369
388
  textColorForBackground: (color: string) => string;
370
389
  };
390
+ /**
391
+ * The different types of renderers available
392
+ */
393
+ type Renderer = Exclude<InternalRenderer, typeof SvgRendererType>;
371
394
  export default NVL;
372
- export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
373
- export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
395
+ export type { NvlOptions, Renderer, Node, Relationship, PartialNode, PartialRelationship, Layout, LayoutOptions, ForceDirectedOptions, HierarchicalOptions, CircularOptions, ExternalCallbacks, HitTargets, HitTargetNode, HitTargetRelationship, Point, NvlMouseEvent, ZoomOptions, StyledCaption, WebGLRendererType, CanvasRendererType };
396
+ export { NVL, colorMapperFunctions, CompatibilityError, ForceDirectedLayoutType, HierarchicalLayoutType, GridLayoutType, FreeLayoutType, d3ForceLayoutType, CircularLayoutType, drawCircleBand, nvlResultTransformer, getZoomTargetForNodePositions };
@@ -2,8 +2,8 @@ import type { Node } from '../../types/graph-element';
2
2
  import type { Point } from '../../utils/geometry';
3
3
  /**
4
4
  * Calculates the average node coordinates for a given set of nodes.
5
- * @param {Node[]} nodes The nodes to calculate the average position for.
6
- * @param {Record<string, Node | Point>} positions The positions of the nodes.
7
- * @returns {number[]} The average node coordinates.
5
+ * @param nodes - The nodes to calculate the average position for.
6
+ * @param positions - The positions of the nodes.
7
+ * @returns The average node coordinates.
8
8
  */
9
9
  export declare const calculateAverageNodePosition: (nodes: Node[], positions: Record<string, Node | Point>) => number[];
@@ -0,0 +1,18 @@
1
+ import type { CircularOptions, LayoutOptions, NvlState } from '../../modules/state/types';
2
+ import AnimatedLayout from '../animatedlayout/AnimatedLayout';
3
+ type CircularLayoutConfig = {
4
+ state: NvlState;
5
+ } & CircularOptions;
6
+ export declare class CircularLayout extends AnimatedLayout {
7
+ private stateDisposers;
8
+ private sortFunction;
9
+ constructor(config: CircularLayoutConfig);
10
+ setOptions(options?: LayoutOptions): void;
11
+ update(refreshPositions?: boolean): void;
12
+ getShouldUpdate(): boolean;
13
+ getComputing(): boolean;
14
+ private layout;
15
+ terminateUpdate(): void;
16
+ destroy(): void;
17
+ }
18
+ export {};
@@ -16,7 +16,7 @@ export declare class ForceCytoLayout {
16
16
  getShouldUpdate(): boolean;
17
17
  getComputing(): boolean;
18
18
  updateNodes(positionList: any): void;
19
- getNodePositions(data: any): import("../../types/graph-element").Node[];
19
+ getNodePositions(data: any): import("../..").Node[];
20
20
  terminateUpdate(): void;
21
21
  destroy(): void;
22
22
  }
@@ -52,30 +52,35 @@ export declare class PhysLayout {
52
52
  private pinTexture;
53
53
  private addedNodes;
54
54
  private updateTexture;
55
+ private vaoExt;
56
+ private physVao;
57
+ private physSmallVao;
58
+ private updateVao;
59
+ private workaroundVao;
55
60
  enableVerlet: boolean;
56
61
  constructor(config: ForceDirectedOptions & {
57
- webGLContext: WebGL2RenderingContext;
62
+ webGLContext: WebGLRenderingContext;
58
63
  state: NvlState;
59
64
  });
60
65
  /**
61
- * Sets the layout options
62
- * @param {ForceDirectedOptions} options the object with the options
63
- * @param {boolean} [initial=false] whether this is the first setting of options
66
+ * Sets the layout options.
67
+ * @param options - The object with the options.
68
+ * @param initial - Whether this is the first setting of options.
64
69
  */
65
70
  setOptions(options?: ForceDirectedOptions, initial?: boolean): void;
66
71
  /**
67
72
  * Sets graph data to be used
68
73
  * @param {{ nodes: Node[]; rels: Relationship[] }} data the graph object
69
- * @returns the top level graph of the subgraphs created by the solar merger
74
+ * @returns The top level graph of the subgraphs created by the solar merger.
70
75
  */
71
76
  setData(data: {
72
77
  nodes: Node[];
73
78
  rels: Relationship[];
74
- }): any;
79
+ }): import("./solarmerger/types").CoarsenedGraph;
75
80
  /**
76
81
  * Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
77
82
  * @param refreshPositions whether the entire layout should be reheated
78
- * @returns whether the layout should update in the following step
83
+ * @returns Whether the layout should update in the following step.
79
84
  */
80
85
  update(refreshPositions?: boolean): boolean;
81
86
  /**
@@ -84,24 +89,24 @@ export declare class PhysLayout {
84
89
  terminateUpdate(): void;
85
90
  /**
86
91
  * Returns whether the current layout needs to be updated in the next iteration step.
87
- * @returns {boolean} Whether the layout should update in the following step.
92
+ * @returns Whether the layout should update in the following step.
88
93
  */
89
94
  getShouldUpdate(): boolean;
90
95
  /**
91
96
  * Returns whether the current layout is computing.
92
97
  * Always returns false because the force-directed layout has no computing step
93
- * @returns {boolean} Whether the layout is computing.
98
+ * @returns Whether the layout is computing.
94
99
  */
95
100
  getComputing(): boolean;
96
101
  /**
97
102
  * Adds the current x,y coordinates for each node to a given list of nodes.
98
- * @param {Node[]} nodeList The list of nodes to get positions for.
99
- * @returns {(Node & Point)[]} The list of nodes containing the x,y coordinates on each node object.
103
+ * @param nodeList - The list of nodes to get positions for.
104
+ * @returns The list of nodes containing the x,y coordinates on each node object.
100
105
  */
101
106
  getNodePositions(nodeList: Node[]): (Node & Point)[];
102
107
  /**
103
108
  * Reheats the layout
104
- * @param {Object} fullData The entire graph object.
109
+ * @param fullData - The entire graph object.
105
110
  */
106
111
  reheat(fullData: {
107
112
  nodes: Node[];
@@ -109,17 +114,17 @@ export declare class PhysLayout {
109
114
  }): void;
110
115
  /**
111
116
  * Updates the existing nodes of a graph with a given list of updates
112
- * @param {Node[]} nodeList The list of updates.
117
+ * @param nodeList - The list of updates.
113
118
  */
114
119
  updateNodes(nodeList: Node[]): void;
115
120
  /**
116
121
  * Adds and removes nodes from the graph based on given updates
117
- * @param {Object} fullData The entire graph object.
118
- * @param {Array<Object>} fullData.nodes the nodes in the graph
119
- * @param {Array<Object>} fullData.rels the relationships in the graph
120
- * @param {Object} nodeChanges The changes in the graph.
121
- * @param {Array<Object>} nodeChanges.adds A list of nodes to be added.
122
- * @param {Array<Object>} nodeChanges.removes A list of nodes to be removed.
122
+ * @param fullData - The entire graph object.
123
+ * @param fullData.nodes - The nodes in the graph.
124
+ * @param fullData.rels - The relationships in the graph.
125
+ * @param nodeChanges - The changes in the graph.
126
+ * @param nodeChanges.adds - A list of nodes to be added.
127
+ * @param nodeChanges.removes - A list of nodes to be removed.
123
128
  */
124
129
  addRemoveData(fullData: {
125
130
  nodes: Node[];
@@ -130,18 +135,18 @@ export declare class PhysLayout {
130
135
  }, relationshipChanges: {
131
136
  adds: Record<string, Relationship>;
132
137
  removes: Record<string, Relationship>;
133
- }): any;
138
+ }): import("./solarmerger/types").CoarsenedGraph;
134
139
  /**
135
140
  * Destroys the class and all buffers and textures.
136
141
  */
137
142
  destroy(): void;
138
143
  /**
139
144
  * Takes the new flat key set of relationships and the current relationship changes
140
- * and checks whether removed relationships are still in the new flat key set
145
+ * and checks whether removed relationships are still in the new flat key set.
141
146
  * and whether added relationships were already in the old flat key set.
142
147
  * @param newFlatKeySet The new flat key set of relationships.
143
148
  * @param relationshipChanges The changes in the relationships.
144
- * @returns {boolean} Whether the relationship flat map has changed.
149
+ * @returns Whether the relationship flat map has changed.
145
150
  */
146
151
  private hasRelationshipFlatMapChanged;
147
152
  private dumpTexture;
@@ -1,2 +1,2 @@
1
- declare const _default: "precision 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;\n\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TEMP = max(0.02, pow(COOL, u_curIteration));\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 texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, 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).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\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);\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 float clusterWeight = clusterData.w;\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).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\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);\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 float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || 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 float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\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;\n acceleration += grav * smoothstep(0.0, 500.0, dist);\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 if (u_curIteration == 0.0) {\n gl_FragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n vec2 prevPos = currentPos - prevVelocity;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n gl_FragColor = vec4(newPos, newVelocity);\n }\n}";
1
+ declare const _default: "precision 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;\n\n\nfloat DAMP = 0.6;\nfloat COOL = 0.99998;\nfloat TEMP = max(0.02, pow(COOL, u_curIteration));\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 texture, float index, float base) {\n float x = mod(index, base);\n float y = (index - x) / base;\n return texture2D(texture, 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).a;\n return nodeSize + otherNodeSize;\n}\n\nvec2 getSpringForce(float curConnection, float numConnections, float springFScale, vec4 myPosition, float i) {\n float curSpring = getTextureData(u_connections, curConnection + i, 4096.0).a;\n\n vec4 otherPosition = getTextureData(u_physData, curSpring, 256.0);\n float otherDataPosition = getTextureData(u_connectionOffsets, curSpring, 256.0).a;\n float avgDegree;\n#if INTEL_WORKAROUND\n avgDegree = max(numConnections, 4.0);\n#else\n float otherNumConnections = getTextureData(u_connections, otherDataPosition, 4096.0).a;\n avgDegree = max((otherNumConnections + numConnections * 3.0) / 4.0, 4.0);\n#endif\n\n vec2 delta = getDelta(myPosition.xy, otherPosition.xy);\n float dist = length(delta);\n\n float F = (dist * dist * springFScale) / (u_baseLength * avgDegree);\n if (u_collisionMultiplier > 0.0) {\n F *= u_collisionMultiplier;\n }\n return (-delta / dist) * F;\n}\n\nvec2 getCollisionForce(float combinedNodeSize, float dist, float fScale, vec2 delta) {\n float collisionForce = (combinedNodeSize - dist) / (dist);\n if (u_collisionMultiplier > 0.0) {\n collisionForce *= u_collisionMultiplier;\n }\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);\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 float clusterWeight = clusterData.w;\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).a;\n float nodeSize = getTextureData(u_sizeTexture, index, 256.0).a;\n\n if (isPinned > 0.5) {\n gl_FragColor = vec4(myPosition.xy, 0.0, 0.0);\n return;\n }\n\n float curConnection = getTextureData(u_connectionOffsets, index, 256.0).a;\n float numConnections = getTextureData(u_connections, curConnection, 4096.0).a;\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);\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 float combinedNodeSize = getCombinedNodeSize(i, nodeSize) * 2.0;\n\n if (dist < combinedNodeSize && number_of_collisions < 40.0) {\n number_of_collisions++;\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n if (i >= clusterStartIndex && i < clusterStartIndex + clusterSize) {\n acceleration += getRepulsionForce(dist, fScale, delta);\n }\n }\n } else {\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n\n if (i < clusterStartIndex || 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 float combinedNodeSize = getCombinedNodeSize(i, nodeSize);\n\n if (dist < combinedNodeSize) {\n acceleration += getCollisionForce(combinedNodeSize, dist, fScale, delta);\n }\n\n acceleration += getRepulsionForce(dist, fScale, delta);\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 if (u_curIteration == 0.0) {\n gl_FragColor = vec4(myPosition.xy, myPosition.zw);\n } else {\n vec2 prevVelocity = myPosition.zw;\n vec2 currentPos = myPosition.xy;\n vec2 prevPos = currentPos - prevVelocity;\n\n vec2 newPos = currentPos + TEMP * ( DAMP * (prevVelocity) + acceleration * TIMESTEP * TIMESTEP);\n vec2 newVelocity = newPos - currentPos;\n gl_FragColor = vec4(newPos, newVelocity);\n }\n}";
2
2
  export default _default;
@@ -1,43 +1,21 @@
1
+ import type { Node, Relationship } from '../../../../types/graph-element';
2
+ import type { CoarsenedGraph, SolarRelationship } from './types';
1
3
  export default class SolarMerger {
2
- constructor(graph: any, nodeIdToIndex: any);
3
4
  graph: {
4
- nodes: any[];
5
- relationships: any[];
6
- idToRel: {};
7
- };
8
- subGraphs: any[];
9
- sunMap: {};
10
- constructGraphObjects(graph: any, nodeIdToIndex: any): {
11
- nodes: any[];
12
- relationships: any[];
13
- idToRel: {};
14
- };
15
- relIdMap: any[];
16
- coarsenTo(targetSize: any): {
17
- nodes: any[];
18
- relationships: any[];
19
- idToRel: {};
20
- };
21
- nodeSortMap: {};
22
- coarsenBy(levelToCoarsenBy: any): {
23
- nodes: any[];
24
- relationships: any[];
25
- idToRel: {};
26
- };
27
- coarsen({ nodes, relationships }: {
28
- nodes: any;
29
- relationships: any;
30
- }, firstIteration: any): {
31
- output: {
32
- nodes: {
33
- id: any;
34
- }[];
35
- relationships: any[];
36
- };
37
- sortedInput: {
38
- nodes: any[];
39
- relationships: any[];
40
- };
41
- nodeSortMap: {};
5
+ nodes: Node[];
6
+ relationships: number[][];
7
+ idToRel: Record<string, SolarRelationship>;
42
8
  };
9
+ subGraphs: CoarsenedGraph[];
10
+ sunMap: Record<string, string>;
11
+ relIdMap: string[][];
12
+ nodeSortMap?: Record<number, number>;
13
+ constructor(inputGraph: {
14
+ nodes: Node[];
15
+ rels: Relationship[];
16
+ }, nodeIdToIndex: Record<string, number>);
17
+ private constructGraphObjects;
18
+ coarsenTo(targetSize: number): CoarsenedGraph;
19
+ coarsenBy(levelToCoarsenBy: number): CoarsenedGraph;
20
+ private coarsen;
43
21
  }