plebeiangraphlibrary 2.2.0 → 2.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ All notable changes to the Plebeian Graph Library (PGL) will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.2.2] - 2025-02-28
9
+
10
+ ### Added
11
+
12
+ - **remove_node(nodeId)** — Remove a node and all incident edges. Updates adjacency lists for remaining nodes. Returns `true` if the node existed and was removed.
13
+ - **remove_edge(edgeId)** — Remove an edge by ID. Updates adjacency lists. Returns `true` if the edge existed and was removed.
14
+ - **NodeData** and **EdgeData** types — Exported for typed node/edge data when using add_node and add_edge.
15
+ - **exports** field in package.json — Cleaner ESM/CJS resolution for bundlers.
16
+
17
+ ### Changed
18
+
19
+ - **add_edge** — Uses internal edge ID counter to avoid collisions when edges are removed.
20
+ - **LoadDwt1005** — Now lazy-loaded via dynamic import; DWT 1005 dataset is in a separate chunk and only loaded when called (reduces main bundle size).
21
+ - **get_position_map** — Skips nodes without `data.pos` instead of returning undefined.
22
+ - **constructAdjacencyList** — Added `await Promise.resolve()` between passes to yield to the event loop on large graphs.
23
+ - **4_ToggleActivation.html** — Fixed missing `await` on `G.initialize()`.
24
+
25
+ ### Fixed
26
+
27
+ - Edge ID collisions when removing and re-adding edges (now uses monotonic counter).
28
+ - Potential browser hang during adjacency construction on very large graphs (yield point added).
29
+
30
+ [2.2.2]: https://github.com/range-et/PGL/compare/v2.2.1...v2.2.2
@@ -27,7 +27,7 @@
27
27
  const G = await PGL.Models.GenerateErdosReyni_n_p(1000, 0.02);
28
28
  // since these graphs can be really large - they are not initialized
29
29
  // so you must initialize them
30
- G.initialize();
30
+ await G.initialize();
31
31
  G.printData();
32
32
 
33
33
  // now in this case we shall use the Kamada Kawai algorithm to initilaize all the positions
package/README.md CHANGED
@@ -22,15 +22,15 @@ The documentation for the package is available at [documentation](https://www.pl
22
22
  npm run document
23
23
  ```
24
24
 
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`, **Interaction** (opt-in: `enableInteraction`, `disableInteraction`; types `NodePickDetails`, `EdgePickDetails`, `InteractionOptions` for click/hover/drag callbacks), `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).
25
+ This writes TypeDoc output to the `docs/` folder. **API overview:** the library exposes the following namespaces: `Graph` (add_node, add_edge, remove_node, remove_edge, get_position_map, apply_position_map, etc.), `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, LoadDwt1005 — lazy-loaded), `Constructors` (ConstructGraphNodeEdgesList), `Drawing` (SimulateKamadaKawai, DrawEdgeLines, DrawEdgeBundling, DisplaceEdgeInY, etc.), `Geometry`, `Utilities`, `ThreeWrapper`, `GraphDrawer`, **Interaction** (opt-in: `enableInteraction`, `disableInteraction`; types `NodePickDetails`, `EdgePickDetails`, `InteractionOptions` for click/hover/drag callbacks), `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
26
 
27
27
  ### Graph simulations
28
28
 
29
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
30
 
31
- ### Types (Point, PointLike)
31
+ ### Types (Point, PointLike, NodeData, EdgeData)
32
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.
33
+ The library exports **Point** (class with `x`, `y`, `z` and `translate()`), **PointLike** (`{ x: number; y: number; z: number }`), **NodeData** (typed shape for node data; `pos` optional), and **EdgeData** (typed shape for edge data; `ldata` optional for line geometry). Use `PointLike` for plain objects; use `new PGL.Point(x, y, z)` when you need the class.
34
34
 
35
35
  ### Drawing API: static vs mutable
36
36
 
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "plebeiangraphlibrary",
3
- "version": "2.2.0",
3
+ "version": "2.2.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
7
  "types": "./Build/index.d.ts",
8
8
  "module": "./Build/pgl_module.js",
9
+ "exports": {
10
+ ".": {
11
+ "import": { "types": "./Build/index.d.ts", "default": "./Build/pgl_module.js" },
12
+ "require": { "types": "./Build/index.d.ts", "default": "./Build/pgl.js" }
13
+ }
14
+ },
9
15
  "scripts": {
10
16
  "watch": "vite build --watch",
11
17
  "build": "rm -rf Build && vite build",
@@ -33,6 +39,7 @@
33
39
  "Build/",
34
40
  "Examples/",
35
41
  "README.md",
42
+ "CHANGELOG.md",
36
43
  "CODE_OF_CONDUCT.md",
37
44
  "CONTRIBUTING.md",
38
45
  "LICENSE"