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.
Files changed (58) hide show
  1. package/Build/Core/Edge.d.ts +20 -0
  2. package/Build/Core/Graph.d.ts +114 -0
  3. package/Build/Core/_Node.d.ts +20 -0
  4. package/Build/Core/index.d.ts +3 -0
  5. package/Build/Drawing/Drawing.d.ts +129 -0
  6. package/Build/Drawing/GraphDrawer.d.ts +70 -0
  7. package/Build/Drawing/MeshLineGeometry.d.ts +11 -0
  8. package/Build/Drawing/MeshLineMaterial.d.ts +16 -0
  9. package/Build/Drawing/ThickLine.d.ts +21 -0
  10. package/Build/Drawing/ThreeJSDrawer.d.ts +197 -0
  11. package/Build/Drawing/index.d.ts +3 -0
  12. package/Build/GraphAlgorithms/GraphMethods.d.ts +47 -0
  13. package/Build/GraphAlgorithms/index.d.ts +1 -0
  14. package/Build/HelperClasses/ColorHelper.d.ts +21 -0
  15. package/Build/HelperClasses/GeometryHelpers.d.ts +31 -0
  16. package/Build/HelperClasses/GraphConstructors.d.ts +12 -0
  17. package/Build/HelperClasses/Line.d.ts +12 -0
  18. package/Build/HelperClasses/Point.d.ts +26 -0
  19. package/Build/HelperClasses/Utilities.d.ts +45 -0
  20. package/Build/HelperClasses/index.d.ts +3 -0
  21. package/Build/Hierarchy/KDDistanceStrategy.d.ts +8 -0
  22. package/Build/Hierarchy/KDTree.d.ts +10 -0
  23. package/Build/Hierarchy/buildSimplifiedGraph.d.ts +7 -0
  24. package/Build/Hierarchy/index.d.ts +29 -0
  25. package/Build/Hierarchy/types.d.ts +33 -0
  26. package/Build/MatrixHelpers.d.ts +12 -0
  27. package/Build/Models/ErdosRenyiModel.d.ts +13 -0
  28. package/Build/Models/index.d.ts +1 -0
  29. package/Build/SampleData/DataLoader.d.ts +49 -0
  30. package/Build/SampleData/ZKC.d.ts +5 -0
  31. package/Build/SampleData/ZKC_simulated.d.ts +10 -0
  32. package/Build/SampleData/dwt_1005.d.ts +1008 -0
  33. package/Build/SampleData/index.d.ts +2 -0
  34. package/Build/Shaders/fragmentShader.glsl.d.ts +2 -0
  35. package/Build/Shaders/vertexShader.glsl.d.ts +2 -0
  36. package/Build/Simulation/KamadaKawai3D.d.ts +30 -0
  37. package/Build/Simulation/Octree.d.ts +34 -0
  38. package/Build/Simulation/StressSGD3D.d.ts +45 -0
  39. package/Build/Simulation/index.d.ts +4 -0
  40. package/Build/index.d.ts +40 -0
  41. package/Build/pgl.js +3824 -3389
  42. package/Build/pgl.js.map +1 -1
  43. package/Build/pgl_module.js +20827 -35564
  44. package/Build/pgl_module.js.map +1 -1
  45. package/Examples/10_Adjacency_matrix.html +74 -0
  46. package/Examples/11_Custom_layout.html +89 -0
  47. package/Examples/12_StressSGD_simulation_live.html +80 -0
  48. package/Examples/13_StressSGD_bunny_3d.html +104 -0
  49. package/Examples/4_ToggleActivation.html +1 -1
  50. package/Examples/5_Hierarchy_simple.html +5 -2
  51. package/Examples/9_Simulation_live.html +74 -0
  52. package/Examples/data/bunny.obj +7474 -0
  53. package/Examples/examples.html +27 -2
  54. package/README.md +42 -10
  55. package/package.json +15 -23
  56. package/Build/Textures/Square.png +0 -0
  57. package/Build/pgl.d.ts +0 -703
  58. package/Build/pgl.d.ts.map +0 -1
