@neo4j-nvl/base 0.3.7 → 0.3.8-8b34b51d
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 +37 -0
- package/dist/base.mjs +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/PhysLayout.d.ts +8 -7
- package/dist/types/layouts/forcedirectedlayout/physlayout/shaders/multilevel-repulsive-fragment-verlet.d.ts +1 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/SolarMerger.d.ts +17 -39
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/solar-placer.d.ts +4 -1
- package/dist/types/layouts/forcedirectedlayout/physlayout/solarmerger/types.d.ts +48 -0
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/jsDriverResultTransformer.d.ts +4 -1
- package/package.json +4 -3
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { ForceDirectedOptions, NvlState } from '../../../modules/state/types';
|
|
2
2
|
import type { Node, Relationship } from '../../../types/graph-element';
|
|
3
3
|
import type { Point } from '../../../utils/geometry';
|
|
4
|
+
import type { CoarsenedGraph } from './solarmerger/types';
|
|
4
5
|
export declare class PhysLayout {
|
|
5
6
|
private physVbo;
|
|
6
7
|
private physSmallVbo;
|
|
7
8
|
private physProjection;
|
|
8
9
|
private physSmallProjection;
|
|
9
10
|
private gl;
|
|
10
|
-
private
|
|
11
|
+
private useReadPixelWorkaround;
|
|
11
12
|
private averageNodeSize;
|
|
12
13
|
private shouldUpdate;
|
|
13
14
|
private iterationCount;
|
|
@@ -31,10 +32,10 @@ export declare class PhysLayout {
|
|
|
31
32
|
private nodeSortMap;
|
|
32
33
|
private firstUpdate;
|
|
33
34
|
private curPhysData;
|
|
34
|
-
private
|
|
35
|
+
private approxRepForceShader;
|
|
35
36
|
private levelsClusterTexture;
|
|
36
37
|
private levelsFinestIndexTexture;
|
|
37
|
-
private
|
|
38
|
+
private initialLevelTexture;
|
|
38
39
|
private levelsData;
|
|
39
40
|
private collisionDetectionMultiplier;
|
|
40
41
|
private physShader;
|
|
@@ -70,7 +71,7 @@ export declare class PhysLayout {
|
|
|
70
71
|
setData(data: {
|
|
71
72
|
nodes: Node[];
|
|
72
73
|
rels: Relationship[];
|
|
73
|
-
}):
|
|
74
|
+
}): CoarsenedGraph;
|
|
74
75
|
/**
|
|
75
76
|
* Updates the node's positions for the next step in the physics layout iterations if the layout needs to update
|
|
76
77
|
* @param refreshPositions whether the entire layout should be reheated
|
|
@@ -126,7 +127,7 @@ export declare class PhysLayout {
|
|
|
126
127
|
}, nodeChanges: {
|
|
127
128
|
adds: Record<string, Node>;
|
|
128
129
|
removes: Record<string, Node>;
|
|
129
|
-
}):
|
|
130
|
+
}): CoarsenedGraph;
|
|
130
131
|
/**
|
|
131
132
|
* Destroys the class and all buffers and textures.
|
|
132
133
|
*/
|
|
@@ -151,7 +152,7 @@ export declare class PhysLayout {
|
|
|
151
152
|
private setupPhysicsForCoarse;
|
|
152
153
|
private setupPinData;
|
|
153
154
|
private setupUpdates;
|
|
154
|
-
private
|
|
155
|
-
private
|
|
155
|
+
private setupReadPixelWorkaround;
|
|
156
|
+
private doReadPixelWorkaround;
|
|
156
157
|
private definePhysicsArrays;
|
|
157
158
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "precision 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\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 0
|
|
1
|
+
declare const _default: "precision 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\nfloat PI = 3.1415926535897932384626433832795;\nfloat TIMESTEP = 1.0 / 30.0;\nfloat VELOCITYDECAY = 1.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\nfloat getSquaredLogClusterWeight(float value) {\n return pow(log(value), 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\n float clusterIndex = clusterData.x;\n float clusterStartIndex = clusterData.y;\n float clusterSize = clusterData.z;\n float clusterArea = pow(clusterSize + u_baseLength * 2.0, 2.0);\n\n float finestIndex = getTextureData(u_finestIndexes, index, 256.0).a;\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 // Repulsion & Collision Detection\n for (float i = 0.0; i < 256.0 * 256.0; i++) {\n if (i >= clusterStartIndex + clusterSize || i >= u_numNodes) {\n break;\n }\n if (i < clusterStartIndex || i == index) {\n continue;\n }\n\n vec4 otherClusterData = getTextureData(u_clusterData, i, 256.0);\n float otherClusterWeight = getSquaredLogClusterWeight(otherClusterData.w);\n\n float otherFinestIndex = getTextureData(u_finestIndexes, i, 256.0).a;\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 F = (clusterArea * fScale) / (dist * dist);\n\n if (u_isTopLevel == 1.0) {\n repulsionForceScale = 0.2;\n }\n\n acceleration += ((delta / sqrt(dist)) * F) * repulsionForceScale * otherClusterWeight;\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 gl_FragColor = vec4(acceleration, vec2(finestIndex, 0));\n}";
|
|
2
2
|
export default _default;
|
|
@@ -1,43 +1,21 @@
|
|
|
1
|
+
import type { Node, Relationship } from '../../../../types/graph-element';
|
|
2
|
+
import type { CoarsenedGraph, SolarNode, SolarRelationship } from './types';
|
|
1
3
|
export default class SolarMerger {
|
|
2
|
-
constructor(graph: any, nodeIdToIndex: any);
|
|
3
4
|
graph: {
|
|
4
|
-
nodes:
|
|
5
|
-
relationships:
|
|
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: SolarNode[];
|
|
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
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Point } from '../../../../utils/geometry';
|
|
2
|
-
export declare const calculatePositions: (centre: Point, r: number, noOfChildren: number) =>
|
|
2
|
+
export declare const calculatePositions: (centre: Point, r: number, noOfChildren: number) => {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Node } from '../../../../types/graph-element';
|
|
2
|
+
export interface SolarNode extends Node {
|
|
3
|
+
id: string;
|
|
4
|
+
solarId: number;
|
|
5
|
+
weight?: number;
|
|
6
|
+
finestIndex?: number;
|
|
7
|
+
originalId?: string;
|
|
8
|
+
position?: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
placement?: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface SolarRelationship {
|
|
18
|
+
id: string;
|
|
19
|
+
from: string;
|
|
20
|
+
to: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CoarsenedGraph {
|
|
23
|
+
nodes: Sun[];
|
|
24
|
+
relationships: number[][];
|
|
25
|
+
idToRel: Record<string, SolarRelationship>;
|
|
26
|
+
}
|
|
27
|
+
export interface Sun extends SolarNode {
|
|
28
|
+
planets?: Planet[];
|
|
29
|
+
solarSize?: () => number;
|
|
30
|
+
children?: () => Planet[];
|
|
31
|
+
previousIndex?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface Planet extends SolarNode {
|
|
34
|
+
parent: Sun;
|
|
35
|
+
sunId: number;
|
|
36
|
+
moons: Moon[];
|
|
37
|
+
solarSize: () => number;
|
|
38
|
+
children: () => Moon[];
|
|
39
|
+
}
|
|
40
|
+
export interface Moon extends SolarNode {
|
|
41
|
+
parent: Planet;
|
|
42
|
+
sunId: number;
|
|
43
|
+
solarSize: () => number;
|
|
44
|
+
}
|
|
45
|
+
export type Celestial = Sun | Planet | Moon;
|
|
46
|
+
export declare const isSun: (node: SolarNode | Celestial) => node is Sun;
|
|
47
|
+
export declare const isPlanet: (node: SolarNode | Celestial) => node is Planet;
|
|
48
|
+
export declare const isMoon: (node: SolarNode | Celestial) => node is Moon;
|
|
@@ -4,7 +4,7 @@ export declare const MaxIndexBuffer = 65536;
|
|
|
4
4
|
export declare const MinRelLength = 100;
|
|
5
5
|
export declare const Gravity = 100;
|
|
6
6
|
export declare const SimulationStopVelocity = 100;
|
|
7
|
-
export declare const VerletSimulationStopVelocity = 0.
|
|
7
|
+
export declare const VerletSimulationStopVelocity = 0.25;
|
|
8
8
|
export declare const MappingEnd = 999999;
|
|
9
9
|
export declare const ActiveAnimDuration = 1000;
|
|
10
10
|
export declare const DefaultNodeSize = 25;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Node as DriverNode, Relationship as DriverRelationship, Path, Record } from 'neo4j-driver';
|
|
2
2
|
export declare const recordMapper: (record: Record) => any[];
|
|
3
|
-
|
|
3
|
+
type GraphElement = DriverNode | DriverRelationship | Path;
|
|
4
|
+
type NestedGraphElements = GraphElement | NestedGraphElements[];
|
|
5
|
+
export declare const recordCollector: (graphElements: NestedGraphElements[]) => {
|
|
4
6
|
recordObjectMap: Map<any, any>;
|
|
5
7
|
nodes: any[];
|
|
6
8
|
relationships: any[];
|
|
@@ -30,3 +32,4 @@ export declare const nvlResultTransformer: import("neo4j-driver-core/types/resul
|
|
|
30
32
|
nodes: any[];
|
|
31
33
|
relationships: any[];
|
|
32
34
|
}>;
|
|
35
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-nvl/base",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8-8b34b51d",
|
|
4
4
|
"license": "SEE LICENSE IN 'LICENSE.txt'",
|
|
5
5
|
"homepage": "https://neo4j.com/docs/nvl/current/",
|
|
6
6
|
"description": "Base library for the Neo4j Visualization Library",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"postpack": "rm LICENSE.txt && rm CHANGELOG.md"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@neo4j-nvl/layout-workers": "0.3.
|
|
31
|
+
"@neo4j-nvl/layout-workers": "0.3.8-8b34b51d",
|
|
32
32
|
"@segment/analytics-next": "^1.70.0",
|
|
33
33
|
"color-string": "^1.9.1",
|
|
34
34
|
"d3-force": "^3.0.0",
|
|
@@ -57,5 +57,6 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"neo4j-driver": "*"
|
|
60
|
-
}
|
|
60
|
+
},
|
|
61
|
+
"stableVersion": "0.3.8"
|
|
61
62
|
}
|