plebeiangraphlibrary 2.0.1 → 2.1.2
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/Build/Core/Edge.d.ts +20 -0
- package/Build/Core/Graph.d.ts +114 -0
- package/Build/Core/_Node.d.ts +20 -0
- package/Build/Core/index.d.ts +3 -0
- package/Build/Drawing/Drawing.d.ts +129 -0
- package/Build/Drawing/GraphDrawer.d.ts +70 -0
- package/Build/Drawing/MeshLineGeometry.d.ts +11 -0
- package/Build/Drawing/MeshLineMaterial.d.ts +16 -0
- package/Build/Drawing/ThickLine.d.ts +21 -0
- package/Build/Drawing/ThreeJSDrawer.d.ts +197 -0
- package/Build/Drawing/index.d.ts +3 -0
- package/Build/GraphAlgorithms/GraphMethods.d.ts +47 -0
- package/Build/GraphAlgorithms/index.d.ts +1 -0
- package/Build/HelperClasses/ColorHelper.d.ts +21 -0
- package/Build/HelperClasses/GeometryHelpers.d.ts +31 -0
- package/Build/HelperClasses/GraphConstructors.d.ts +12 -0
- package/Build/HelperClasses/Line.d.ts +12 -0
- package/Build/HelperClasses/Point.d.ts +26 -0
- package/Build/HelperClasses/Utilities.d.ts +45 -0
- package/Build/HelperClasses/index.d.ts +3 -0
- package/Build/Hierarchy/KDDistanceStrategy.d.ts +8 -0
- package/Build/Hierarchy/KDTree.d.ts +10 -0
- package/Build/Hierarchy/buildSimplifiedGraph.d.ts +7 -0
- package/Build/Hierarchy/index.d.ts +29 -0
- package/Build/Hierarchy/types.d.ts +33 -0
- package/Build/MatrixHelpers.d.ts +12 -0
- package/Build/Models/ErdosRenyiModel.d.ts +13 -0
- package/Build/Models/index.d.ts +1 -0
- package/Build/SampleData/DataLoader.d.ts +49 -0
- package/Build/SampleData/ZKC.d.ts +5 -0
- package/Build/SampleData/ZKC_simulated.d.ts +10 -0
- package/Build/SampleData/dwt_1005.d.ts +1008 -0
- package/Build/SampleData/index.d.ts +2 -0
- package/Build/Shaders/fragmentShader.glsl.d.ts +2 -0
- package/Build/Shaders/vertexShader.glsl.d.ts +2 -0
- package/Build/Simulation/KamadaKawai3D.d.ts +30 -0
- package/Build/Simulation/Octree.d.ts +34 -0
- package/Build/Simulation/StressSGD3D.d.ts +45 -0
- package/Build/Simulation/index.d.ts +4 -0
- package/Build/index.d.ts +40 -0
- package/Build/pgl.js +3824 -3389
- package/Build/pgl.js.map +1 -1
- package/Build/pgl_module.js +20827 -35564
- package/Build/pgl_module.js.map +1 -1
- package/Examples/10_Adjacency_matrix.html +74 -0
- package/Examples/11_Custom_layout.html +89 -0
- package/Examples/12_StressSGD_simulation_live.html +80 -0
- package/Examples/13_StressSGD_bunny_3d.html +104 -0
- package/Examples/4_ToggleActivation.html +1 -1
- package/Examples/5_Hierarchy_simple.html +5 -2
- package/Examples/9_Simulation_live.html +74 -0
- package/Examples/data/bunny.obj +7474 -0
- package/Examples/examples.html +27 -2
- package/README.md +42 -10
- package/package.json +15 -23
- package/Build/Textures/Square.png +0 -0
- package/Build/pgl.d.ts +0 -703
- package/Build/pgl.d.ts.map +0 -1
package/Examples/examples.html
CHANGED
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
</a>
|
|
37
37
|
<a href="5_Hierarchy_simple.html" class="example-card">
|
|
38
38
|
<div class="num">Example 5</div>
|
|
39
|
-
<div class="title">Hierarchy</div>
|
|
40
|
-
<p class="desc">
|
|
39
|
+
<div class="title">Hierarchy (simplify by merging nearby nodes)</div>
|
|
40
|
+
<p class="desc">Merge nodes within a distance in 3D into super-nodes at cluster centers; edges between clusters are combined. Fewer nodes, same overall structure — good for LOD or flow-map style views.</p>
|
|
41
41
|
</a>
|
|
42
42
|
<a href="6_Flowmap_style.html" class="example-card">
|
|
43
43
|
<div class="num">Example 6</div>
|
|
@@ -54,6 +54,31 @@
|
|
|
54
54
|
<div class="title">ThreeWrapper variants</div>
|
|
55
55
|
<p class="desc">Different draw styles: box nodes, simplified (cylinder-style) edges, and modularity-based node/edge groups by a node property.</p>
|
|
56
56
|
</a>
|
|
57
|
+
<a href="9_Simulation_live.html" class="example-card">
|
|
58
|
+
<div class="num">Example 9</div>
|
|
59
|
+
<div class="title">Live 3D simulation</div>
|
|
60
|
+
<p class="desc">Time-based 3D Kamada–Kawai: layout evolves in real time. Uses createKamadaKawai3D, step(dt), and mutable vertices.</p>
|
|
61
|
+
</a>
|
|
62
|
+
<a href="10_Adjacency_matrix.html" class="example-card">
|
|
63
|
+
<div class="num">Example 10</div>
|
|
64
|
+
<div class="title">Adjacency matrix + power iteration</div>
|
|
65
|
+
<p class="desc">get_adjacency_matrix() and matrix math in the browser. Power iteration for leading eigenvector; node size reflects value.</p>
|
|
66
|
+
</a>
|
|
67
|
+
<a href="11_Custom_layout.html" class="example-card">
|
|
68
|
+
<div class="num">Example 11</div>
|
|
69
|
+
<div class="title">Custom layout from matrix math</div>
|
|
70
|
+
<p class="desc">Adjacency → power iteration for two coordinates → apply_position_map. Full pipeline: matrix math to 3D layout.</p>
|
|
71
|
+
</a>
|
|
72
|
+
<a href="12_StressSGD_simulation_live.html" class="example-card">
|
|
73
|
+
<div class="num">Example 12</div>
|
|
74
|
+
<div class="title">Stress SGD live simulation</div>
|
|
75
|
+
<p class="desc">Stress layout by s_gd2: epoch-based, Fisher-Yates shuffle. createStressSGD3D, step(dt).</p>
|
|
76
|
+
</a>
|
|
77
|
+
<a href="13_StressSGD_bunny_3d.html" class="example-card">
|
|
78
|
+
<div class="num">Example 13</div>
|
|
79
|
+
<div class="title">Stress SGD 3D (Stanford Bunny mesh)</div>
|
|
80
|
+
<p class="desc">3D stress layout from a mesh: OBJ → graph (vertices + edges), initial positions = mesh. Layout refines in 3D so the shape stays bunny-like.</p>
|
|
81
|
+
</a>
|
|
57
82
|
</section>
|
|
58
83
|
</main>
|
|
59
84
|
</body>
|
package/README.md
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
## Introduction
|
|
2
2
|
|
|
3
|
-
The Plebeian Graph Library (PGL) is a library designed to facilitate the visualization of large-scale network data (
|
|
3
|
+
The Plebeian Graph Library (PGL) is a library designed to facilitate the visualization of large-scale network data (NetworkX-style graph plotting in JavaScript/TypeScript). Leveraging the power of WebGL, PGL offers an efficient and interactive solution for visualizing network data in web browsers (Tested on Firefox, Edge and Chrome). Whether dealing with local datasets or data retrieved from APIs, PGL provides a versatile platform for conducting extensive network simulations, physical modeling, and immersive visualizations. With a rich set of features including graph condensation based on selected criteria, randomized edge pruning in highly connected graphs, and support for diverse visualization techniques like network diffusions and Kamada Kawai layouts, and edge bundling, PGL empowers users to gain valuable insights from complex network structures.
|
|
4
4
|
|
|
5
5
|
## Notes on terminology
|
|
6
6
|
|
|
7
|
-
It can be a bit confusing especially when working with Nodes/Edges/Vertices/Lines in this library (Also in general in working with graphs). Hence the terminology that I've followed here is as
|
|
7
|
+
It can be a bit confusing especially when working with Nodes/Edges/Vertices/Lines in this library (Also in general in working with graphs). Hence the terminology that I've followed here is as follows:
|
|
8
8
|
|
|
9
9
|
- Nodes (The library and the class is called \_Node so as to not confuse with NodeJS ) and Edges make up a graph.
|
|
10
10
|
- Vertices and Lines make up the 3d visualization side of a graph.
|
|
11
11
|
- Nodes are the abstract idea, vertices are what's visualized
|
|
12
|
-
- Edges are the abstract idea , lines are what's visualized.
|
|
12
|
+
- Edges are the abstract idea , lines are what's visualized.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Lastly, there are a few helper classes like points and lines. Points are essentially vectors and are used for displacement and also for describing a place in relation to the global coordinate system. Line are an array of points that get translated into lines using one of the visualization methods. Points can have different visualizations like boxes, billboarded planes and cylinders etc.
|
|
15
15
|
|
|
16
|
-
Existing network visualization libraries like NetworkX dictated the semantics of the graph library and borrowed some of the semantic ideas from three JS. The process is to define a Graph Object made of nodes and edges. Then modify this graph based on some set of properties. Then update the relevant settings. And lastly, to visualize the nodes, either as point clouds, boxes or cylinders, and to draw out the edges (bundled or not) lines.
|
|
17
|
-
Here is an illustrated walkthrough of a simple set-up given a predefined set of “nodes” and “edges”.
|
|
18
16
|
|
|
19
17
|
## Documentation
|
|
20
18
|
|
|
@@ -24,11 +22,38 @@ The documentation for the package is available at [documentation](https://www.pl
|
|
|
24
22
|
npm run document
|
|
25
23
|
```
|
|
26
24
|
|
|
27
|
-
This writes TypeDoc output to the `docs/` folder. **API overview:** the library exposes the following namespaces: `Graph`, `GraphMethods` (BFS, Dijkstra, GraphDiameter, SelectSubgraph), `SampleData` (LoadZKC, LoadZKCSimulated), `Constructors` (ConstructGraphNodeEdgesList), `Drawing` (SimulateKamadaKawai, DrawEdgeLines, DrawEdgeBundling, DisplaceEdgeInY, etc.), `Geometry`, `Utilities`, `ThreeWrapper`, `GraphDrawer`, `Models` (Erdos–Renyi),
|
|
25
|
+
This writes TypeDoc output to the `docs/` folder. **API overview:** the library exposes the following namespaces: `Graph`, `GraphMethods` (BFS, Dijkstra, GraphDiameter, SelectSubgraph — note: `Dijkstra` returns hop-count distances via BFS for unweighted graphs), `SampleData` (LoadZKC, LoadZKCSimulated, LoadGraphFromEdgeListText for (sgd)²-style edge lists, LoadGraphFromObjText for OBJ meshes → graph + positions), `Constructors` (ConstructGraphNodeEdgesList), `Drawing` (SimulateKamadaKawai, DrawEdgeLines, DrawEdgeBundling, DisplaceEdgeInY, etc.), `Geometry`, `Utilities`, `ThreeWrapper`, `GraphDrawer`, `Models` (Erdos–Renyi), `Hierarchy` (clusterByDistance, clusterByStrategy for flow-map style clustering), **Simulation** (createKamadaKawai3D, createStressSGD3D — stress layout methods from (sgd)², Imperial), **MatrixHelpers** (matrixVectorMultiply, normalizeVector), and **glMatrix** (re-exported [gl-matrix](https://github.com/toji/gl-matrix) for vector/matrix math in the browser).
|
|
26
|
+
|
|
27
|
+
### Graph simulations
|
|
28
|
+
|
|
29
|
+
For time-based layout updates (e.g. in a `requestAnimationFrame` loop), use **createKamadaKawai3D(graph, options)** or **createStressSGD3D(graph, options)** (async). Both return an object with **step(deltaTime)**, **getPositions()** (Float32Array), and **getPositionMap()**. The Stress SGD layout follows the (sgd)² reference implementation from Imperial ([arXiv:1710.04626](https://arxiv.org/abs/1710.04626), [IEEE TVCG](https://www.computer.org/csdl/journal/tg/2019/09/08419285/13rRUyYBlgE), [github.com/jxz12/s_gd2](https://github.com/jxz12/s_gd2)). Use **DrawTHREEGraphVerticesMutable** so you can call **updatePositions(simulation.getPositions())** each frame without recreating geometry. For 3D layout that does not collapse to a line, pass **initialPositions** (e.g. from **LoadGraphFromObjText**) and use **dimensions: 3**. See Examples 9 (Kamada–Kawai live simulation), 11 (custom layout), 12 (Stress SGD live simulation), and 13 (Stress SGD 3D with Stanford Bunny mesh).
|
|
30
|
+
|
|
31
|
+
### Types (Point, PointLike)
|
|
32
|
+
|
|
33
|
+
The library exports **Point** (class with `x`, `y`, `z` and `translate()`) and **PointLike** (`{ x: number; y: number; z: number }`) for typing position maps and custom layout results. Use `PointLike` for plain objects; use `new PGL.Point(x, y, z)` when you need the class.
|
|
34
|
+
|
|
35
|
+
### Drawing API: static vs mutable
|
|
36
|
+
|
|
37
|
+
- **Static** (one-shot layout): `DrawTHREEGraphVertices`, `DrawTHREEGraphEdgesThin` — create geometry once from the graph.
|
|
38
|
+
- **Mutable** (animation loops): `DrawTHREEGraphVerticesMutable` (and `updatePositions()`), `DrawTHREEGraphEdgesThinMutable` (and `updateEdges()`) — update geometry each frame for time-based simulation.
|
|
39
|
+
|
|
40
|
+
### LOD and flow-map style
|
|
41
|
+
|
|
42
|
+
**Hierarchy** (clusterByDistance, clusterByStrategy) and Example 6 provide FlowmapBlue-style level-of-detail: cluster nodes by distance (e.g. KD-tree), merge nearby nodes into super-nodes, and simplify the graph for zoom-dependent detail. See Examples 5 (Hierarchy) and 6 (Flow map).
|
|
43
|
+
|
|
44
|
+
### Matrix math in the browser
|
|
45
|
+
|
|
46
|
+
**get_node_ids_order()** returns a stable array of node IDs. **get_adjacency_matrix()** returns `{ matrix: Float32Array (row-major n×n), nodeIds }`. Use **matrixVectorMultiply(A, n, x, out)** and **normalizeVector(x)** for power iteration or diffusion in the browser. The library re-exports **glMatrix** (vec3, mat4, etc.) so you can do full vector/matrix math without adding another dependency. Dense adjacency matrix is for small/medium graphs; for very large graphs use **get_adjacency()** (sparse). See Examples 10 and 11.
|
|
28
47
|
|
|
29
48
|
## General setup of the package
|
|
30
49
|
|
|
31
|
-
Apart from the graph class all the methods are stored in variables. These variables (For example SampleData) would have a function attached to it that returns a value, or in some cases you can pass in values to do stuff (like displacing the graph etc). I mostly did this for the sake of speed to develop
|
|
50
|
+
Apart from the graph class all the methods are stored in variables. These variables (For example SampleData) would have a function attached to it that returns a value, or in some cases you can pass in values to do stuff (like displacing the graph etc). I mostly did this for the sake of speed to develop — they will eventually be wrapped up as classes.
|
|
51
|
+
|
|
52
|
+
## Semantics of the Package
|
|
53
|
+
|
|
54
|
+
Existing network visualization libraries like NetworkX dictated the semantics of the graph library and borrowed some of the semantic ideas from three JS. The process is to define a Graph Object made of nodes and edges. Then modify this graph based on some set of properties. Then update the relevant settings. And lastly, to visualize the nodes, either as point clouds, boxes or cylinders, and to draw out the edges (bundled or not) lines.
|
|
55
|
+
Here is an illustrated walkthrough of a simple set-up given a predefined set of “nodes” and “edges”.
|
|
56
|
+
|
|
32
57
|
|
|
33
58
|
## An example of rendering a basic graph
|
|
34
59
|
|
|
@@ -94,6 +119,11 @@ async function createVisualization() {
|
|
|
94
119
|
createVisualization();
|
|
95
120
|
```
|
|
96
121
|
|
|
122
|
+
## Testing
|
|
123
|
+
|
|
124
|
+
- **Unit tests:** `npm run test:unit` (Vitest; tests Utilities, Graph, Simulation, matrix helpers).
|
|
125
|
+
- **Visual regression:** `npm test` (Puppeteer + pixelmatch against a baseline screenshot).
|
|
126
|
+
|
|
97
127
|
## Usage / Installation
|
|
98
128
|
|
|
99
129
|
Install it from the npm repository. Note that this method needs a npm folder to be set up with a build tool like parcel to package the visualizations
|
|
@@ -139,6 +169,8 @@ Also remember to check out the contributions file where there are more details o
|
|
|
139
169
|
|
|
140
170
|
Remember to follow our Code of Conduct to ensure a welcoming and inclusive environment for everyone
|
|
141
171
|
|
|
142
|
-
##
|
|
172
|
+
## References and acknowledgements
|
|
173
|
+
|
|
174
|
+
**Stress-based layout (createStressSGD3D):** The stress-minimization-by-SGD algorithm and schedule used in PGL are taken from the **(sgd)²** reference implementation ([jxz12/s_gd2](https://github.com/jxz12/s_gd2)) from Imperial College London. The underlying method is from the paper: J. X. Zheng, S. Pawar, D. F. M. Goodman, *Graph Drawing by Stochastic Gradient Descent*, IEEE Transactions on Visualization and Computer Graphics, [arXiv:1710.04626](https://arxiv.org/abs/1710.04626). Example graph data (e.g. football.txt) in the Stress SGD demo are from the same s_gd2 repository.
|
|
143
175
|
|
|
144
|
-
This library was sponsored by the Geometry Lab under the Laboratory for Design Technologies at the Graduate School of Design, Harvard University. Many thanks to Andrew Witt for guiding this project. This project was developed by
|
|
176
|
+
**PGL:** This library was sponsored by the Geometry Lab under the Laboratory for Design Technologies at the Graduate School of Design, Harvard University. Many thanks to Andrew Witt for guiding this project. This project was developed by [Indrajeet Haldar](https://www.indrajeethaldar.com/).
|
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plebeiangraphlibrary",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A NetworkX like package for graphs in javascript",
|
|
5
5
|
"source": "./Src/index.ts",
|
|
6
6
|
"main": "./Build/pgl.js",
|
|
7
|
-
"types": "./Build/
|
|
7
|
+
"types": "./Build/index.d.ts",
|
|
8
8
|
"module": "./Build/pgl_module.js",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"watch": "
|
|
11
|
-
"build": "
|
|
10
|
+
"watch": "vite build --watch",
|
|
11
|
+
"build": "rm -rf Build && vite build",
|
|
12
12
|
"build:all": "npm run build && npm run document",
|
|
13
13
|
"test": "node ./test/test_1.js",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
14
|
+
"test:unit": "vitest run",
|
|
15
|
+
"test:unit:watch": "vitest",
|
|
16
|
+
"document": "rm -rf docs && npx typedoc --options typedoc.json",
|
|
17
|
+
"document:public": "npm run document && rm -rf public && mkdir -p public && cp -R docs/. public/",
|
|
18
|
+
"examples:public": "rm -rf public && mkdir -p public && cp -R Examples/. public/",
|
|
19
|
+
"deploy:public": "npm run build && npm run document && rm -rf public && mkdir -p public && mkdir -p public/Build && cp -R Build/. public/Build/ && cp -R Examples/. public/ && cp -R docs/. public/",
|
|
18
20
|
"serve": "python3 -m http.server 3000"
|
|
19
21
|
},
|
|
20
22
|
"repository": {
|
|
@@ -41,32 +43,22 @@
|
|
|
41
43
|
"url": "https://github.com/range-et/PGL/issues"
|
|
42
44
|
},
|
|
43
45
|
"homepage": "https://www.plebeiangraphlibrary.com/",
|
|
44
|
-
"targets": {
|
|
45
|
-
"main": {
|
|
46
|
-
"includeNodeModules": false
|
|
47
|
-
},
|
|
48
|
-
"module": {
|
|
49
|
-
"includeNodeModules": true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
46
|
"dependencies": {
|
|
47
|
+
"gl-matrix": "^3.4.3",
|
|
53
48
|
"three": "^0.170.0"
|
|
54
49
|
},
|
|
55
50
|
"devDependencies": {
|
|
56
|
-
"@parcel/packager-ts": "^2.9.1",
|
|
57
|
-
"@parcel/transformer-typescript-tsc": "^2.9.1",
|
|
58
|
-
"@parcel/transformer-typescript-types": "^2.9.1",
|
|
59
51
|
"@types/three": "^0.170.0",
|
|
60
52
|
"express": "^4.18.2",
|
|
61
|
-
"jest": "^29.7.0",
|
|
62
|
-
"jest-image-snapshot": "^6.4.0",
|
|
63
53
|
"jsdoc": "^4.0.2",
|
|
64
|
-
"parcel": "^2.9.1",
|
|
65
54
|
"pixelmatch": "^5.3.0",
|
|
66
55
|
"pngjs": "^7.0.0",
|
|
67
56
|
"puppeteer": "^21.7.0",
|
|
68
57
|
"shelljs": "^0.8.5",
|
|
69
58
|
"typedoc": "^0.24.8",
|
|
70
|
-
"typescript": "^5.1.3"
|
|
59
|
+
"typescript": "^5.1.3",
|
|
60
|
+
"vite": "^6.0.1",
|
|
61
|
+
"vite-plugin-dts": "^4.3.4",
|
|
62
|
+
"vitest": "^2.1.6"
|
|
71
63
|
}
|
|
72
64
|
}
|
|
Binary file
|