@@ -0,0 +1,20 @@
1
+ interface Edge {
2
+ start: number;
3
+ end: number;
4
+ data: any;
5
+ }
6
+ /**
7
+ * Edge class: connects two nodes by start/end IDs; can hold optional data (e.g. "ldata" for line geometry).
8
+ */
9
+ declare class Edge {
10
+ /**
11
+ *
12
+ * Construct an edge
13
+ *
14
+ * @param start Start index of the edge based on the array of nodes
15
+ * @param end End index of the edge based on the array of nodes
16
+ * @param data - Optional data; "ldata" is reserved for line geometry used when drawing the edge
17
+ */
18
+ constructor(start: number, end: number, data: any);
19
+ }
20
+ export default Edge;
@@ -0,0 +1,114 @@
1
+ import { default as Line } from '../HelperClasses/Line';
2
+ import { default as Point } from '../HelperClasses/Point';
3
+ import { default as _Node } from './_Node';
4
+ import { default as Edge } from './Edge';
5
+ interface Graph {
6
+ nodes: Map<number, _Node>;
7
+ edges: Map<number, Edge>;
8
+ }
9
+ /**
10
+ * The main graph object: contains nodes and edges that get modified with different
11
+ * operations (layout, clustering, etc.).
12
+ */
13
+ declare class Graph {
14
+ /**
15
+ *
16
+ * Construct a graph object (no initializing)
17
+ *
18
+ * @param nodes - Map of all the nodes associated with the graph
19
+ * @param edges - Map of all the edges associated with the graph
20
+ */
21
+ constructor(nodes: Map<number, _Node>, edges: Map<number, Edge>);
22
+ /**
23
+ * Prints out a snapshot of data associated with this graph like how many nodes and how many edges
24
+ */
25
+ printData(): void;
26
+ /**
27
+ * Initializes the graph and constructs the node adjacency list.
28
+ */
29
+ initialize(): Promise<void>;
30
+ /**
31
+ *
32
+ * This is the official create method to make a graph based on a set of nodes and edges
33
+ * It also auto-initializes the graph and sets all the adjacency lists in memory.
34
+ *
35
+ * @param nodes - map of nodes
36
+ * @param edges - map of edges
37
+ * @returns
38
+ */
39
+ static create(nodes: Map<number, _Node>, edges: Map<number, Edge>): Promise<Graph>;
40
+ /**
41
+ * Constructs the adjacency associated with the graph
42
+ */
43
+ constructAdjacencyList(): Promise<void>;
44
+ /**
45
+ * Add a node to the graph.
46
+ * @param nodeID - The node ID
47
+ * @param data - Data associated with the node
48
+ */
49
+ add_node(nodeID: number, data: _Node): void;
50
+ /**
51
+ * Add an edge to the graph
52
+ * @param start - Starting index of the edge
53
+ * @param end - The end index of the edge
54
+ * @param data - data associated with the edge
55
+ */
56
+ add_edge(start: number, end: number, data: any): void;
57
+ /**
58
+ *
59
+ * @returns The adjacency lists associated with the graph
60
+ */
61
+ get_adjacency(): Map<number, number[]>;
62
+ /**
63
+ * Apply a position map based on some data
64
+ * @param data - the position map that has to be applied to the graph
65
+ */
66
+ apply_position_map(data: Map<number, Point>): void;
67
+ /**
68
+ * Apply an line map to a graph
69
+ * @param data Line data that has to be applied to the graph
70
+ */
71
+ apply_edge_pos_maps(data: Map<number, Line>): void;
72
+ /**
73
+ * get the current edge map
74
+ * @returns The current set of edges associated with the graph
75
+ */
76
+ get_edge_map(): Map<number, Line>;
77
+ /**
78
+ * Applies all the maps to the graph
79
+ * @param layout - Applies an object of maps associated with a graph: {pmap:(the position map), emap:(the edge map)}
80
+ */
81
+ apply_drawing_maps(layout: {
82
+ pmap: Map<number, Point>;
83
+ emap: Map<number, Line>;
84
+ }): void;
85
+ /**
86
+ * Gets the position map and the edge map respectively
87
+ * @returns The position map and the edge map as pmap and emap
88
+ */
89
+ get_map(): {
90
+ pmap: Map<number, Point>;
91
+ emap: Map<number, Line>;
92
+ };
93
+ /**
94
+ * Get the position of the nodes in the graph.
95
+ * @returns The position map (node ID to Point)
96
+ */
97
+ get_position_map(): Map<number, Point>;
98
+ /**
99
+ * Returns a deterministic order of node IDs (same as iteration order of nodes).
100
+ * Use this order for adjacency matrix rows/columns, simulation buffers, and drawer indices.
101
+ * @returns Array of node IDs in stable order
102
+ */
103
+ get_node_ids_order(): number[];
104
+ /**
105
+ * Returns the adjacency matrix and the node ID order. Dense form is for small/medium graphs;
106
+ * for very large graphs use get_adjacency() (sparse) instead.
107
+ * @returns { matrix: Float32Array (row-major n×n), nodeIds: number[] }
108
+ */
109
+ get_adjacency_matrix(): {
110
+ matrix: Float32Array;
111
+ nodeIds: number[];
112
+ };
113
+ }
114
+ export default Graph;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Graph node: holds arbitrary data (e.g. `pos` for layout) and neighbour IDs.
3
+ * Named `_Node` to avoid confusion with Node.js and Three.js Vertices.
4
+ */
5
+ interface _Node {
6
+ data: any;
7
+ neighbours: number[];
8
+ }
9
+ /**
10
+ * Node class: each node has an ID (index) and arbitrary data.
11
+ * The data typically includes "pos" (Point) for visualization.
12
+ */
13
+ declare class _Node {
14
+ /**
15
+ *
16
+ * @param data - Data associated with the node; include "pos" (Point) for graph visuals
17
+ */
18
+ constructor(data: any);
19
+ }
20
+ export default _Node;
@@ -0,0 +1,3 @@
1
+ export { default as Graph } from './Graph';
2
+ export { default as _Node } from './_Node';
3
+ export { default as Edge } from './Edge';
@@ -0,0 +1,129 @@
1
+ import { default as Point } from '../HelperClasses/Point';
2
+ import { default as Line } from '../HelperClasses/Line';
3
+ import { default as Graph } from '../Core/Graph';
4
+ /**
5
+ * Simulates Kamada kawai for a network in 2d. 3d is not supported yet
6
+ * Note: This is an async function as it take time for some of the large graphs
7
+ *
8
+ * @param Graph - The first input number
9
+ * @param iterations - The second input number
10
+ * @param simulationBound - The bounds of simulation (Mostly a global number to scale the graph up or down)
11
+ * @param cohesionValue - How sticky the nodes are i.r. how much they cluster together
12
+ * @returns A node map of all the nodes and their simulated positions. Note: position maps have to be applied to the graph.
13
+ *
14
+ */
15
+ declare function SimulateKamadaKawai(Graph: Graph, iterations: number, simulationBound?: number, cohesionValue?: number, repulsionValue?: number): Promise<Map<number, Point>>;
16
+ /**
17
+ *
18
+ * Randomly sets all the positions for a graph
19
+ * Not really very useful but I've used it in some cases and have kept it around
20
+ *
21
+ * @param Graph - The graph who's nodes you would want to reposition
22
+ *
23
+ * @return A position map of all the nodes and its corresponding positions
24
+ */
25
+ declare function InstanciateRandomPositions(Graph: Graph): Map<number, Point>;
26
+ /**
27
+ *
28
+ * Constructs the edges as lines, Note: these are just a representation of the lines
29
+ * they then have to be visulized using one of the Three JS Drawer functions like
30
+ * draw a thick line or a thin line. This draws out the edges divided by some number of
31
+ * divisions that you specify
32
+ *
33
+ * @param Graph - The graph whos edges are getting drawn
34
+ * @param divDistance - How many divisions (distance) to make along the edge
35
+ * @returns A line map - which holds a map of all the edge indices and the corresponding line representations
36
+ */
37
+ declare function DrawEdgeLines(Graph: Graph, divDistance: number): Map<number, Line>;
38
+ /**
39
+ *
40
+ * Constructs the edges as lines, Note: these are just a representation of the lines
41
+ * they then have to be visulized using one of the Three JS Drawer functions like
42
+ * draw a thick line or a thin line - this draws them based on the number of divisions
43
+ * you would like them to have
44
+ * @param Graph - The graph whos edges are getting drawn
45
+ * @param numberOfDivs - How many divisions to make along the edge
46
+ * @returns A line map - which holds a map of all the edge indices and the corresponding line representations
47
+ */
48
+ declare function DrawEdgeLinesDivisions(Graph: Graph, numberOfDivs: number): Map<number, Line>;
49
+ /**
50
+ *
51
+ * Edge bundling - this isnt as fast as the current KDE based methods - but it provides a basic method of
52
+ * Visualizing large edge flows. Note: This is an aysnc function as it takes a while for the edge bundling to happen
53
+ *
54
+ * @param LineMap - The map of edges as a line map
55
+ * @param iterations - The number of iterations to run edge bundling
56
+ * @param distance - A shorthand for how close together the vertices need to be before they get influnced by each other
57
+ * @returns A line map with all the updated positions of the line (Where they are bundled together) Again - this needs to be applied to the graph!
58
+ */
59
+ declare function DrawEdgeBundling(LineMap: Map<number, Line>, iterations: number, distance: number): Promise<Map<number, Line>>;
60
+ /**
61
+ *
62
+ * Displace the edges vertically, almost akin to the Deck.gl arcs
63
+ * The displacement is done in a sin curve with the ends still touching the nodes
64
+ * Note: This is an inplace modification of the edges
65
+ *
66
+ * @param LineMap - The map of edges as a line map
67
+ * @param displacement - the amount of vertical displacement
68
+ */
69
+ declare function DisplaceEdgeInY(LineMap: Map<number, Line>, displacement: number): Map<number, Line>;
70
+ /**
71
+ *
72
+ * Displace the vertices vertically based on some prameter (For example degree or modularity)
73
+ *
74
+ * @param Graph - the graph whos nodes have to be displaced
75
+ * @param parameter - the prameter based on which you want to modify the
76
+ * @param displacement - the maximum amunt of displacement, all the other values are rescaled linerly
77
+ */
78
+ declare function DisplaceVertices(Graph: Graph, parameter: string, displacement: number): void;
79
+ /**
80
+ *
81
+ * Generates a hive plot for a graph, this includes the option to displace the graph vertically based on degrees and how far away each node is
82
+ *
83
+ * @param Graph - The graph
84
+ * @param selectedNode - the node around which the hive plot is generated
85
+ * @param step - If the hive should step up or down if yes then by what increments
86
+ * @param startPosition - Starting position
87
+ * @returns
88
+ */
89
+ declare function HivePlot(Graph: Graph, selectedNode: number, step: number, startPosition: Point): Promise<{
90
+ pmap: Map<any, any>;
91
+ emap: Map<number, Line>;
92
+ }>;
93
+ /**
94
+ * Move a graph somewhere (like the physical location) - This is an inplace movement and overwrites existing values
95
+ *
96
+ * @param Graph - The graph that has to be moved
97
+ * @param dispacement - This is a point and I end up using Point and Vector interchangably. So here the xyz values from the point are used to displace the nodes
98
+ */
99
+ declare function MoveGraph(Graph: Graph, dispacement: Point): void;
100
+ /**
101
+ *
102
+ * Draw new lines from edges, and draw them based on the distance of divisions (i.e. divide the line up every 10 units) Note: This is an in place update that takes place on the graph - it overwrites the existing data.
103
+ *
104
+ * @param Graph - The grapht who's edges have to be updated
105
+ * @param divDistance - The distance by which the divisions are made
106
+ */
107
+ declare function UpdateEdgeLinesDist(Graph: Graph, divDistance: number): void;
108
+ /**
109
+ *
110
+ * Draw new lines from edges, and draw them based on divisions (i.e. divide the line into 10 units) Note: This is an in place update that takes place on the graph - it overwrites the existing data.
111
+
112
+ * @param Graph - The grapht who's edges have to be updated
113
+ * @param Divs - The number of divisions to be made
114
+ */
115
+ declare function UpdateEdgeLinesDivs(Graph: Graph, Divs: number): void;
116
+ declare const _default: {
117
+ SimulateKamadaKawai: typeof SimulateKamadaKawai;
118
+ DrawEdgeLines: typeof DrawEdgeLines;
119
+ DrawEdgeLinesDivisions: typeof DrawEdgeLinesDivisions;
120
+ DrawEdgeBundling: typeof DrawEdgeBundling;
121
+ HivePlot: typeof HivePlot;
122
+ DisplaceEdgeInY: typeof DisplaceEdgeInY;
123
+ MoveGraph: typeof MoveGraph;
124
+ InstanciateRandomPositions: typeof InstanciateRandomPositions;
125
+ DisplaceVertices: typeof DisplaceVertices;
126
+ UpdateEdgeLinesDist: typeof UpdateEdgeLinesDist;
127
+ UpdateEdgeLinesDivs: typeof UpdateEdgeLinesDivs;
128
+ };
129
+ export default _default;
@@ -0,0 +1,70 @@
1
+ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
2
+ import { default as Graph } from '../Core/Graph';
3
+ import * as THREE from "three";
4
+ interface GraphDrawer3d {
5
+ canvas: HTMLCanvasElement;
6
+ width: number;
7
+ height: number;
8
+ geometryMap: Map<any, any>;
9
+ materialMap: Map<any, any>;
10
+ meshMap: Map<any, any>;
11
+ controls: OrbitControls;
12
+ renderer: THREE.WebGLRenderer;
13
+ camera: THREE.PerspectiveCamera;
14
+ scene: THREE.Scene;
15
+ graphs: Map<number, Graph>;
16
+ }
17
+ /**
18
+ * This is the main graph drawer class
19
+ */
20
+ declare class GraphDrawer3d {
21
+ /**
22
+ * To initialize the graph drawer there are a set of graph drawing settings that have to be set.
23
+ * Here are the details to do the same:
24
+ * canvas - the html canvas element that you would like to render
25
+ * height - the the height of the initialized canvas
26
+ * width - the width of the initialized canvas
27
+ * geometry map - a map that keeps track of all the geometry in the scene (Optional)
28
+ * material map - a mapt that keeps track of all the materials in the scene (Optional)
29
+ * controls - Controls that define how one can navigate this 3d space (Self initialized)
30
+ * renderer - Renderer element form the three JS library
31
+ * camera - A perspective camera from the threeJS library
32
+ * scene - The three JS scene that gets define automatically
33
+ *
34
+ * @param GraphDrawerOptions3d - These options are constructed into a single object and passed in
35
+ */
36
+ constructor(GraphDrawerOptions3d: {
37
+ canvas: HTMLCanvasElement;
38
+ width: number;
39
+ height: number;
40
+ geometryMap: Map<any, any>;
41
+ materialMap: Map<any, any>;
42
+ meshMap: Map<any, any>;
43
+ controls: OrbitControls;
44
+ renderer: THREE.WebGLRenderer;
45
+ camera: THREE.PerspectiveCamera;
46
+ scene: THREE.Scene;
47
+ });
48
+ /**
49
+ * This essentially initializes the drawing element based on the settings
50
+ * Remember to do this since if if its not done the scene will not render
51
+ */
52
+ init(): Promise<void>;
53
+ /**
54
+ *
55
+ * This is the main way to add elements to the viewer window that gets initialized
56
+ *
57
+ * @param element A geometry element (THREE.Group, Line, or Points) to add to the scene
58
+ */
59
+ addVisElement(element: THREE.Group | THREE.Line | THREE.Points): void;
60
+ /**
61
+ * This is the render call that is called every frame to update the rendering of the canvas
62
+ * Remember to do this since this is a common are for bugs to occur
63
+ */
64
+ rendercall(): void;
65
+ }
66
+ export { GraphDrawer3d };
67
+ declare const _default: {
68
+ GraphDrawer3d: typeof GraphDrawer3d;
69
+ };
70
+ export default _default;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Ribbon geometry for billboarded thick lines (MeshLine-style).
3
+ * Each line point becomes two vertices (left/right edge); the material
4
+ * expands them in screen space so the line has visible thickness.
5
+ */
6
+ import * as THREE from "three";
7
+ /**
8
+ * Build a BufferGeometry for one polyline as a ribbon (strip of quads).
9
+ * Attributes: position, positionPrev, positionNext, side.
10
+ */
11
+ export declare function buildMeshLineGeometry(positions: THREE.Vector3[]): THREE.BufferGeometry;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Billboarded thick-line material (screen-space width).
3
+ * Adapted from the MeshLine approach: vertex shader expands the ribbon
4
+ * in clip space so lines have consistent pixel width and always face the camera.
5
+ */
6
+ import * as THREE from "three";
7
+ export interface MeshLineMaterialOptions {
8
+ color?: number;
9
+ lineWidth?: number;
10
+ resolution?: THREE.Vector2;
11
+ }
12
+ /**
13
+ * Material for billboarded thick lines. Width is in pixels (screen space).
14
+ * Requires resolution uniform (canvas size) for correct scaling.
15
+ */
16
+ export declare function createMeshLineMaterial(options?: MeshLineMaterialOptions): THREE.ShaderMaterial;
@@ -0,0 +1,21 @@
1
+ import { default as Line } from '../HelperClasses/Line';
2
+ /**
3
+ * Internal thick-line drawing: billboarded mesh-line (ribbon with screen-space width).
4
+ * No dependency on Three.js examples; geometry and material are maintained in-house.
5
+ * Based on the MeshLine approach (see e.g. threejs-meshline / THREE.MeshLine).
6
+ */
7
+ import * as THREE from "three";
8
+ /**
9
+ * Create a single thick line mesh from a Line (array of points).
10
+ * Uses a ribbon geometry + shader material so the line is billboarded
11
+ * and has consistent pixel width on screen.
12
+ *
13
+ * @param line - Line with .points (Point[])
14
+ * @param bounds - Scale factor applied to point coordinates (same as thin lines)
15
+ * @param color - Hex color
16
+ * @param lineWidthPx - Line width in pixels (screen space)
17
+ * @param resolution - Canvas size for correct scaling (optional)
18
+ * @returns A Three.js Mesh that can be added to the scene
19
+ */
20
+ export declare function createThickLineMesh(line: Line, bounds: number, color: number, lineWidthPx?: number, resolution?: THREE.Vector2): THREE.Mesh;
21
+ export declare function createThickEdgesGroup(edgeMap: Map<number, Line>, bounds: number, color: number, thickness?: number, resolution?: THREE.Vector2): THREE.Group;
@@ -0,0 +1,197 @@
1
+ import { default as Point } from '../HelperClasses/Point';
2
+ import { default as Line } from '../HelperClasses/Line';
3
+ import { default as Graph } from '../Core/Graph';
4
+ import * as THREE from "three";
5
+ /**
6
+ * Draw the vertices of the graph as a point cloud. **Static geometry** — use for one-shot layout.
7
+ * For time-based simulation use DrawTHREEGraphVerticesMutable and updatePositions() each frame.
8
+ *
9
+ * @param Graph - the graph that has to be drawn out
10
+ * @param bounds - A global scaling parameter defaults to 1 but change to scale up a graph
11
+ * @param size - The size of all the nodes - either an array the same length as nodes or a single number
12
+ * @param color - the color of the node defaults to white
13
+ * @param alpha - the alpha value of the node defaults to 1 (opaque)
14
+ * @returns a THREE.Group containing the point cloud
15
+ */
16
+ declare function DrawTHREEGraphVertices(Graph: Graph, bounds?: number, size?: number | number[], color?: number, alpha?: number): THREE.Group<THREE.Object3DEventMap>;
17
+ /**
18
+ * Result of DrawTHREEGraphVerticesMutable. Use `updatePositions()` each frame with simulation positions.
19
+ */
20
+ export interface MutableVerticesResult {
21
+ /** THREE.Group to add to the scene */
22
+ group: THREE.Group;
23
+ /** Update vertex positions from Float32Array (node order) or Map&lt;nodeId, Point&gt; */
24
+ updatePositions(positions: Float32Array | Map<number, Point>): void;
25
+ }
26
+ /**
27
+ * **Mutable** point cloud: positions can be updated each frame. Use for time-based simulation.
28
+ * Call updatePositions(simulation.getPositions()) (or a Map) in your animation loop.
29
+ * Node order matches get_node_ids_order().
30
+ */
31
+ declare function DrawTHREEGraphVerticesMutable(Graph: Graph, bounds?: number, size?: number | number[], color?: number, alpha?: number): MutableVerticesResult;
32
+ /**
33
+ * Draws all edges as thick lines. **Static geometry** — use for one-shot layout.
34
+ *
35
+ * @param Graph - The graph whose edges have to be drawn
36
+ * @param bounds - the global scale for all the edges to be drawn defaults to 1
37
+ * @param color - color of the edges defaults to white
38
+ * @param thickness - thickness of the edges (defaults to 0.4; screen-space pixels ≈ thickness × 100 for values &lt; 1)
39
+ * @returns a Three Js group of edges that can be added to the scene
40
+ */
41
+ declare function DrawTHREEGraphEdgesThick(Graph: Graph, bounds?: number, color?: number, thickness?: number): THREE.Group<THREE.Object3DEventMap>;
42
+ /**
43
+ *
44
+ * Draw thick edges from an edge map
45
+ *
46
+ * @param EdgeMap - The edge map associated with the graph
47
+ * @param bounds - The global scale of the graph - defaults to 1
48
+ * @param color - The color of the edges - defaults to white
49
+ * @param thickness - thickness of the edges (defaults to 0.4; pixels ≈ thickness × 100 for values &lt; 1)
50
+ * @returns
51
+ */
52
+ declare function DrawThickEdgesFromEdgeMap(EdgeMap: Map<number, Line>, bounds: number, color?: number, thickness?: number): THREE.Group<THREE.Object3DEventMap>;
53
+ /**
54
+ * Draw thin lines for all edges. **Static geometry** — use for one-shot layout.
55
+ * For time-based simulation use DrawTHREEGraphEdgesThinMutable and updateEdges() each frame.
56
+ *
57
+ * @param Graph - The graph that has to be drawn
58
+ * @param bounds - The global scale factor for the edges - defaults to 1
59
+ * @param color - color of the lines - defaults to white
60
+ * @returns a THREE.Group of lines
61
+ */
62
+ declare function DrawTHREEGraphEdgesThin(Graph: Graph, bounds?: number, color?: number): THREE.Group<THREE.Object3DEventMap>;
63
+ /**
64
+ * Result of DrawTHREEGraphEdgesThinMutable. Call `updateEdges()` after applying new positions to the graph.
65
+ */
66
+ export interface MutableEdgesResult {
67
+ /** THREE.Group containing the line segments */
68
+ group: THREE.Group;
69
+ /** Rebuild edge geometry from the graph's current position and edge maps */
70
+ updateEdges(): void;
71
+ }
72
+ /**
73
+ * **Mutable** thin edges: geometry is refreshed from the graph each frame. Use for time-based simulation.
74
+ * After updating the graph's position map and edge map, call updateEdges() in your animation loop.
75
+ */
76
+ declare function DrawTHREEGraphEdgesThinMutable(Graph: Graph, bounds?: number, color?: number): MutableEdgesResult;
77
+ /**
78
+ * Draw a single thick line through an ordered list of node IDs (e.g. a path).
79
+ * Uses graph positions; line width in pixels (pass thickness >= 1 for pixel width).
80
+ *
81
+ * @param Graph - Graph with position map
82
+ * @param bounds - Scale factor for positions
83
+ * @param pathNodeIds - Ordered node IDs (start to end)
84
+ * @param color - Hex color for the path line
85
+ * @param thickness - Line width in pixels (e.g. 5 for a thick path)
86
+ */
87
+ declare function DrawThickPathFromNodeIds(Graph: Graph, bounds: number, pathNodeIds: number[], color?: number, thickness?: number): THREE.Group<THREE.Object3DEventMap>;
88
+ /**
89
+ *
90
+ * Draw Line map as lines given the edge map assocaited with the graph
91
+ *
92
+ * @param LineMap - The edge map that has to be drawn out
93
+ * @param bounds - Global scale for the edges to be drawn defaults to 1
94
+ * @param color - Color of the edges defaults to 1
95
+ * @returns
96
+ */
97
+ declare function DrawThinEdgesFromEdgeMap(LineMap: Map<number, Line>, bounds?: number, color?: number): THREE.Group<THREE.Object3DEventMap>;
98
+ /**
99
+ * Add boxes for all nodes using one InstancedMesh (efficient for 1000s of boxes).
100
+ *
101
+ * @param nodeMap - a map of all the nodes
102
+ * @param bounds - global scale of the edges to be drawn, defaults to 1
103
+ * @param color - default color of the edges, defaults to white
104
+ * @param size - size of the nodes defaults to 10
105
+ * @returns a group containing one InstancedMesh for all boxes
106
+ */
107
+ declare function AddBoxBasedImaging(nodeMap: Map<number, Point>, bounds?: number, color?: number, size?: number | number[]): THREE.Group<THREE.Object3DEventMap>;
108
+ /**
109
+ * Result of DrawTHREEBoxBasedVerticesMutable. Use `updatePositions()` each frame for simulation.
110
+ */
111
+ export interface MutableBoxVerticesResult {
112
+ /** THREE.Group containing the instanced box mesh */
113
+ group: THREE.Group;
114
+ /** Update box positions from Float32Array or Map&lt;nodeId, Point&gt; */
115
+ updatePositions(positions: Float32Array | Map<number, Point>): void;
116
+ }
117
+ /**
118
+ * Box-based vertices as one InstancedMesh with updatable positions (e.g. for simulation).
119
+ * Node order matches get_node_ids_order() when called with a graph's position map.
120
+ */
121
+ declare function DrawTHREEBoxBasedVerticesMutable(Graph: Graph, bounds?: number, color?: number, size?: number | number[]): MutableBoxVerticesResult;
122
+ /**
123
+ *
124
+ * Draw box based verices given a graph
125
+ *
126
+ * @param Graph - The graph that needs its vertices drawn
127
+ * @param bounds - A global scale for the graph, defaults to one
128
+ * @param color - Default color of the boxes defaults to white
129
+ * @param size - Default size of the nodes defaults to 10
130
+ * @returns
131
+ */
132
+ declare function DrawTHREEBoxBasedVertices(Graph: Graph, bounds?: number, color?: number, size?: number | number[]): THREE.Group<THREE.Object3DEventMap>;
133
+ /**
134
+ *
135
+ * Draw cylinders where all the vertices are based on a node map
136
+ *
137
+ * @param nodeMap - the node map assiciate with the graph that has to be drawn out
138
+ * @param divisonLength - the length of the divisions that are there in each one of the cylinder (this is a circumfurence amount), defaults to 16
139
+ * @param color - the default color of the cylinder, defaults to white
140
+ * @param size - the default size of the cylinder, defaults to 10
141
+ * @returns
142
+ */
143
+ declare function AddCylinderBasedImaging(nodeMap: Map<number, Point>, divisonLength?: number, color?: number, size?: number | number[]): THREE.Group<THREE.Object3DEventMap>;
144
+ /**
145
+ *
146
+ * Split up a graph and return an boject containing a bunch of node groups and edge groups based on some parameterS
147
+ *
148
+ * @param Graph - the graph that you want to split up
149
+ * @param propertyName - the property that you want to split them on
150
+ * @returns - an object that hasa set of node vertices and a set of edge lines based on the splitting factor
151
+ */
152
+ declare function AddInModularityBasedPointGroups(Graph: Graph, propertyName: string): Promise<{
153
+ nodeGroups: Map<number, THREE.Group<THREE.Object3DEventMap>>;
154
+ EdgeGroups: Map<number, THREE.Group<THREE.Object3DEventMap>>;
155
+ }>;
156
+ /**
157
+ *
158
+ * Draw simplified line edges (thin based) based on some number. This number is a fraction of the total number of edges (so if you specify 0.1 it would draw 10% of the edges)
159
+ *
160
+ * @param Graph - The graph that has to be drawn out
161
+ * @param amount - The fraction of edges to be drawn
162
+ * @param color - color of these edges - defaults to 0.1
163
+ * @returns - a group of simple lines based on all the edges supplied to it
164
+ */
165
+ declare function DrawSimplifiedEdges(Graph: Graph, amount: number, color?: number): THREE.Group<THREE.Object3DEventMap>;
166
+ /**
167
+ * Set vertex colors by node ID. Uses the geometry's "label" attribute (node ID per vertex) to map node IDs to vertex indices; if "label" is missing, indexArray is treated as vertex indices.
168
+ *
169
+ * @param vertices - THREE.Points with customColor (and optionally label) attribute, or a Group whose first child is that Points object
170
+ * @param indexArray - Node IDs to color, or vertex indices if geometry has no label attribute
171
+ * @param color - Hex color to apply
172
+ */
173
+ declare function ChangeTheVertexColours(vertices: THREE.Points | THREE.Group, indexArray: number[], color: number): void;
174
+ /**
175
+ * Reset all vertex colors to white.
176
+ * @param vertices - THREE.Points with customColor attribute, or a Group whose first child is that Points object
177
+ */
178
+ declare function ResetVertexColors(vertices: THREE.Points | THREE.Group): void;
179
+ declare const _default: {
180
+ DrawTHREEGraphVertices: typeof DrawTHREEGraphVertices;
181
+ DrawTHREEGraphVerticesMutable: typeof DrawTHREEGraphVerticesMutable;
182
+ DrawTHREEGraphEdgesThick: typeof DrawTHREEGraphEdgesThick;
183
+ DrawTHREEGraphEdgesThin: typeof DrawTHREEGraphEdgesThin;
184
+ DrawTHREEGraphEdgesThinMutable: typeof DrawTHREEGraphEdgesThinMutable;
185
+ DrawThickPathFromNodeIds: typeof DrawThickPathFromNodeIds;
186
+ AddBoxBasedImaging: typeof AddBoxBasedImaging;
187
+ AddInModularityBasedPointGroups: typeof AddInModularityBasedPointGroups;
188
+ DrawThinEdgesFromEdgeMap: typeof DrawThinEdgesFromEdgeMap;
189
+ DrawThickEdgesFromEdgeMap: typeof DrawThickEdgesFromEdgeMap;
190
+ AddCylinderBasedImaging: typeof AddCylinderBasedImaging;
191
+ DrawSimplifiedEdges: typeof DrawSimplifiedEdges;
192
+ ChangeTheVertexColours: typeof ChangeTheVertexColours;
193
+ ResetVertexColors: typeof ResetVertexColors;
194
+ DrawTHREEBoxBasedVertices: typeof DrawTHREEBoxBasedVertices;
195
+ DrawTHREEBoxBasedVerticesMutable: typeof DrawTHREEBoxBasedVerticesMutable;
196
+ };
197
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export { default as Drawing } from './Drawing';
2
+ export { default as ThreeWrapper } from './ThreeJSDrawer';
3
+ export { default as GraphDrawer } from './GraphDrawer';
@@ -0,0 +1,47 @@
1
+ import { default as Graph } from '../Core/Graph';
2
+ /**
3
+ *
4
+ * Performs a BFS search on a graph - Async because it takes a while on large graphs
5
+ *
6
+ * @param Graph - The graph which has to be searched using the BFS algorithm
7
+ * @param node - The node form which to start
8
+ * @returns - A map of which node was explored from which other node
9
+ */
10
+ declare function BFSSearch(Graph: Graph, node: number): Promise<Map<number, number>>;
11
+ /**
12
+ *
13
+ * Performs a dijkstra search on a graph
14
+ *
15
+ * @param Graph - The graph on which to perform the Dijkstra search
16
+ * @param Node - The node from which to start
17
+ * @returns - Map from which each one of the nodes was searched from
18
+ */
19
+ declare function Dijkstra(Graph: Graph, Node: number): Promise<Map<number, number>>;
20
+ /**
21
+ *
22
+ * Finds the diameter of the graph
23
+ *
24
+ * @param Graph
25
+ * @returns returns an object with a start, end - the two points of a graph and the diameter of the graph
26
+ */
27
+ declare function GraphDiameter(Graph: Graph): Promise<{
28
+ start: number;
29
+ end: number;
30
+ distance: number;
31
+ }>;
32
+ /**
33
+ *
34
+ * Select a subgraph
35
+ *
36
+ * @param graph - The main graph to select from
37
+ * @param nodeList - The selection of nodes that we want to select from this graph
38
+ * @returns A graph object that contains this subgraph
39
+ */
40
+ declare function SelectSubgraph(graph: Graph, nodeList: number[]): Promise<Graph>;
41
+ declare const _default: {
42
+ GraphDiameter: typeof GraphDiameter;
43
+ Dijkstra: typeof Dijkstra;
44
+ BFSSearch: typeof BFSSearch;
45
+ SelectSubgraph: typeof SelectSubgraph;
46
+ };
47
+ export default _default;
@@ -0,0 +1 @@
1
+ export { default as GraphMethods } from './GraphMethods';