plebeiangraphlibrary 1.0.6
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/Textures/Square.png +0 -0
- package/Build/pgl.d.ts +642 -0
- package/Build/pgl.d.ts.map +1 -0
- package/Build/pgl.js +2960 -0
- package/Build/pgl.js.map +1 -0
- package/Build/pgl_module.js +32602 -0
- package/Build/pgl_module.js.map +1 -0
- package/CODE_OF_CONDUCT.md +40 -0
- package/CONTRIBUTING.md +52 -0
- package/Examples/1_ZKC_simple.html +76 -0
- package/Examples/2_ZKC_edge_bundling.html +82 -0
- package/Examples/3_LargePointCloud.html +82 -0
- package/Examples/4_ToggleActivation.html +106 -0
- package/Examples/MasterStyle.css +53 -0
- package/Examples/Textures/Square.png +0 -0
- package/Examples/index.html +34 -0
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/package.json +67 -0
package/Build/pgl.js
ADDED
|
@@ -0,0 +1,2960 @@
|
|
|
1
|
+
var $h9nKb$three = require("three");
|
|
2
|
+
var $h9nKb$threeexamplesjsmlinesLine2js = require("three/examples/jsm/lines/Line2.js");
|
|
3
|
+
var $h9nKb$threeexamplesjsmlinesLineMaterial = require("three/examples/jsm/lines/LineMaterial");
|
|
4
|
+
var $h9nKb$threeexamplesjsmlinesLineGeometry = require("three/examples/jsm/lines/LineGeometry");
|
|
5
|
+
var $h9nKb$threeexamplesjsmcontrolsOrbitControls = require("three/examples/jsm/controls/OrbitControls");
|
|
6
|
+
|
|
7
|
+
function $parcel$export(e, n, v, s) {
|
|
8
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
+
}
|
|
10
|
+
var $parcel$global =
|
|
11
|
+
typeof globalThis !== 'undefined'
|
|
12
|
+
? globalThis
|
|
13
|
+
: typeof self !== 'undefined'
|
|
14
|
+
? self
|
|
15
|
+
: typeof window !== 'undefined'
|
|
16
|
+
? window
|
|
17
|
+
: typeof global !== 'undefined'
|
|
18
|
+
? global
|
|
19
|
+
: {};
|
|
20
|
+
var $parcel$modules = {};
|
|
21
|
+
var $parcel$inits = {};
|
|
22
|
+
|
|
23
|
+
var parcelRequire = $parcel$global["parcelRequired21f"];
|
|
24
|
+
if (parcelRequire == null) {
|
|
25
|
+
parcelRequire = function(id) {
|
|
26
|
+
if (id in $parcel$modules) {
|
|
27
|
+
return $parcel$modules[id].exports;
|
|
28
|
+
}
|
|
29
|
+
if (id in $parcel$inits) {
|
|
30
|
+
var init = $parcel$inits[id];
|
|
31
|
+
delete $parcel$inits[id];
|
|
32
|
+
var module = {id: id, exports: {}};
|
|
33
|
+
$parcel$modules[id] = module;
|
|
34
|
+
init.call(module.exports, module, module.exports);
|
|
35
|
+
return module.exports;
|
|
36
|
+
}
|
|
37
|
+
var err = new Error("Cannot find module '" + id + "'");
|
|
38
|
+
err.code = 'MODULE_NOT_FOUND';
|
|
39
|
+
throw err;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
parcelRequire.register = function register(id, init) {
|
|
43
|
+
$parcel$inits[id] = init;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
$parcel$global["parcelRequired21f"] = parcelRequire;
|
|
47
|
+
}
|
|
48
|
+
parcelRequire.register("jYcHE", function(module, exports) {
|
|
49
|
+
|
|
50
|
+
$parcel$export(module.exports, "default", () => $e89d79794dbc0ba9$export$2e2bcd8739ae039);
|
|
51
|
+
|
|
52
|
+
var $6Xdhg = parcelRequire("6Xdhg");
|
|
53
|
+
|
|
54
|
+
var $fd3jp = parcelRequire("fd3jp");
|
|
55
|
+
|
|
56
|
+
var $fw40F = parcelRequire("fw40F");
|
|
57
|
+
|
|
58
|
+
var $3WMe9 = parcelRequire("3WMe9");
|
|
59
|
+
|
|
60
|
+
var $cWcXJ = parcelRequire("cWcXJ");
|
|
61
|
+
var __awaiter = undefined && undefined.__awaiter || function(thisArg11, _arguments11, P11, generator11) {
|
|
62
|
+
function adopt11(value11) {
|
|
63
|
+
return value11 instanceof P11 ? value11 : new P11(function(resolve11) {
|
|
64
|
+
resolve11(value11);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return new (P11 || (P11 = Promise))(function(resolve11, reject11) {
|
|
68
|
+
function fulfilled11(value11) {
|
|
69
|
+
try {
|
|
70
|
+
step11(generator11.next(value11));
|
|
71
|
+
} catch (e11) {
|
|
72
|
+
reject11(e11);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function rejected11(value11) {
|
|
76
|
+
try {
|
|
77
|
+
step11(generator11["throw"](value11));
|
|
78
|
+
} catch (e11) {
|
|
79
|
+
reject11(e11);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function step11(result11) {
|
|
83
|
+
result11.done ? resolve11(result11.value) : adopt11(result11.value).then(fulfilled11, rejected11);
|
|
84
|
+
}
|
|
85
|
+
step11((generator11 = generator11.apply(thisArg11, _arguments11 || [])).next());
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Simulates Kamada kawai for a network in 2d. 3d is not supported yet
|
|
90
|
+
* Note: This is an async function as it take time for some of the large graphs
|
|
91
|
+
*
|
|
92
|
+
* @param Graph - The first input number
|
|
93
|
+
* @param iterations - The second input number
|
|
94
|
+
* @param simulationBound - The bounds of simulation (Mostly a global number to scale the graph up or down)
|
|
95
|
+
* @param cohesionValue - How sticky the nodes are i.r. how much they cluster together
|
|
96
|
+
* @returns And node map of all the nodes and their simulated positions - Please note: position maps have to to be applied to the graph!
|
|
97
|
+
*
|
|
98
|
+
*/ function SimulateKamadaKawai(Graph11, iterations11, simulationBound11 = 100, cohesionValue11 = 1, repulsionValue11 = 1) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function*() {
|
|
100
|
+
const adjList11 = Graph11.get_adjacency();
|
|
101
|
+
// pos map
|
|
102
|
+
const PosMapX11 = new Map();
|
|
103
|
+
const PosMapY11 = new Map();
|
|
104
|
+
let rx11, ry11;
|
|
105
|
+
for (const node11 of adjList11.keys()){
|
|
106
|
+
rx11 = Math.random() * simulationBound11;
|
|
107
|
+
ry11 = Math.random() * simulationBound11;
|
|
108
|
+
PosMapX11.set(node11, rx11);
|
|
109
|
+
PosMapY11.set(node11, ry11);
|
|
110
|
+
}
|
|
111
|
+
// start simulation
|
|
112
|
+
for(let i11 = 0; i11 < iterations11; i11++){
|
|
113
|
+
// calculate the clustering force
|
|
114
|
+
// these two keep track of the node being simulated's
|
|
115
|
+
// position - redeclaring is sorta unncessary
|
|
116
|
+
let nodeX11;
|
|
117
|
+
let nodeY11;
|
|
118
|
+
// also keep track of all the x_s and y_s
|
|
119
|
+
let x_s11;
|
|
120
|
+
let y_s11;
|
|
121
|
+
// also the same thing for the clustering force
|
|
122
|
+
let y_r11;
|
|
123
|
+
let x_r11;
|
|
124
|
+
// same thing for the cohesion values that get recalculated
|
|
125
|
+
let new_c_xpos_dispacement11;
|
|
126
|
+
let new_c_ypos_dispacement11;
|
|
127
|
+
let new_x_r_pos11;
|
|
128
|
+
let new_y_r_pos11;
|
|
129
|
+
let new_c_xpos11;
|
|
130
|
+
let new_c_ypos11;
|
|
131
|
+
let new_g_xpos_displacement11;
|
|
132
|
+
let new_g_ypos_displacement11;
|
|
133
|
+
for (const node11 of adjList11.keys()){
|
|
134
|
+
// this chunk is for the attraction force
|
|
135
|
+
// get the node pos
|
|
136
|
+
const neighbours11 = adjList11.get(node11);
|
|
137
|
+
// remember always declare this nodes details
|
|
138
|
+
nodeX11 = PosMapX11.get(node11);
|
|
139
|
+
nodeY11 = PosMapY11.get(node11);
|
|
140
|
+
// get the set of x's
|
|
141
|
+
x_s11 = [];
|
|
142
|
+
// get the set of y's
|
|
143
|
+
y_s11 = [];
|
|
144
|
+
// now iterate through the pos list and append
|
|
145
|
+
neighbours11.forEach((n_s11)=>{
|
|
146
|
+
const n_pos_x11 = PosMapX11.get(n_s11);
|
|
147
|
+
const n_pos_y11 = PosMapY11.get(n_s11);
|
|
148
|
+
x_s11.push(n_pos_x11);
|
|
149
|
+
y_s11.push(n_pos_y11);
|
|
150
|
+
});
|
|
151
|
+
// now average out the values
|
|
152
|
+
new_c_xpos11 = (0, $6Xdhg.default).calculateAverage(x_s11);
|
|
153
|
+
new_c_ypos11 = (0, $6Xdhg.default).calculateAverage(y_s11);
|
|
154
|
+
// this chunk is for the repelling force
|
|
155
|
+
y_r11 = [];
|
|
156
|
+
x_r11 = [];
|
|
157
|
+
let diffx11;
|
|
158
|
+
let diffy11;
|
|
159
|
+
let othernodeX11;
|
|
160
|
+
let othernodeY11;
|
|
161
|
+
// then find the element
|
|
162
|
+
for (const otherNode11 of Graph11.nodes.keys())// get the position of all the other nodes
|
|
163
|
+
if (otherNode11 != node11) {
|
|
164
|
+
// calculate inverse distance
|
|
165
|
+
othernodeX11 = PosMapX11.get(otherNode11);
|
|
166
|
+
othernodeY11 = PosMapY11.get(otherNode11);
|
|
167
|
+
diffx11 = othernodeX11 - nodeX11;
|
|
168
|
+
diffy11 = othernodeY11 - nodeY11;
|
|
169
|
+
// get the inverse square value
|
|
170
|
+
// add that to the *_r arrays
|
|
171
|
+
x_r11.push(diffx11);
|
|
172
|
+
y_r11.push(diffy11);
|
|
173
|
+
}
|
|
174
|
+
// this is the repulsion value
|
|
175
|
+
new_x_r_pos11 = repulsionValue11 * 1 / ((0, $6Xdhg.default).calculateAverage(x_r11) * (0, $6Xdhg.default).calculateAverage(x_r11));
|
|
176
|
+
new_y_r_pos11 = repulsionValue11 * 1 / ((0, $6Xdhg.default).calculateAverage(y_r11) * (0, $6Xdhg.default).calculateAverage(y_r11));
|
|
177
|
+
// calculate the dispacement amount in c/y pos
|
|
178
|
+
// this is the cohesion value
|
|
179
|
+
new_c_xpos_dispacement11 = cohesionValue11 * (new_c_xpos11 - nodeX11);
|
|
180
|
+
new_c_ypos_dispacement11 = cohesionValue11 * (new_c_ypos11 - nodeY11);
|
|
181
|
+
// Also move all the points towards the center a little bit
|
|
182
|
+
// so that the graph doesent explode out
|
|
183
|
+
new_g_xpos_displacement11 = cohesionValue11 * (0 - nodeX11);
|
|
184
|
+
new_g_ypos_displacement11 = cohesionValue11 * (0 - nodeY11);
|
|
185
|
+
// then add the x and y components of the two vectors
|
|
186
|
+
const new_xpos11 = new_x_r_pos11 + new_g_xpos_displacement11 + new_c_xpos_dispacement11 + nodeX11;
|
|
187
|
+
const new_ypos11 = new_y_r_pos11 + new_g_ypos_displacement11 + new_c_ypos_dispacement11 + nodeY11;
|
|
188
|
+
// now set these positions
|
|
189
|
+
PosMapX11.set(node11, new_xpos11);
|
|
190
|
+
PosMapY11.set(node11, new_ypos11);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// return the position
|
|
194
|
+
// keep in mind three JS works with Y upwards and not Z
|
|
195
|
+
// in my head I work the other way round so Im swapping the Z and Y values here
|
|
196
|
+
let PosMap11 = new Map();
|
|
197
|
+
for (const p11 of PosMapX11.keys())PosMap11.set(p11, new (0, $fw40F.default)(PosMapX11.get(p11), 0, PosMapY11.get(p11)));
|
|
198
|
+
// get / set positions
|
|
199
|
+
// move the points
|
|
200
|
+
// Since this simulation might have moved the whole graph off screen
|
|
201
|
+
// get the average pos
|
|
202
|
+
const sim_x11 = [];
|
|
203
|
+
const sim_y11 = [];
|
|
204
|
+
const sim_z11 = [];
|
|
205
|
+
let interimPoint11;
|
|
206
|
+
for (const p11 of PosMap11.keys()){
|
|
207
|
+
interimPoint11 = PosMap11.get(p11);
|
|
208
|
+
sim_x11.push(interimPoint11.x);
|
|
209
|
+
sim_y11.push(interimPoint11.y);
|
|
210
|
+
sim_z11.push(interimPoint11.z);
|
|
211
|
+
}
|
|
212
|
+
const x_displacement11 = (0, $6Xdhg.default).calculateAverage(sim_x11);
|
|
213
|
+
const y_displacement11 = (0, $6Xdhg.default).calculateAverage(sim_y11);
|
|
214
|
+
const z_displacement11 = (0, $6Xdhg.default).calculateAverage(sim_z11);
|
|
215
|
+
const dispacementVector11 = new (0, $fw40F.default)(-x_displacement11, -y_displacement11, -z_displacement11);
|
|
216
|
+
PosMap11 = MovePmap(PosMap11, dispacementVector11);
|
|
217
|
+
return PosMap11;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* Randomly sets all the positions for a graph
|
|
223
|
+
* Not really very useful but I've used it in some cases and have kept it around
|
|
224
|
+
*
|
|
225
|
+
* @param Graph - The graph who's nodes you would want to reposition
|
|
226
|
+
*
|
|
227
|
+
* @return A position map of all the nodes and its corresponding positions
|
|
228
|
+
*/ function InstanciateRandomPositions(Graph11) {
|
|
229
|
+
const adjList11 = Graph11.get_adjacency();
|
|
230
|
+
const PosMapX11 = new Map();
|
|
231
|
+
const PosMapY11 = new Map();
|
|
232
|
+
for (const node11 of adjList11.keys()){
|
|
233
|
+
PosMapX11.set(node11, Math.random() * 200);
|
|
234
|
+
PosMapY11.set(node11, Math.random() * 200);
|
|
235
|
+
}
|
|
236
|
+
const PosMap11 = new Map();
|
|
237
|
+
for (const p11 of PosMapX11.keys())PosMap11.set(p11, new (0, $fw40F.default)(PosMapX11.get(p11), 0, PosMapY11.get(p11)));
|
|
238
|
+
return PosMap11;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
*
|
|
242
|
+
* Constructs the edges as lines, Note: these are just a representation of the lines
|
|
243
|
+
* they then have to be visulized using one of the Three JS Drawer functions like
|
|
244
|
+
* draw a thick line or a thin line. This draws out the edges divided by some number of
|
|
245
|
+
* divisions that you specify
|
|
246
|
+
*
|
|
247
|
+
* @param Graph - The graph whos edges are getting drawn
|
|
248
|
+
* @param divDistance - How many divisions (distance) to make along the edge
|
|
249
|
+
* @returns A line map - which holds a map of all the edge indices and the corresponding line representations
|
|
250
|
+
*/ function DrawEdgeLines(Graph11, divDistance11) {
|
|
251
|
+
// this is the return map
|
|
252
|
+
const lineMap11 = new Map();
|
|
253
|
+
let edge11;
|
|
254
|
+
let start11;
|
|
255
|
+
let end11;
|
|
256
|
+
for (const key11 of Graph11.edges.keys()){
|
|
257
|
+
edge11 = Graph11.edges.get(key11);
|
|
258
|
+
// get the start pos
|
|
259
|
+
start11 = Graph11.nodes.get(edge11.start).data.pos;
|
|
260
|
+
end11 = Graph11.nodes.get(edge11.end).data.pos;
|
|
261
|
+
const Line11 = (0, $fd3jp.default).line_from_start_end_distance(start11, end11, divDistance11);
|
|
262
|
+
lineMap11.set(key11, Line11);
|
|
263
|
+
}
|
|
264
|
+
return lineMap11;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
*
|
|
268
|
+
* Constructs the edges as lines, Note: these are just a representation of the lines
|
|
269
|
+
* they then have to be visulized using one of the Three JS Drawer functions like
|
|
270
|
+
* draw a thick line or a thin line - this draws them based on the number of divisions
|
|
271
|
+
* you would like them to have
|
|
272
|
+
* @param Graph - The graph whos edges are getting drawn
|
|
273
|
+
* @param numberOfDivs - How many divisions to make along the edge
|
|
274
|
+
* @returns A line map - which holds a map of all the edge indices and the corresponding line representations
|
|
275
|
+
*/ function DrawEdgeLinesDivisions(Graph11, numberOfDivs11) {
|
|
276
|
+
// this is the return map
|
|
277
|
+
const lineMap11 = new Map();
|
|
278
|
+
let edge11;
|
|
279
|
+
let start11;
|
|
280
|
+
let end11;
|
|
281
|
+
for (const key11 of Graph11.edges.keys()){
|
|
282
|
+
edge11 = Graph11.edges.get(key11);
|
|
283
|
+
// get the start pos
|
|
284
|
+
start11 = Graph11.nodes.get(edge11.start).data.pos;
|
|
285
|
+
end11 = Graph11.nodes.get(edge11.end).data.pos;
|
|
286
|
+
const Line11 = (0, $fd3jp.default).line_from_start_end_divisions(start11, end11, numberOfDivs11);
|
|
287
|
+
lineMap11.set(key11, Line11);
|
|
288
|
+
}
|
|
289
|
+
return lineMap11;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
*
|
|
293
|
+
* Edge bundling - this isnt as fast as the current KDE based methods - but it provides a basic method of
|
|
294
|
+
* Visualizing large edge flows. Note: This is an aysnc function as it takes a while for the edge bundling to happen
|
|
295
|
+
*
|
|
296
|
+
* @param LineMap - The map of edges as a line map
|
|
297
|
+
* @param iterations - The number of iterations to run edge bundling
|
|
298
|
+
* @param distance - A shorthand for how close together the vertices need to be before they get influnced by each other
|
|
299
|
+
* @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!
|
|
300
|
+
*/ function DrawEdgeBundling(LineMap11, iterations11, distance11) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function*() {
|
|
302
|
+
// first create a deep copy of the map
|
|
303
|
+
const returnArray11 = new Map();
|
|
304
|
+
for (let key11 of LineMap11.keys())returnArray11.set(key11, structuredClone(LineMap11.get(key11)));
|
|
305
|
+
// variables that are getting reused
|
|
306
|
+
let line11;
|
|
307
|
+
let otherLine11;
|
|
308
|
+
let x_s11;
|
|
309
|
+
let y_s11;
|
|
310
|
+
let z_s11;
|
|
311
|
+
let pnt11;
|
|
312
|
+
let otherpoint11;
|
|
313
|
+
let d11;
|
|
314
|
+
let x_d11;
|
|
315
|
+
let y_d11;
|
|
316
|
+
let z_d11;
|
|
317
|
+
let avgx11;
|
|
318
|
+
let avgy11;
|
|
319
|
+
let avgz11;
|
|
320
|
+
// run it for whatever number of iterations
|
|
321
|
+
for(let i11 = 0; i11 < iterations11; i11++)// then iterate through every line
|
|
322
|
+
for (let key11 of returnArray11.keys()){
|
|
323
|
+
// then get the line that we are working with
|
|
324
|
+
line11 = returnArray11.get(key11);
|
|
325
|
+
// then for each point in the line we have to move it closer to the other points
|
|
326
|
+
for(let ii11 = 1; ii11 < line11.points.length - 1; ii11++){
|
|
327
|
+
// then get the point that we need to work with
|
|
328
|
+
x_s11 = [];
|
|
329
|
+
y_s11 = [];
|
|
330
|
+
z_s11 = [];
|
|
331
|
+
pnt11 = line11.points[ii11];
|
|
332
|
+
// then run the point accumulation algoritm
|
|
333
|
+
for (let otherKey11 of returnArray11.keys())if (otherKey11 != key11) {
|
|
334
|
+
// then get the other line
|
|
335
|
+
otherLine11 = returnArray11.get(otherKey11);
|
|
336
|
+
for(let iii11 = 1; iii11 < otherLine11.points.length - 1; iii11++){
|
|
337
|
+
otherpoint11 = otherLine11.points[iii11];
|
|
338
|
+
d11 = (0, $6Xdhg.default).calculateSquaredDistance(pnt11, otherpoint11);
|
|
339
|
+
if (d11 <= Math.pow(distance11, 2)) {
|
|
340
|
+
x_d11 = otherpoint11.x - pnt11.x;
|
|
341
|
+
y_d11 = otherpoint11.y - pnt11.y;
|
|
342
|
+
z_d11 = otherpoint11.z - pnt11.z;
|
|
343
|
+
x_s11.push(x_d11);
|
|
344
|
+
y_s11.push(y_d11);
|
|
345
|
+
z_s11.push(z_d11);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// now create a new displacement amount
|
|
350
|
+
avgx11 = pnt11.x + 0.8 * ((0, $6Xdhg.default).calculateAverage(x_s11) || 0);
|
|
351
|
+
avgy11 = pnt11.y + 0.8 * ((0, $6Xdhg.default).calculateAverage(y_s11) || 0);
|
|
352
|
+
avgz11 = pnt11.z + 0.8 * ((0, $6Xdhg.default).calculateAverage(z_s11) || 0);
|
|
353
|
+
const newPoint11 = new (0, $fw40F.default)(avgx11, avgy11, avgz11);
|
|
354
|
+
line11.points[ii11] = newPoint11;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// now return that new map
|
|
358
|
+
return returnArray11;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
*
|
|
363
|
+
* Displace the edges vertically, almost akin to the Deck.gl arcs
|
|
364
|
+
* The displacement is done in a sin curve with the ends still touching the nodes
|
|
365
|
+
* Note: This is an inplace modification of the edges
|
|
366
|
+
*
|
|
367
|
+
* @param LineMap - The map of edges as a line map
|
|
368
|
+
* @param displacement - the amount of vertical displacement
|
|
369
|
+
*/ function DisplaceEdgeInY(LineMap11, displacement11) {
|
|
370
|
+
const returnArray11 = new Map();
|
|
371
|
+
for (let key11 of LineMap11.keys())returnArray11.set(key11, structuredClone(LineMap11.get(key11)));
|
|
372
|
+
for (const key11 of returnArray11.keys()){
|
|
373
|
+
const line11 = returnArray11.get(key11);
|
|
374
|
+
// now for all the points in this
|
|
375
|
+
let pnt11, ydisval11;
|
|
376
|
+
for(let i11 = 0; i11 < line11.points.length; i11++){
|
|
377
|
+
pnt11 = line11.points[i11];
|
|
378
|
+
ydisval11 = displacement11 * Math.sin(Math.PI * i11 / (line11.points.length - 1));
|
|
379
|
+
pnt11.y = pnt11.y + ydisval11;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return returnArray11;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
*
|
|
386
|
+
* Displace the vertices vertically based on some prameter (For example degree or modularity)
|
|
387
|
+
*
|
|
388
|
+
* @param Graph - the graph whos nodes have to be displaced
|
|
389
|
+
* @param parameter - the prameter based on which you want to modify the
|
|
390
|
+
* @param displacement - the maximum amunt of displacement, all the other values are rescaled linerly
|
|
391
|
+
*/ function DisplaceVertices(Graph, parameter, displacement) {
|
|
392
|
+
let max = 0;
|
|
393
|
+
let value, ydisplacement;
|
|
394
|
+
// go through the thing and set the min max values
|
|
395
|
+
for (let node of Graph.nodes.values()){
|
|
396
|
+
value = eval("node.data." + parameter);
|
|
397
|
+
if (value >= max) max = value;
|
|
398
|
+
}
|
|
399
|
+
// go through the nodes again and set the values
|
|
400
|
+
for (const node of Graph.nodes.values()){
|
|
401
|
+
value = eval("node.data." + parameter);
|
|
402
|
+
ydisplacement = value / max * displacement;
|
|
403
|
+
// now filter the values so that we know that the values are between a max and a min
|
|
404
|
+
ydisplacement = Math.max(0, ydisplacement); // this sets the lower bound to be something
|
|
405
|
+
ydisplacement = Math.min(displacement, ydisplacement); // this sets the upper bound of the thing
|
|
406
|
+
node.data.pos.y = ydisplacement;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
*
|
|
411
|
+
* 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
|
|
412
|
+
*
|
|
413
|
+
* @param Graph - The graph
|
|
414
|
+
* @param selectedNode - the node around which the hive plot is generated
|
|
415
|
+
* @param step - If the hive should step up or down if yes then by what increments
|
|
416
|
+
* @param startPosition - Starting position
|
|
417
|
+
* @returns
|
|
418
|
+
*/ function HivePlot(Graph11, selectedNode11, step11, startPosition11) {
|
|
419
|
+
return __awaiter(this, void 0, void 0, function*() {
|
|
420
|
+
const adj11 = Graph11.get_adjacency();
|
|
421
|
+
const DijkstraDepth11 = yield (0, $cWcXJ.default).Dijkstra(Graph11, selectedNode11);
|
|
422
|
+
// calculate the number of steps that I am searching through
|
|
423
|
+
const steps11 = Math.max(...[
|
|
424
|
+
...DijkstraDepth11.values()
|
|
425
|
+
]);
|
|
426
|
+
// step map
|
|
427
|
+
const stepMap11 = new Map();
|
|
428
|
+
// now create a stepped ring of stuff
|
|
429
|
+
for(let i11 = 0; i11 <= steps11; i11++){
|
|
430
|
+
const ntier11 = [];
|
|
431
|
+
for (const nkey11 of DijkstraDepth11.keys())if (i11 == DijkstraDepth11.get(nkey11)) ntier11.push(nkey11);
|
|
432
|
+
stepMap11.set(i11, ntier11);
|
|
433
|
+
}
|
|
434
|
+
// the returning pos map
|
|
435
|
+
const Pmap11 = new Map();
|
|
436
|
+
// now find the relevant node Positions
|
|
437
|
+
// get the start positions
|
|
438
|
+
const xoff11 = startPosition11.x || 0;
|
|
439
|
+
const yoff11 = startPosition11.y || 0;
|
|
440
|
+
const zoff11 = startPosition11.z || 0;
|
|
441
|
+
// set the positions
|
|
442
|
+
for (const node11 of adj11.keys()){
|
|
443
|
+
const yval11 = DijkstraDepth11.get(node11) * step11;
|
|
444
|
+
const depthArr11 = stepMap11.get(DijkstraDepth11.get(node11));
|
|
445
|
+
const angle11 = 2 * Math.PI * (depthArr11.indexOf(node11) / depthArr11.length);
|
|
446
|
+
const xval11 = Math.sin(angle11) * yval11;
|
|
447
|
+
const zval11 = Math.cos(angle11) * yval11;
|
|
448
|
+
// construct a new point
|
|
449
|
+
const pnt11 = new (0, $fw40F.default)(xval11 + xoff11, -yval11 + yoff11, zval11 + zoff11);
|
|
450
|
+
Pmap11.set(node11, pnt11);
|
|
451
|
+
}
|
|
452
|
+
// simulate the lines
|
|
453
|
+
Graph11.apply_position_map(Pmap11);
|
|
454
|
+
const lmap11 = DrawEdgeLines(Graph11, 1);
|
|
455
|
+
const newLmap11 = yield DrawEdgeBundling(lmap11, 12, 5);
|
|
456
|
+
return {
|
|
457
|
+
pmap: Pmap11,
|
|
458
|
+
emap: newLmap11
|
|
459
|
+
};
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Move a graph somewhere (like the physical location) - This is an inplace movement and overwrites existing values
|
|
464
|
+
*
|
|
465
|
+
* @param Graph - The graph that has to be moved
|
|
466
|
+
* @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
|
|
467
|
+
*/ function MoveGraph(Graph11, dispacement11) {
|
|
468
|
+
const Gmap11 = Graph11.get_map();
|
|
469
|
+
const NewPmap11 = MovePmap(Gmap11.pmap, dispacement11);
|
|
470
|
+
const NewEmap11 = MoveEmap(Gmap11.emap, dispacement11);
|
|
471
|
+
Graph11.apply_drawing_maps({
|
|
472
|
+
pmap: NewPmap11,
|
|
473
|
+
emap: NewEmap11
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
*
|
|
478
|
+
* Move the nodes somewhere (Or the nodemap corresponding to the graph) - This is not an overwrite rather returns a new position map for the nodes to moved
|
|
479
|
+
*
|
|
480
|
+
* @param NodeM
|
|
481
|
+
* ap - The Current position map of the graph
|
|
482
|
+
* @param displacement - The Displacement vector
|
|
483
|
+
* @returns - A new position map
|
|
484
|
+
*/ function MovePmap(NodeMap11, displacement11) {
|
|
485
|
+
const newPmap11 = new Map();
|
|
486
|
+
for (let node11 of NodeMap11.keys()){
|
|
487
|
+
const p11 = NodeMap11.get(node11);
|
|
488
|
+
p11.translate(displacement11);
|
|
489
|
+
newPmap11.set(node11, p11);
|
|
490
|
+
}
|
|
491
|
+
return newPmap11;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
*
|
|
495
|
+
* Move the edges somewhere (the edgemap corresponding to the graph) - This is not an overwrite and returns a new edge map for the edges to be moved too
|
|
496
|
+
*
|
|
497
|
+
* @param LineMap - The current line map, this is made up of lines
|
|
498
|
+
* @param dispacement - The displacement vector
|
|
499
|
+
* @returns - The new line map
|
|
500
|
+
*/ function MoveEmap(LineMap11, dispacement11) {
|
|
501
|
+
const newEmap11 = new Map();
|
|
502
|
+
// variables - instead of redeclaring
|
|
503
|
+
let interimPoints11;
|
|
504
|
+
let interimLine11;
|
|
505
|
+
let newLine11;
|
|
506
|
+
for (let lineNumber11 of LineMap11.keys()){
|
|
507
|
+
// reset the interim points
|
|
508
|
+
interimPoints11 = [];
|
|
509
|
+
// get the line
|
|
510
|
+
interimLine11 = LineMap11.get(lineNumber11);
|
|
511
|
+
// move all the points
|
|
512
|
+
for (let pnt11 of interimLine11.points){
|
|
513
|
+
pnt11.translate(dispacement11);
|
|
514
|
+
// add this to the new stack of lines
|
|
515
|
+
interimPoints11.push(pnt11);
|
|
516
|
+
}
|
|
517
|
+
// create a new line
|
|
518
|
+
newLine11 = new (0, $3WMe9.default)(interimPoints11);
|
|
519
|
+
// add this to the new map
|
|
520
|
+
newEmap11.set(lineNumber11, newLine11);
|
|
521
|
+
}
|
|
522
|
+
return newEmap11;
|
|
523
|
+
}
|
|
524
|
+
// THIS IS THE BIT THATS A BIT CONFUSING
|
|
525
|
+
/*
|
|
526
|
+
Data for visualization is store in the graph under the elements data
|
|
527
|
+
So for example - the position data under a point in the graph is under
|
|
528
|
+
- Graph.nodes.get(whatever node).data.pos
|
|
529
|
+
*/ // commenting out because appears to be redundant
|
|
530
|
+
// update edge lines after moving points or something
|
|
531
|
+
// this redraws the lines based on distance
|
|
532
|
+
/**
|
|
533
|
+
*
|
|
534
|
+
* 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.
|
|
535
|
+
*
|
|
536
|
+
* @param Graph - The grapht who's edges have to be updated
|
|
537
|
+
* @param divDistance - The distance by which the divisions are made
|
|
538
|
+
*/ function UpdateEdgeLinesDist(Graph11, divDistance11) {
|
|
539
|
+
let edge11;
|
|
540
|
+
let start11;
|
|
541
|
+
let end11;
|
|
542
|
+
let line11;
|
|
543
|
+
for (const key11 of Graph11.edges.keys()){
|
|
544
|
+
edge11 = Graph11.edges.get(key11);
|
|
545
|
+
// get the start pos
|
|
546
|
+
start11 = Graph11.nodes.get(edge11.start).data.pos;
|
|
547
|
+
end11 = Graph11.nodes.get(edge11.end).data.pos;
|
|
548
|
+
line11 = (0, $fd3jp.default).line_from_start_end_distance(start11, end11, divDistance11);
|
|
549
|
+
edge11.data.ldata = line11;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
*
|
|
554
|
+
* 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.
|
|
555
|
+
|
|
556
|
+
* @param Graph - The grapht who's edges have to be updated
|
|
557
|
+
* @param Divs - The number of divisions to be made
|
|
558
|
+
*/ function UpdateEdgeLinesDivs(Graph11, Divs11) {
|
|
559
|
+
let edge11;
|
|
560
|
+
let start11;
|
|
561
|
+
let end11;
|
|
562
|
+
let line11;
|
|
563
|
+
for (const key11 of Graph11.edges.keys()){
|
|
564
|
+
edge11 = Graph11.edges.get(key11);
|
|
565
|
+
// get the start pos
|
|
566
|
+
start11 = Graph11.nodes.get(edge11.start).data.pos;
|
|
567
|
+
end11 = Graph11.nodes.get(edge11.end).data.pos;
|
|
568
|
+
line11 = (0, $fd3jp.default).line_from_start_end_divisions(start11, end11, Divs11);
|
|
569
|
+
edge11.data.ldata = line11;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
var $e89d79794dbc0ba9$export$2e2bcd8739ae039 = {
|
|
573
|
+
SimulateKamadaKawai: SimulateKamadaKawai,
|
|
574
|
+
DrawEdgeLines: DrawEdgeLines,
|
|
575
|
+
DrawEdgeLinesDivisions: DrawEdgeLinesDivisions,
|
|
576
|
+
DrawEdgeBundling: DrawEdgeBundling,
|
|
577
|
+
HivePlot: HivePlot,
|
|
578
|
+
DisplaceEdgeInY: DisplaceEdgeInY,
|
|
579
|
+
MoveGraph: MoveGraph,
|
|
580
|
+
InstanciateRandomPositions: InstanciateRandomPositions,
|
|
581
|
+
DisplaceVertices: DisplaceVertices,
|
|
582
|
+
UpdateEdgeLinesDist: // these two are special functions
|
|
583
|
+
UpdateEdgeLinesDist,
|
|
584
|
+
UpdateEdgeLinesDivs: UpdateEdgeLinesDivs
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
});
|
|
588
|
+
parcelRequire.register("6Xdhg", function(module, exports) {
|
|
589
|
+
|
|
590
|
+
$parcel$export(module.exports, "default", () => $51028d69415a7fb7$export$2e2bcd8739ae039);
|
|
591
|
+
// Calculate average
|
|
592
|
+
/**
|
|
593
|
+
* calculate the average of an array of numberss
|
|
594
|
+
* @param arr an array of number whose average has to be calculated
|
|
595
|
+
* @returns the average
|
|
596
|
+
*/ function $51028d69415a7fb7$var$calculateAverage(arr) {
|
|
597
|
+
let runningSum = 0;
|
|
598
|
+
for(let i = 0; i < arr.length; i++)runningSum = runningSum + arr[i];
|
|
599
|
+
const avg = runningSum / arr.length;
|
|
600
|
+
if (Number.isNaN(avg)) return 0;
|
|
601
|
+
return avg;
|
|
602
|
+
}
|
|
603
|
+
// calculate distance between two points
|
|
604
|
+
/**
|
|
605
|
+
* Calculate the distance betweeen two points
|
|
606
|
+
* @param p1 the first point
|
|
607
|
+
* @param p2 the second point
|
|
608
|
+
* @returns the distance between the points
|
|
609
|
+
*/ function $51028d69415a7fb7$var$calculateDistance(p1, p2) {
|
|
610
|
+
const d = Math.pow(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2) + Math.pow(p1.z - p2.z, 2), 0.5);
|
|
611
|
+
return d;
|
|
612
|
+
}
|
|
613
|
+
// calculate squared distance sometimes we dont really need
|
|
614
|
+
// the actual root but just a rough idea
|
|
615
|
+
/**
|
|
616
|
+
* Calculate the squared distance between two points
|
|
617
|
+
* @param p1 the first point
|
|
618
|
+
* @param p2 the second point
|
|
619
|
+
* @returns the squared distance between the two points
|
|
620
|
+
*/ function $51028d69415a7fb7$var$calculateSquaredDistance(p1, p2) {
|
|
621
|
+
const d = Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2) + Math.pow(p1.z - p2.z, 2);
|
|
622
|
+
return d;
|
|
623
|
+
}
|
|
624
|
+
// get a random subset of something from a array of things
|
|
625
|
+
// must provide the number of things we want from that array
|
|
626
|
+
/**
|
|
627
|
+
* get a random subset of something from a array of things must provide the number of things we want from that array
|
|
628
|
+
* @param arr the array from which the subset has to be made
|
|
629
|
+
* @param n number of items to select
|
|
630
|
+
* @returns a new array made up of a random sample from the original array
|
|
631
|
+
*/ function $51028d69415a7fb7$var$getRandomSubset(arr, n) {
|
|
632
|
+
var result = new Array(n), len = arr.length, taken = new Array(len);
|
|
633
|
+
if (n > len) throw new RangeError("getRandom: more elements taken than available");
|
|
634
|
+
while(n--){
|
|
635
|
+
var x = Math.floor(Math.random() * len);
|
|
636
|
+
result[n] = arr[x in taken ? taken[x] : x];
|
|
637
|
+
taken[x] = --len in taken ? taken[len] : len;
|
|
638
|
+
}
|
|
639
|
+
return result;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* This is a super useful method to get a random number of edges or something that you would like to draw
|
|
643
|
+
* this is primarily done because there are way too many edges sometimes and and the number of edges is really
|
|
644
|
+
* What slows the whole rendering process down
|
|
645
|
+
* @param map - the map that youd like to reduce
|
|
646
|
+
* @param n - the fraction of items that youd like to return from this map
|
|
647
|
+
* @returns A reduced map with a fractio of those many entries
|
|
648
|
+
*/ function $51028d69415a7fb7$var$getRandomSubset_map(map, n) {
|
|
649
|
+
const newMap = new Map();
|
|
650
|
+
let prob;
|
|
651
|
+
for (const item of map.keys()){
|
|
652
|
+
prob = Math.random();
|
|
653
|
+
if (prob < n) newMap.set(item, map.get(item));
|
|
654
|
+
}
|
|
655
|
+
return newMap;
|
|
656
|
+
}
|
|
657
|
+
var $51028d69415a7fb7$export$2e2bcd8739ae039 = {
|
|
658
|
+
calculateAverage: $51028d69415a7fb7$var$calculateAverage,
|
|
659
|
+
calculateDistance: $51028d69415a7fb7$var$calculateDistance,
|
|
660
|
+
calculateSquaredDistance: $51028d69415a7fb7$var$calculateSquaredDistance,
|
|
661
|
+
getRandomSubset: $51028d69415a7fb7$var$getRandomSubset,
|
|
662
|
+
getRandomSubset_map: $51028d69415a7fb7$var$getRandomSubset_map
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
parcelRequire.register("fd3jp", function(module, exports) {
|
|
668
|
+
|
|
669
|
+
$parcel$export(module.exports, "default", () => $b12aa3a1ba88a23a$export$2e2bcd8739ae039);
|
|
670
|
+
|
|
671
|
+
var $fw40F = parcelRequire("fw40F");
|
|
672
|
+
|
|
673
|
+
var $3WMe9 = parcelRequire("3WMe9");
|
|
674
|
+
|
|
675
|
+
var $6Xdhg = parcelRequire("6Xdhg");
|
|
676
|
+
/**
|
|
677
|
+
* Creates a line based on the number of divisons
|
|
678
|
+
*
|
|
679
|
+
* @param start the start point
|
|
680
|
+
* @param end the end point
|
|
681
|
+
* @param divisions the number of divisions
|
|
682
|
+
* @returns the line object
|
|
683
|
+
*/ function $b12aa3a1ba88a23a$var$line_from_start_end_divisions(start, end, divisions) {
|
|
684
|
+
// create a start and end time
|
|
685
|
+
const Start = new (0, $fw40F.default)(start.x, start.y, start.z);
|
|
686
|
+
const End = new (0, $fw40F.default)(end.x, end.y, end.z);
|
|
687
|
+
// interpolated points
|
|
688
|
+
const points = [];
|
|
689
|
+
// divisions
|
|
690
|
+
for(let i = 0; i <= divisions; i++){
|
|
691
|
+
const interVar = i / divisions;
|
|
692
|
+
const newx = interVar * Start.x + (1 - interVar) * End.x;
|
|
693
|
+
const newy = interVar * Start.y + (1 - interVar) * End.y;
|
|
694
|
+
const newz = interVar * Start.z + (1 - interVar) * End.z;
|
|
695
|
+
const newPoint = new (0, $fw40F.default)(newx, newy, newz);
|
|
696
|
+
points.push(newPoint);
|
|
697
|
+
}
|
|
698
|
+
// create a new line
|
|
699
|
+
const SubdividedLine = new (0, $3WMe9.default)(points);
|
|
700
|
+
return SubdividedLine;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Divides the line into a number of divisions based on distance
|
|
704
|
+
* @param start - the start point
|
|
705
|
+
* @param end - the end point
|
|
706
|
+
* @param distance - the distance at which this line must be divided
|
|
707
|
+
* @returns A line object with the right number of points
|
|
708
|
+
*/ function $b12aa3a1ba88a23a$var$line_from_start_end_distance(start, end, distance) {
|
|
709
|
+
const dist = (0, $6Xdhg.default).calculateDistance(start, end);
|
|
710
|
+
const divs = Math.round(dist / distance) + 2;
|
|
711
|
+
const subdivline = $b12aa3a1ba88a23a$var$line_from_start_end_divisions(start, end, divs);
|
|
712
|
+
return subdivline;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Calculates the centroid of an array of points
|
|
716
|
+
* @param points An array of points
|
|
717
|
+
* @returns the central point of the array of points
|
|
718
|
+
*/ function $b12aa3a1ba88a23a$var$centroid(points) {
|
|
719
|
+
let rx = 0;
|
|
720
|
+
let ry = 0;
|
|
721
|
+
let rz = 0;
|
|
722
|
+
points.forEach((element)=>{
|
|
723
|
+
rx += element.x;
|
|
724
|
+
ry += element.y;
|
|
725
|
+
rz += element.z;
|
|
726
|
+
});
|
|
727
|
+
rx = rx / points.length;
|
|
728
|
+
ry = ry / points.length;
|
|
729
|
+
rz = rz / points.length;
|
|
730
|
+
const centroid = new (0, $fw40F.default)(rx, ry, rz);
|
|
731
|
+
return centroid;
|
|
732
|
+
}
|
|
733
|
+
var $b12aa3a1ba88a23a$export$2e2bcd8739ae039 = {
|
|
734
|
+
line_from_start_end_divisions: $b12aa3a1ba88a23a$var$line_from_start_end_divisions,
|
|
735
|
+
line_from_start_end_distance: $b12aa3a1ba88a23a$var$line_from_start_end_distance,
|
|
736
|
+
centroid: $b12aa3a1ba88a23a$var$centroid
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
});
|
|
740
|
+
parcelRequire.register("fw40F", function(module, exports) {
|
|
741
|
+
|
|
742
|
+
$parcel$export(module.exports, "default", () => $b4bcf46d914a9151$export$2e2bcd8739ae039);
|
|
743
|
+
class $b4bcf46d914a9151$var$Point {
|
|
744
|
+
/**
|
|
745
|
+
* Constructs a point based on the x y z values
|
|
746
|
+
* @param x x value
|
|
747
|
+
* @param y y value
|
|
748
|
+
* @param z z value
|
|
749
|
+
*/ constructor(x, y, z){
|
|
750
|
+
this.x = x;
|
|
751
|
+
this.y = y;
|
|
752
|
+
this.z = z;
|
|
753
|
+
}
|
|
754
|
+
// Points are somewhat the same thing as a vector
|
|
755
|
+
// So im using the same type instead of redeclaring the
|
|
756
|
+
// Type
|
|
757
|
+
/**
|
|
758
|
+
* Displaces a point - note this method moves the existing point
|
|
759
|
+
* @param Point This is the displacement vactor, used as a point but the same idea holds
|
|
760
|
+
*/ translate(Point) {
|
|
761
|
+
this.x = this.x + Point.x;
|
|
762
|
+
this.y = this.y + Point.y;
|
|
763
|
+
this.z = this.z + Point.z;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
var $b4bcf46d914a9151$export$2e2bcd8739ae039 = $b4bcf46d914a9151$var$Point;
|
|
767
|
+
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
parcelRequire.register("3WMe9", function(module, exports) {
|
|
771
|
+
|
|
772
|
+
$parcel$export(module.exports, "default", () => $2dfc32cf7d94658f$export$2e2bcd8739ae039);
|
|
773
|
+
|
|
774
|
+
var $fw40F = parcelRequire("fw40F");
|
|
775
|
+
class $2dfc32cf7d94658f$var$Line {
|
|
776
|
+
/**
|
|
777
|
+
* Constructs a line from an array of points
|
|
778
|
+
* @param points an array of points
|
|
779
|
+
*/ constructor(points){
|
|
780
|
+
this.points = [];
|
|
781
|
+
points.forEach((p)=>{
|
|
782
|
+
const point = new (0, $fw40F.default)(p.x, p.y, p.z);
|
|
783
|
+
this.points.push(point);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
var $2dfc32cf7d94658f$export$2e2bcd8739ae039 = $2dfc32cf7d94658f$var$Line;
|
|
788
|
+
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
parcelRequire.register("cWcXJ", function(module, exports) {
|
|
793
|
+
|
|
794
|
+
$parcel$export(module.exports, "default", () => $96b4f4dcd8ff333f$export$2e2bcd8739ae039);
|
|
795
|
+
|
|
796
|
+
var $9TL8g = parcelRequire("9TL8g");
|
|
797
|
+
var $96b4f4dcd8ff333f$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
798
|
+
function adopt(value) {
|
|
799
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
800
|
+
resolve(value);
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
804
|
+
function fulfilled(value) {
|
|
805
|
+
try {
|
|
806
|
+
step(generator.next(value));
|
|
807
|
+
} catch (e) {
|
|
808
|
+
reject(e);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function rejected(value) {
|
|
812
|
+
try {
|
|
813
|
+
step(generator["throw"](value));
|
|
814
|
+
} catch (e) {
|
|
815
|
+
reject(e);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function step(result) {
|
|
819
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
820
|
+
}
|
|
821
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
// do a BFS Search Starting from some point
|
|
825
|
+
// searches the whole graph and returns a map of which node
|
|
826
|
+
// was searched from where
|
|
827
|
+
// to speed this up all the nodes are actually numbers
|
|
828
|
+
/**
|
|
829
|
+
*
|
|
830
|
+
* Performs a BFS search on a graph - Async because it takes a while on large graphs
|
|
831
|
+
*
|
|
832
|
+
* @param Graph - The graph which has to be searched using the BFS algorithm
|
|
833
|
+
* @param node - The node form which to start
|
|
834
|
+
* @returns - A map of which node was explored from which other node
|
|
835
|
+
*/ function $96b4f4dcd8ff333f$var$BFSSearch(Graph, node) {
|
|
836
|
+
return $96b4f4dcd8ff333f$var$__awaiter(this, void 0, void 0, function*() {
|
|
837
|
+
const adj = Graph.get_adjacency();
|
|
838
|
+
const exploredFromMap = new Map();
|
|
839
|
+
const explored = [];
|
|
840
|
+
const stack = [];
|
|
841
|
+
// queue the first node
|
|
842
|
+
stack.push(node);
|
|
843
|
+
exploredFromMap.set(node, -1);
|
|
844
|
+
// search through the whole graph
|
|
845
|
+
while(stack.length > 0){
|
|
846
|
+
const currentNode = stack.pop();
|
|
847
|
+
// add this current node to the explored list
|
|
848
|
+
explored.push(currentNode);
|
|
849
|
+
const neighbours = adj.get(currentNode);
|
|
850
|
+
for(let i = 0; i < neighbours.length; i++){
|
|
851
|
+
const neighbour = neighbours[i];
|
|
852
|
+
if (!explored.includes(neighbour)) {
|
|
853
|
+
stack.push(neighbour);
|
|
854
|
+
exploredFromMap.set(neighbour, currentNode);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
// then return the explored from map
|
|
859
|
+
return exploredFromMap;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
// do a dijkstra Search Distance map
|
|
863
|
+
/**
|
|
864
|
+
*
|
|
865
|
+
* Performs a dijkstra search on a graph
|
|
866
|
+
*
|
|
867
|
+
* @param Graph - The graph on which to perform the Dijkstra search
|
|
868
|
+
* @param Node - The node from which to start
|
|
869
|
+
* @returns - Map from which each one of the nodes was searched from
|
|
870
|
+
*/ function $96b4f4dcd8ff333f$var$Dijkstra(Graph, Node) {
|
|
871
|
+
return $96b4f4dcd8ff333f$var$__awaiter(this, void 0, void 0, function*() {
|
|
872
|
+
const adj = Graph.get_adjacency();
|
|
873
|
+
const Dmap = new Map();
|
|
874
|
+
// get the explored from map
|
|
875
|
+
const exploredFromMap = yield $96b4f4dcd8ff333f$var$BFSSearch(Graph, Node);
|
|
876
|
+
// then for each element in the map go through
|
|
877
|
+
// contact trace where that element came from
|
|
878
|
+
for (const n of adj.keys()){
|
|
879
|
+
let i = 0;
|
|
880
|
+
let exploredFrom = exploredFromMap.get(n);
|
|
881
|
+
while(exploredFrom != -1){
|
|
882
|
+
exploredFrom = exploredFromMap.get(exploredFrom);
|
|
883
|
+
i += 1;
|
|
884
|
+
}
|
|
885
|
+
Dmap.set(n, i);
|
|
886
|
+
}
|
|
887
|
+
// now return this map
|
|
888
|
+
return Dmap;
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
// This file contains basic things like
|
|
892
|
+
// Graph searches and stuff
|
|
893
|
+
// this only returns one of the diameters that is the longest
|
|
894
|
+
// not all of them
|
|
895
|
+
/**
|
|
896
|
+
*
|
|
897
|
+
* Finds the diameter of the graph
|
|
898
|
+
*
|
|
899
|
+
* @param Graph
|
|
900
|
+
* @returns returns an object with a start, end - the two points of a graph and the diameter of the graph
|
|
901
|
+
*/ function $96b4f4dcd8ff333f$var$GraphDiameter(Graph) {
|
|
902
|
+
return $96b4f4dcd8ff333f$var$__awaiter(this, void 0, void 0, function*() {
|
|
903
|
+
// find the diameter of the graph
|
|
904
|
+
// start Dijkstra from some random node
|
|
905
|
+
let seed = Math.floor(Math.random() * Graph.nodes.size);
|
|
906
|
+
let Dstart = yield $96b4f4dcd8ff333f$var$Dijkstra(Graph, seed);
|
|
907
|
+
// iterate through all the values and then get
|
|
908
|
+
// the value that is the highest amongst the others
|
|
909
|
+
let currentDistance = -1;
|
|
910
|
+
for (const n of Dstart.keys()){
|
|
911
|
+
const dval = Dstart.get(n);
|
|
912
|
+
if (dval > currentDistance) {
|
|
913
|
+
seed = n;
|
|
914
|
+
currentDistance = dval;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
// then search from there to the furthest point again
|
|
918
|
+
const newStart = seed;
|
|
919
|
+
Dstart = yield $96b4f4dcd8ff333f$var$Dijkstra(Graph, seed);
|
|
920
|
+
// repeat the thing
|
|
921
|
+
currentDistance = -1;
|
|
922
|
+
for (const n of Dstart.keys()){
|
|
923
|
+
const dval = Dstart.get(n);
|
|
924
|
+
if (dval > currentDistance) {
|
|
925
|
+
seed = n;
|
|
926
|
+
currentDistance = dval;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
const returnObj = {
|
|
930
|
+
start: newStart,
|
|
931
|
+
end: seed,
|
|
932
|
+
distance: currentDistance
|
|
933
|
+
};
|
|
934
|
+
return returnObj;
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
// Select a subrgaph
|
|
938
|
+
// you must specify a list of nodes that you passed in
|
|
939
|
+
/**
|
|
940
|
+
*
|
|
941
|
+
* Select a subgraph
|
|
942
|
+
*
|
|
943
|
+
* @param graph - The main graph to select from
|
|
944
|
+
* @param nodeList - The selection of nodes that we want to select from this graph
|
|
945
|
+
* @returns A graph object that contains this subgraph
|
|
946
|
+
*/ function $96b4f4dcd8ff333f$var$SelectSubgraph(graph, nodeList) {
|
|
947
|
+
return $96b4f4dcd8ff333f$var$__awaiter(this, void 0, void 0, function*() {
|
|
948
|
+
const prunedNodes = new Map();
|
|
949
|
+
const prunedEdges = new Map();
|
|
950
|
+
// set the prunded vertices list
|
|
951
|
+
nodeList.forEach((element)=>{
|
|
952
|
+
// get the element from the graph and set that
|
|
953
|
+
// data element in the prunded vertices map
|
|
954
|
+
const ndata = graph.nodes.get(element);
|
|
955
|
+
prunedNodes.set(element, ndata);
|
|
956
|
+
});
|
|
957
|
+
// set the pruned edges list
|
|
958
|
+
let i = 0;
|
|
959
|
+
for (const edge of graph.edges.keys()){
|
|
960
|
+
const edgeData = graph.edges.get(edge);
|
|
961
|
+
if (nodeList.includes(edgeData.start) && nodeList.includes(edgeData.end)) {
|
|
962
|
+
prunedEdges.set(i, edgeData);
|
|
963
|
+
i += 1;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
// construct a new graph that represents the new graph
|
|
967
|
+
const newGraph = yield (0, $9TL8g.default).create(prunedNodes, prunedEdges);
|
|
968
|
+
return newGraph;
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
var // this is where the exports happen
|
|
972
|
+
$96b4f4dcd8ff333f$export$2e2bcd8739ae039 = {
|
|
973
|
+
GraphDiameter: $96b4f4dcd8ff333f$var$GraphDiameter,
|
|
974
|
+
Dijkstra: $96b4f4dcd8ff333f$var$Dijkstra,
|
|
975
|
+
BFSSearch: $96b4f4dcd8ff333f$var$BFSSearch,
|
|
976
|
+
SelectSubgraph: $96b4f4dcd8ff333f$var$SelectSubgraph
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
});
|
|
980
|
+
parcelRequire.register("9TL8g", function(module, exports) {
|
|
981
|
+
|
|
982
|
+
$parcel$export(module.exports, "default", () => $734dcf9f6d72d709$export$2e2bcd8739ae039);
|
|
983
|
+
|
|
984
|
+
var $i8obY = parcelRequire("i8obY");
|
|
985
|
+
var $734dcf9f6d72d709$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
986
|
+
function adopt(value) {
|
|
987
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
988
|
+
resolve(value);
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
992
|
+
function fulfilled(value) {
|
|
993
|
+
try {
|
|
994
|
+
step(generator.next(value));
|
|
995
|
+
} catch (e) {
|
|
996
|
+
reject(e);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function rejected(value) {
|
|
1000
|
+
try {
|
|
1001
|
+
step(generator["throw"](value));
|
|
1002
|
+
} catch (e) {
|
|
1003
|
+
reject(e);
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function step(result) {
|
|
1007
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1008
|
+
}
|
|
1009
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1010
|
+
});
|
|
1011
|
+
};
|
|
1012
|
+
/**
|
|
1013
|
+
* The main graph object - this contrains nodes and edges that get modified with different
|
|
1014
|
+
* Operations etc.
|
|
1015
|
+
*/ class $734dcf9f6d72d709$var$Graph {
|
|
1016
|
+
/**
|
|
1017
|
+
*
|
|
1018
|
+
* Construct a graph object (no initializing)
|
|
1019
|
+
*
|
|
1020
|
+
* @param nodes - Map of all the nodes associated with the graph
|
|
1021
|
+
* @param edges - Map of all the edges assocaiated with the graph
|
|
1022
|
+
*/ constructor(nodes, edges){
|
|
1023
|
+
this.nodes = nodes;
|
|
1024
|
+
this.edges = edges;
|
|
1025
|
+
// execute Internal methods
|
|
1026
|
+
// this.printData();
|
|
1027
|
+
}
|
|
1028
|
+
// test function
|
|
1029
|
+
/**
|
|
1030
|
+
* Prints out a snapshot of data associated with this graph like how many nodes and how many edges
|
|
1031
|
+
*/ printData() {
|
|
1032
|
+
const message = "This is a graph with " + this.nodes.size + " nodes and " + this.edges.size + " edges";
|
|
1033
|
+
console.log(message);
|
|
1034
|
+
}
|
|
1035
|
+
// initialize
|
|
1036
|
+
/**
|
|
1037
|
+
* Initializes the graph and constructs a node adajaceny list list
|
|
1038
|
+
*/ initialize() {
|
|
1039
|
+
return $734dcf9f6d72d709$var$__awaiter(this, void 0, void 0, function*() {
|
|
1040
|
+
yield this.constructAdjacencyList();
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
// new create method
|
|
1044
|
+
/**
|
|
1045
|
+
*
|
|
1046
|
+
* This is the official create method to make a graph based on a set of nodes and edges
|
|
1047
|
+
* It also auto initializes the graph and sets all the adjaceny lists in the memory
|
|
1048
|
+
*
|
|
1049
|
+
* @param nodes - map of nodes
|
|
1050
|
+
* @param edges - map of edges
|
|
1051
|
+
* @returns
|
|
1052
|
+
*/ static create(nodes, edges) {
|
|
1053
|
+
return $734dcf9f6d72d709$var$__awaiter(this, void 0, void 0, function*() {
|
|
1054
|
+
const g = new $734dcf9f6d72d709$var$Graph(nodes, edges);
|
|
1055
|
+
yield g.initialize();
|
|
1056
|
+
return g;
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
// construct the adjacency list represntation
|
|
1060
|
+
/**
|
|
1061
|
+
* Constructs the adjacency associated with the graph
|
|
1062
|
+
*/ constructAdjacencyList() {
|
|
1063
|
+
return $734dcf9f6d72d709$var$__awaiter(this, void 0, void 0, function*() {
|
|
1064
|
+
// I'm constructing a Graph here so some of the stuff doesnt matter
|
|
1065
|
+
this.edges.forEach((edge)=>{
|
|
1066
|
+
// get the start point
|
|
1067
|
+
const start = edge.start;
|
|
1068
|
+
const end = edge.end;
|
|
1069
|
+
// set the node property
|
|
1070
|
+
if (this.nodes.get(start)) {
|
|
1071
|
+
const relevantSNode = this.nodes.get(start);
|
|
1072
|
+
relevantSNode.neighbours.push(end);
|
|
1073
|
+
} else if (this.nodes.get(end)) {
|
|
1074
|
+
const relevantENode = this.nodes.get(end);
|
|
1075
|
+
relevantENode.neighbours.push(start);
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
// then for each node then get the unique neighbours
|
|
1079
|
+
for (const key of this.nodes.keys()){
|
|
1080
|
+
const neighs = this.nodes.get(key).neighbours;
|
|
1081
|
+
const new_neigh = [
|
|
1082
|
+
...new Set(neighs)
|
|
1083
|
+
];
|
|
1084
|
+
const selfIndex = new_neigh.indexOf(key);
|
|
1085
|
+
if (selfIndex > -1) new_neigh.splice(selfIndex, 1); // 2nd parameter means remove one item only
|
|
1086
|
+
this.nodes.get(key).neighbours = new_neigh;
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
// add a node
|
|
1091
|
+
/**
|
|
1092
|
+
* Add a noce to the graph
|
|
1093
|
+
* @param nodeID - the node ID
|
|
1094
|
+
* @param data - data associated with the node
|
|
1095
|
+
*/ add_node(nodeID, data) {
|
|
1096
|
+
this.nodes.set(nodeID, data);
|
|
1097
|
+
}
|
|
1098
|
+
// add an edge
|
|
1099
|
+
/**
|
|
1100
|
+
* Add an edge to the graph
|
|
1101
|
+
* @param start - Starting index of the edge
|
|
1102
|
+
* @param end - The end index of the edge
|
|
1103
|
+
* @param data - data associated with the edge
|
|
1104
|
+
*/ add_edge(start, end, data) {
|
|
1105
|
+
const newEdge = new (0, $i8obY.default)(start, end, data);
|
|
1106
|
+
// this is a new edge that we add to the edges
|
|
1107
|
+
this.edges.set(this.edges.size, newEdge);
|
|
1108
|
+
// also add this to the node neighbours
|
|
1109
|
+
const relevantNode = this.nodes.get(start);
|
|
1110
|
+
relevantNode.neighbours.push(end);
|
|
1111
|
+
}
|
|
1112
|
+
// get an adjacency list reprentation of the graph
|
|
1113
|
+
// this onlu has the indices and not the actual data
|
|
1114
|
+
// associated with the node to speed things up
|
|
1115
|
+
/**
|
|
1116
|
+
*
|
|
1117
|
+
* @returns Get the adjaceny (adjacency lists) associated with the graph
|
|
1118
|
+
*/ get_adjacency() {
|
|
1119
|
+
const SparseMap = new Map();
|
|
1120
|
+
// iterate through the node list
|
|
1121
|
+
for (const key of this.nodes.keys())SparseMap.set(key, this.nodes.get(key).neighbours);
|
|
1122
|
+
return SparseMap;
|
|
1123
|
+
}
|
|
1124
|
+
// set position based on an array of positions
|
|
1125
|
+
// this could be anything (we use kamada kawai )
|
|
1126
|
+
/**
|
|
1127
|
+
* Apply a position map based on some data
|
|
1128
|
+
* @param data - the position map that has to be applied to the graph
|
|
1129
|
+
*/ apply_position_map(data) {
|
|
1130
|
+
for (let n of data.keys())this.nodes.get(n).data = Object.assign(Object.assign({}, this.nodes.get(n).data), {
|
|
1131
|
+
pos: data.get(n)
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
// create new edge pos representation
|
|
1135
|
+
// same approach for applying the key data
|
|
1136
|
+
/**
|
|
1137
|
+
* Apply an line map to a graph
|
|
1138
|
+
* @param data Line data that has to be applied to the graph
|
|
1139
|
+
*/ apply_edge_pos_maps(data) {
|
|
1140
|
+
for (let key of data.keys())this.edges.get(key).data = Object.assign(Object.assign({}, this.edges.get(key).data), {
|
|
1141
|
+
ldata: data.get(key)
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
// get the edge reps
|
|
1145
|
+
// this returns all the edge map readings
|
|
1146
|
+
/**
|
|
1147
|
+
* get the current edge map
|
|
1148
|
+
* @returns The current set of edges associated with the graph
|
|
1149
|
+
*/ get_edge_map() {
|
|
1150
|
+
const lines = new Map();
|
|
1151
|
+
for (const key of this.edges.keys()){
|
|
1152
|
+
const edge = this.edges.get(key).data.ldata;
|
|
1153
|
+
lines.set(key, edge);
|
|
1154
|
+
}
|
|
1155
|
+
return lines;
|
|
1156
|
+
}
|
|
1157
|
+
// graph apply pos and edge map
|
|
1158
|
+
/**
|
|
1159
|
+
* Applies all the maps to the graph
|
|
1160
|
+
* @param layout - Applies an object of maps associated with with a graph is made up of {pmap:(the position map), emap:{the edge map}}
|
|
1161
|
+
*/ apply_drawing_maps(layout) {
|
|
1162
|
+
if (layout.pmap) this.apply_position_map(layout.pmap);
|
|
1163
|
+
if (layout.emap) this.apply_edge_pos_maps(layout.emap);
|
|
1164
|
+
}
|
|
1165
|
+
// get the positon map of the graph
|
|
1166
|
+
/**
|
|
1167
|
+
* Gets the position map and the edge map respectively
|
|
1168
|
+
* @returns the positon map and the edge map as pmap and emap
|
|
1169
|
+
*/ get_map() {
|
|
1170
|
+
return {
|
|
1171
|
+
pmap: this.get_position_map(),
|
|
1172
|
+
emap: this.get_edge_map()
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* get the postion of the nodes in the graph
|
|
1177
|
+
* @returns the position map
|
|
1178
|
+
*/ get_position_map() {
|
|
1179
|
+
const pmap = new Map();
|
|
1180
|
+
for (const node of this.nodes.keys())pmap.set(node, this.nodes.get(node).data.pos);
|
|
1181
|
+
return pmap;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
var // Export the graph Library
|
|
1185
|
+
$734dcf9f6d72d709$export$2e2bcd8739ae039 = $734dcf9f6d72d709$var$Graph;
|
|
1186
|
+
|
|
1187
|
+
});
|
|
1188
|
+
parcelRequire.register("i8obY", function(module, exports) {
|
|
1189
|
+
|
|
1190
|
+
$parcel$export(module.exports, "default", () => $d33bbd65b64ffa49$export$2e2bcd8739ae039);
|
|
1191
|
+
/**
|
|
1192
|
+
* The edge class, edges have a start and end but they can also have data associated with that edge
|
|
1193
|
+
*/ class $d33bbd65b64ffa49$var$Edge {
|
|
1194
|
+
/**
|
|
1195
|
+
*
|
|
1196
|
+
* Construct an edge
|
|
1197
|
+
*
|
|
1198
|
+
* @param start Start index of the edge based on the array of nodes
|
|
1199
|
+
* @param end End index of the edge based on the array of nodes
|
|
1200
|
+
* @param data Data associated, note that ldata is reserved for how to draw the lines associated with the edge
|
|
1201
|
+
*/ constructor(start, end, data){
|
|
1202
|
+
this.start = start;
|
|
1203
|
+
this.end = end;
|
|
1204
|
+
this.data = Object.assign({}, data);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
var $d33bbd65b64ffa49$export$2e2bcd8739ae039 = $d33bbd65b64ffa49$var$Edge;
|
|
1208
|
+
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
parcelRequire.register("eqUI8", function(module, exports) {
|
|
1215
|
+
|
|
1216
|
+
$parcel$export(module.exports, "default", () => $a81f7bf7ba151678$export$2e2bcd8739ae039);
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
var $bWT2q = parcelRequire("bWT2q");
|
|
1223
|
+
|
|
1224
|
+
var $8lQGS = parcelRequire("8lQGS");
|
|
1225
|
+
|
|
1226
|
+
var $cWcXJ = parcelRequire("cWcXJ");
|
|
1227
|
+
var __awaiter = undefined && undefined.__awaiter || function(thisArg11, _arguments11, P11, generator11) {
|
|
1228
|
+
function adopt11(value11) {
|
|
1229
|
+
return value11 instanceof P11 ? value11 : new P11(function(resolve11) {
|
|
1230
|
+
resolve11(value11);
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
return new (P11 || (P11 = Promise))(function(resolve11, reject11) {
|
|
1234
|
+
function fulfilled11(value11) {
|
|
1235
|
+
try {
|
|
1236
|
+
step11(generator11.next(value11));
|
|
1237
|
+
} catch (e11) {
|
|
1238
|
+
reject11(e11);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
function rejected11(value11) {
|
|
1242
|
+
try {
|
|
1243
|
+
step11(generator11["throw"](value11));
|
|
1244
|
+
} catch (e11) {
|
|
1245
|
+
reject11(e11);
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
function step11(result11) {
|
|
1249
|
+
result11.done ? resolve11(result11.value) : adopt11(result11.value).then(fulfilled11, rejected11);
|
|
1250
|
+
}
|
|
1251
|
+
step11((generator11 = generator11.apply(thisArg11, _arguments11 || [])).next());
|
|
1252
|
+
});
|
|
1253
|
+
};
|
|
1254
|
+
// Draw the graph out as a bunch of vertices
|
|
1255
|
+
// As like tiny squares
|
|
1256
|
+
/**
|
|
1257
|
+
*
|
|
1258
|
+
* Draw the veritces of the graph out as a point cloud
|
|
1259
|
+
*
|
|
1260
|
+
* @param Graph - the graph that has to be drawn out
|
|
1261
|
+
* @param bounds - A global scaling parameter defaults to 1 but change to scale up a garph
|
|
1262
|
+
* @param size - The size of all the nodes - either input an array the same length of the number of nodes decribing how big each node is, or a global node value as a number or defaults to 1
|
|
1263
|
+
* @param color - the color of the node defaults to white
|
|
1264
|
+
* @param alpha - the alpha value of the node defaults to 1 (opaque)
|
|
1265
|
+
* @returns a three JS group that contains all the vertices as a point cloud or a three js points object that can be added to the scene
|
|
1266
|
+
*/ function DrawTHREEGraphVertices(Graph11, bounds11 = 1, size11 = 1, color11 = 0xffffff, alpha11 = 1) {
|
|
1267
|
+
const positionAttribute11 = [];
|
|
1268
|
+
// get the corresponding points list
|
|
1269
|
+
const pmap11 = Graph11.get_position_map();
|
|
1270
|
+
// declare the sizes and colors
|
|
1271
|
+
let sizes11;
|
|
1272
|
+
let colors11;
|
|
1273
|
+
if (typeof size11 == "number") sizes11 = Array(Graph11.nodes.size).fill(size11);
|
|
1274
|
+
else sizes11 = size11;
|
|
1275
|
+
colors11 = Array(Graph11.nodes.size).fill(color11);
|
|
1276
|
+
const labels11 = [];
|
|
1277
|
+
const colorVal11 = new $h9nKb$three.Color();
|
|
1278
|
+
colorVal11.setRGB(255, 255, 255); // white as the default
|
|
1279
|
+
// process the data set
|
|
1280
|
+
let i11 = 0;
|
|
1281
|
+
let nodeData11;
|
|
1282
|
+
for (let node11 of Graph11.nodes.keys()){
|
|
1283
|
+
nodeData11 = pmap11.get(node11);
|
|
1284
|
+
positionAttribute11.push(nodeData11.x * bounds11, nodeData11.y * bounds11, nodeData11.z * bounds11);
|
|
1285
|
+
colorVal11.toArray(colors11, i11 * 3);
|
|
1286
|
+
labels11.push(node11);
|
|
1287
|
+
i11 += 1;
|
|
1288
|
+
}
|
|
1289
|
+
const geometry11 = new $h9nKb$three.BufferGeometry();
|
|
1290
|
+
// geometry attribute
|
|
1291
|
+
geometry11.setAttribute("position", new $h9nKb$three.Float32BufferAttribute(positionAttribute11, 3));
|
|
1292
|
+
// color attribute
|
|
1293
|
+
geometry11.setAttribute("customColor", new $h9nKb$three.Float32BufferAttribute(colors11, 3));
|
|
1294
|
+
// size attribute
|
|
1295
|
+
geometry11.setAttribute("size", new $h9nKb$three.Float32BufferAttribute(sizes11, 1));
|
|
1296
|
+
// label attribute
|
|
1297
|
+
geometry11.setAttribute("label", new $h9nKb$three.Int32BufferAttribute(labels11, 1));
|
|
1298
|
+
geometry11.name = "nodes";
|
|
1299
|
+
// example material
|
|
1300
|
+
const PointMaterial11 = new $h9nKb$three.ShaderMaterial({
|
|
1301
|
+
uniforms: {
|
|
1302
|
+
color: {
|
|
1303
|
+
value: new $h9nKb$three.Color(0xffffff)
|
|
1304
|
+
},
|
|
1305
|
+
pointTexture: {
|
|
1306
|
+
value: new $h9nKb$three.TextureLoader().load("./Textures/Square.png")
|
|
1307
|
+
},
|
|
1308
|
+
alphaTest: {
|
|
1309
|
+
value: alpha11
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
vertexShader: (0, $bWT2q.vertexShader),
|
|
1313
|
+
fragmentShader: (0, $8lQGS.fragmentShader)
|
|
1314
|
+
});
|
|
1315
|
+
const vertices11 = new $h9nKb$three.Group();
|
|
1316
|
+
vertices11.add(new $h9nKb$three.Points(geometry11, PointMaterial11));
|
|
1317
|
+
return vertices11;
|
|
1318
|
+
}
|
|
1319
|
+
// then make a thing which draws out all the edges (THICK)
|
|
1320
|
+
/**
|
|
1321
|
+
*
|
|
1322
|
+
* Draws out all the edges (Thick edges of a graph)
|
|
1323
|
+
*
|
|
1324
|
+
* @param Graph - The graph whose edges have to be drawn
|
|
1325
|
+
* @param bounds - the global scale for all the edges to be drawn defaults to 1
|
|
1326
|
+
* @param color - color of the edges defaults to white
|
|
1327
|
+
* @param thickness - thickness of the edges (defaults to 0.2)
|
|
1328
|
+
* @returns a Three Js group of edges that can be added to the scene
|
|
1329
|
+
*/ function DrawTHREEGraphEdgesThick(Graph11, bounds11 = 1, color11 = 0xffffff, thickness11 = 0.2) {
|
|
1330
|
+
// add the interpolation function
|
|
1331
|
+
const lineMap11 = Graph11.get_edge_map();
|
|
1332
|
+
return DrawThickEdgesFromEdgeMap(lineMap11, bounds11, color11, thickness11);
|
|
1333
|
+
}
|
|
1334
|
+
// draw a thing to draw out all the edges from the edge map stuff
|
|
1335
|
+
/**
|
|
1336
|
+
*
|
|
1337
|
+
* Draw thick edges from an edge map
|
|
1338
|
+
*
|
|
1339
|
+
* @param EdgeMap - The edge map associated with the graph
|
|
1340
|
+
* @param bounds - The global scale of the graph - defaults to 1
|
|
1341
|
+
* @param color - The color of the edges - defaults to white
|
|
1342
|
+
* @param thickness - thickness of the edges - defaults to 0.2
|
|
1343
|
+
* @returns
|
|
1344
|
+
*/ function DrawThickEdgesFromEdgeMap(EdgeMap11, bounds11, color11 = 0xffffff, thickness11 = 0.2) {
|
|
1345
|
+
// this is the line thing
|
|
1346
|
+
const mat11 = new (0, $h9nKb$threeexamplesjsmlinesLineMaterial.LineMaterial)({
|
|
1347
|
+
color: color11,
|
|
1348
|
+
linewidth: thickness11,
|
|
1349
|
+
vertexColors: true,
|
|
1350
|
+
//resolution: // to be set by renderer, eventually
|
|
1351
|
+
dashed: false,
|
|
1352
|
+
alphaToCoverage: true
|
|
1353
|
+
});
|
|
1354
|
+
const meshes11 = new $h9nKb$three.Group();
|
|
1355
|
+
for (let lval11 of EdgeMap11.values()){
|
|
1356
|
+
const mcolor11 = new $h9nKb$three.Color();
|
|
1357
|
+
// convert the color that we shall be using
|
|
1358
|
+
mcolor11.setHex(color11);
|
|
1359
|
+
const pnts11 = [];
|
|
1360
|
+
const cols11 = [];
|
|
1361
|
+
lval11.points.forEach((pnt11)=>{
|
|
1362
|
+
pnts11.push(pnt11.x * bounds11 - bounds11 / 2, pnt11.y * bounds11 - bounds11 / 2, pnt11.z * bounds11 - bounds11 / 2);
|
|
1363
|
+
cols11.push(mcolor11.r, mcolor11.g, mcolor11.b);
|
|
1364
|
+
});
|
|
1365
|
+
const geo11 = new (0, $h9nKb$threeexamplesjsmlinesLineGeometry.LineGeometry)();
|
|
1366
|
+
geo11.setPositions(pnts11);
|
|
1367
|
+
geo11.setColors(cols11);
|
|
1368
|
+
const line11 = new (0, $h9nKb$threeexamplesjsmlinesLine2js.Line2)(geo11, mat11);
|
|
1369
|
+
line11.computeLineDistances();
|
|
1370
|
+
line11.scale.set(1, 1, 1);
|
|
1371
|
+
meshes11.add(line11);
|
|
1372
|
+
}
|
|
1373
|
+
return meshes11;
|
|
1374
|
+
}
|
|
1375
|
+
// make a thing that draws out all the lines (Thin)
|
|
1376
|
+
/**
|
|
1377
|
+
*
|
|
1378
|
+
* Draw thin lines for all the edges given a graph
|
|
1379
|
+
*
|
|
1380
|
+
* @param Graph - The graph that has to be drawn
|
|
1381
|
+
* @param bounds - The global scale factor for the the edges - defaults to 1
|
|
1382
|
+
* @param color - color of the lines - defaults to white
|
|
1383
|
+
* @returns
|
|
1384
|
+
*/ function DrawTHREEGraphEdgesThin(Graph11, bounds11 = 1, color11 = 0xffffff) {
|
|
1385
|
+
// first get the edge map positions
|
|
1386
|
+
const emap11 = Graph11.get_edge_map();
|
|
1387
|
+
return DrawThinEdgesFromEdgeMap(emap11, bounds11, color11);
|
|
1388
|
+
}
|
|
1389
|
+
// function to draw edges from edge map
|
|
1390
|
+
/**
|
|
1391
|
+
*
|
|
1392
|
+
* Draw Line map as lines given the edge map assocaited with the graph
|
|
1393
|
+
*
|
|
1394
|
+
* @param LineMap - The edge map that has to be drawn out
|
|
1395
|
+
* @param bounds - Global scale for the edges to be drawn defaults to 1
|
|
1396
|
+
* @param color - Color of the edges defaults to 1
|
|
1397
|
+
* @returns
|
|
1398
|
+
*/ function DrawThinEdgesFromEdgeMap(LineMap11, bounds11 = 1, color11 = 0xffffff) {
|
|
1399
|
+
const material11 = new $h9nKb$three.LineBasicMaterial({
|
|
1400
|
+
color: color11
|
|
1401
|
+
});
|
|
1402
|
+
const lines11 = new $h9nKb$three.Group();
|
|
1403
|
+
let points11;
|
|
1404
|
+
for (const edge11 of LineMap11.values()){
|
|
1405
|
+
points11 = [];
|
|
1406
|
+
// get the edge data
|
|
1407
|
+
const ldata11 = edge11.points;
|
|
1408
|
+
ldata11.forEach((element11)=>{
|
|
1409
|
+
points11.push(new $h9nKb$three.Vector3(element11.x * bounds11, element11.y * bounds11, element11.z * bounds11));
|
|
1410
|
+
});
|
|
1411
|
+
// then make the line thing
|
|
1412
|
+
const geometry11 = new $h9nKb$three.BufferGeometry().setFromPoints(points11);
|
|
1413
|
+
const line11 = new $h9nKb$three.Line(geometry11, material11);
|
|
1414
|
+
lines11.add(line11);
|
|
1415
|
+
}
|
|
1416
|
+
return lines11;
|
|
1417
|
+
}
|
|
1418
|
+
// draw the cube box graph here
|
|
1419
|
+
/**
|
|
1420
|
+
*
|
|
1421
|
+
* Adde boxes where all the boxes are
|
|
1422
|
+
*
|
|
1423
|
+
* @param nodeMap - a map of all the nodes
|
|
1424
|
+
* @param bounds - global scale of the edges to be drawn, defaults to 1
|
|
1425
|
+
* @param color - default color of the edges, defaults to white
|
|
1426
|
+
* @param size - size of the nodes defaults to 10
|
|
1427
|
+
* @returns a group of vertices that contains all of the boxes associated with each one of the vertices
|
|
1428
|
+
*/ function AddBoxBasedImaging(nodeMap11, bounds11 = 1, color11 = 0xffffff, size11 = 10) {
|
|
1429
|
+
// precompute all the sizes
|
|
1430
|
+
let sizes11;
|
|
1431
|
+
if (typeof size11 == "number") sizes11 = Array(nodeMap11.size).fill(size11);
|
|
1432
|
+
else sizes11 = size11;
|
|
1433
|
+
// returns a group
|
|
1434
|
+
const group11 = new $h9nKb$three.Group();
|
|
1435
|
+
const material11 = new $h9nKb$three.MeshBasicMaterial({
|
|
1436
|
+
color: color11
|
|
1437
|
+
});
|
|
1438
|
+
let nodeData11;
|
|
1439
|
+
let geometry11;
|
|
1440
|
+
let nodeMesh11;
|
|
1441
|
+
for(let i11 = 0; i11 < nodeMap11.size; i11++){
|
|
1442
|
+
nodeData11 = nodeMap11.get(i11);
|
|
1443
|
+
geometry11 = new $h9nKb$three.BoxGeometry(sizes11[i11], sizes11[i11], sizes11[i11]);
|
|
1444
|
+
geometry11.name = i11.toString();
|
|
1445
|
+
nodeMesh11 = new $h9nKb$three.Mesh(geometry11, material11);
|
|
1446
|
+
nodeMesh11.position.set(nodeData11.x * bounds11, nodeData11.y * bounds11, nodeData11.z * bounds11);
|
|
1447
|
+
group11.add(nodeMesh11);
|
|
1448
|
+
}
|
|
1449
|
+
return group11;
|
|
1450
|
+
}
|
|
1451
|
+
// Draw BoxBased imaging from a graph
|
|
1452
|
+
/**
|
|
1453
|
+
*
|
|
1454
|
+
* Draw box based verices given a graph
|
|
1455
|
+
*
|
|
1456
|
+
* @param Graph - The graph that needs its vertices drawn
|
|
1457
|
+
* @param bounds - A global scale for the graph, defaults to one
|
|
1458
|
+
* @param color - Default color of the boxes defaults to white
|
|
1459
|
+
* @param size - Default size of the nodes defaults to 10
|
|
1460
|
+
* @returns
|
|
1461
|
+
*/ function DrawTHREEBoxBasedVertices(Graph11, bounds11 = 1, color11 = 0xffffff, size11 = 10) {
|
|
1462
|
+
const pmap11 = Graph11.get_position_map();
|
|
1463
|
+
const Bgroup11 = AddBoxBasedImaging(pmap11, bounds11, color11, size11);
|
|
1464
|
+
return Bgroup11;
|
|
1465
|
+
}
|
|
1466
|
+
// draw cylinders where required
|
|
1467
|
+
/**
|
|
1468
|
+
*
|
|
1469
|
+
* Draw cylinders where all the vertices are based on a node map
|
|
1470
|
+
*
|
|
1471
|
+
* @param nodeMap - the node map assiciate with the graph that has to be drawn out
|
|
1472
|
+
* @param divisonLength - the length of the divisions that are there in each one of the cylinder (this is a circumfurence amount), defaults to 16
|
|
1473
|
+
* @param color - the default color of the cylinder, defaults to white
|
|
1474
|
+
* @param size - the default size of the cylinder, defaults to 10
|
|
1475
|
+
* @returns
|
|
1476
|
+
*/ function AddCylinderBasedImaging(nodeMap11, divisonLength11 = 16, color11 = 0xffffff, size11 = 10) {
|
|
1477
|
+
// precompute all the sizes
|
|
1478
|
+
let sizes11;
|
|
1479
|
+
if (typeof size11 == "number") sizes11.Array(nodeMap11.size).fill(size11);
|
|
1480
|
+
else sizes11 = size11;
|
|
1481
|
+
// returns a group
|
|
1482
|
+
const group11 = new $h9nKb$three.Group();
|
|
1483
|
+
const material11 = new $h9nKb$three.MeshBasicMaterial({
|
|
1484
|
+
color: color11
|
|
1485
|
+
});
|
|
1486
|
+
let radius11, circumfurence11, segments11;
|
|
1487
|
+
let nodeData11;
|
|
1488
|
+
for(let i11 = 0; i11 < nodeMap11.size; i11++){
|
|
1489
|
+
nodeData11 = nodeMap11.get(i11);
|
|
1490
|
+
radius11 = sizes11[i11];
|
|
1491
|
+
circumfurence11 = 2 * radius11 * Math.PI;
|
|
1492
|
+
segments11 = Math.ceil(circumfurence11 / divisonLength11);
|
|
1493
|
+
const geometry11 = new $h9nKb$three.CylinderGeometry(radius11, radius11, 10, segments11);
|
|
1494
|
+
geometry11.name = i11.toString();
|
|
1495
|
+
const nodeMesh11 = new $h9nKb$three.Mesh(geometry11, material11);
|
|
1496
|
+
nodeMesh11.position.set(nodeData11.x, nodeData11.y, nodeData11.z);
|
|
1497
|
+
group11.add(nodeMesh11);
|
|
1498
|
+
}
|
|
1499
|
+
return group11;
|
|
1500
|
+
}
|
|
1501
|
+
// draw the sparse graph as groups
|
|
1502
|
+
// this seperates all the points based on some or the other group
|
|
1503
|
+
/**
|
|
1504
|
+
*
|
|
1505
|
+
* Split up a graph and return an boject containing a bunch of node groups and edge groups based on some parameterS
|
|
1506
|
+
*
|
|
1507
|
+
* @param Graph - the graph that you want to split up
|
|
1508
|
+
* @param propertyName - the property that you want to split them on
|
|
1509
|
+
* @returns - an object that hasa set of node vertices and a set of edge lines based on the splitting factor
|
|
1510
|
+
*/ function AddInModularityBasedPointGroups(Graph, propertyName) {
|
|
1511
|
+
return __awaiter(this, void 0, void 0, function*() {
|
|
1512
|
+
// returns an array of groups
|
|
1513
|
+
const groups = new Map();
|
|
1514
|
+
let ndata;
|
|
1515
|
+
let modularity;
|
|
1516
|
+
for (let node of Graph.nodes.keys()){
|
|
1517
|
+
ndata = Graph.nodes.get(node);
|
|
1518
|
+
modularity = eval(`ndata.data.${propertyName}}`);
|
|
1519
|
+
if (groups.has(modularity)) groups.get(modularity).push(node);
|
|
1520
|
+
else groups.set(modularity, [
|
|
1521
|
+
node
|
|
1522
|
+
]);
|
|
1523
|
+
}
|
|
1524
|
+
// then counstruct a bunch of subraphs
|
|
1525
|
+
const meshGraphVertices = new Map();
|
|
1526
|
+
const meshGraphEdges = new Map();
|
|
1527
|
+
let subgraphGroup;
|
|
1528
|
+
let subgraph;
|
|
1529
|
+
let pointRep;
|
|
1530
|
+
let edges;
|
|
1531
|
+
for (let modularityGroup of groups.keys()){
|
|
1532
|
+
subgraphGroup = groups.get(modularityGroup);
|
|
1533
|
+
// returns an array
|
|
1534
|
+
subgraph = yield (0, $cWcXJ.default).SelectSubgraph(Graph, subgraphGroup);
|
|
1535
|
+
// then make the vertex thing
|
|
1536
|
+
pointRep = DrawTHREEGraphVertices(subgraph, 1);
|
|
1537
|
+
meshGraphVertices.set(modularityGroup, pointRep);
|
|
1538
|
+
// make the edges
|
|
1539
|
+
edges = DrawSimplifiedEdges(subgraph, 0.03);
|
|
1540
|
+
meshGraphEdges.set(modularityGroup, edges);
|
|
1541
|
+
}
|
|
1542
|
+
const ROBJ = {
|
|
1543
|
+
nodeGroups: meshGraphVertices,
|
|
1544
|
+
EdgeGroups: meshGraphEdges
|
|
1545
|
+
};
|
|
1546
|
+
return ROBJ;
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
/**
|
|
1550
|
+
*
|
|
1551
|
+
* 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)
|
|
1552
|
+
*
|
|
1553
|
+
* @param Graph - The graph that has to be drawn out
|
|
1554
|
+
* @param amount - The fraction of edges to be drawn
|
|
1555
|
+
* @param color - color of these edges - defaults to 0.1
|
|
1556
|
+
* @returns - a group of simple lines based on all the edges supplied to it
|
|
1557
|
+
*/ function DrawSimplifiedEdges(Graph11, amount11, color11 = 0xffffff) {
|
|
1558
|
+
const lineGroup11 = new $h9nKb$three.Group();
|
|
1559
|
+
const material11 = new $h9nKb$three.LineBasicMaterial({
|
|
1560
|
+
color: color11
|
|
1561
|
+
});
|
|
1562
|
+
let start11;
|
|
1563
|
+
let end11;
|
|
1564
|
+
let points11;
|
|
1565
|
+
for (let edge11 of Graph11.edges.values())if (Math.random() <= amount11) {
|
|
1566
|
+
start11 = Graph11.nodes.get(edge11.start).data.pos;
|
|
1567
|
+
end11 = Graph11.nodes.get(edge11.end).data.pos;
|
|
1568
|
+
points11 = [];
|
|
1569
|
+
points11.push(new $h9nKb$three.Vector3(start11.x, start11.y, start11.z));
|
|
1570
|
+
points11.push(new $h9nKb$three.Vector3(end11.x, end11.y, end11.z));
|
|
1571
|
+
const geometry11 = new $h9nKb$three.BufferGeometry().setFromPoints(points11);
|
|
1572
|
+
const line11 = new $h9nKb$three.Line(geometry11, material11);
|
|
1573
|
+
lineGroup11.add(line11);
|
|
1574
|
+
}
|
|
1575
|
+
return lineGroup11;
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
*
|
|
1579
|
+
* Change all the vertex colors based on some array of properties
|
|
1580
|
+
*
|
|
1581
|
+
* @param vertices - ThreeJS Points object, be sure to pass in the points object and not the group that the points belong too
|
|
1582
|
+
* @param indexArray - The array of the indices of all the nodes whose values that have to be changed
|
|
1583
|
+
* @param color - The color that they have to be changed too
|
|
1584
|
+
*/ function ChangeTheVertexColours(vertices11, indexArray11, color11) {
|
|
1585
|
+
let Attrib11 = vertices11.geometry.attributes;
|
|
1586
|
+
let k11 = 0;
|
|
1587
|
+
const col11 = new $h9nKb$three.Color(color11);
|
|
1588
|
+
indexArray11.forEach((node11)=>{
|
|
1589
|
+
k11 = node11 * 3; // @ts-ignore
|
|
1590
|
+
Attrib11.customColor.array[k11] = col11.r; // @ts-ignore
|
|
1591
|
+
Attrib11.customColor.array[k11 + 1] = col11.g; // @ts-ignore
|
|
1592
|
+
Attrib11.customColor.array[k11 + 2] = col11.b;
|
|
1593
|
+
});
|
|
1594
|
+
Attrib11.customColor.needsUpdate = true;
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
*
|
|
1598
|
+
* This resets all the colors to white
|
|
1599
|
+
*
|
|
1600
|
+
* @param vertices - ThreeJS Points object, be sure to pass in the points object and not the group that the points belong too
|
|
1601
|
+
*/ function ResetVertexColors(vertices11) {
|
|
1602
|
+
let Attrib11 = vertices11.geometry.attributes;
|
|
1603
|
+
let k11 = 0;
|
|
1604
|
+
for(let i11 = 0; i11 < Attrib11.customColor.count; i11++){
|
|
1605
|
+
k11 = i11 * 3; // @ts-ignore
|
|
1606
|
+
Attrib11.customColor.array[k11] = 255; // @ts-ignore
|
|
1607
|
+
Attrib11.customColor.array[k11 + 1] = 255; // @ts-ignore
|
|
1608
|
+
Attrib11.customColor.array[k11 + 2] = 255;
|
|
1609
|
+
}
|
|
1610
|
+
Attrib11.customColor.needsUpdate = true;
|
|
1611
|
+
}
|
|
1612
|
+
var $a81f7bf7ba151678$export$2e2bcd8739ae039 = {
|
|
1613
|
+
DrawTHREEGraphVertices: DrawTHREEGraphVertices,
|
|
1614
|
+
DrawTHREEGraphEdgesThick: DrawTHREEGraphEdgesThick,
|
|
1615
|
+
DrawTHREEGraphEdgesThin: DrawTHREEGraphEdgesThin,
|
|
1616
|
+
AddBoxBasedImaging: AddBoxBasedImaging,
|
|
1617
|
+
AddInModularityBasedPointGroups: AddInModularityBasedPointGroups,
|
|
1618
|
+
DrawThinEdgesFromEdgeMap: DrawThinEdgesFromEdgeMap,
|
|
1619
|
+
DrawThickEdgesFromEdgeMap: DrawThickEdgesFromEdgeMap,
|
|
1620
|
+
AddCylinderBasedImaging: AddCylinderBasedImaging,
|
|
1621
|
+
DrawSimplifiedEdges: DrawSimplifiedEdges,
|
|
1622
|
+
ChangeTheVertexColours: ChangeTheVertexColours,
|
|
1623
|
+
ResetVertexColors: ResetVertexColors,
|
|
1624
|
+
DrawTHREEBoxBasedVertices: DrawTHREEBoxBasedVertices
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1627
|
+
});
|
|
1628
|
+
parcelRequire.register("bWT2q", function(module, exports) {
|
|
1629
|
+
|
|
1630
|
+
$parcel$export(module.exports, "vertexShader", () => $8b2fcdeb0edc9ee9$export$84657c60382b0f83);
|
|
1631
|
+
const $8b2fcdeb0edc9ee9$export$84657c60382b0f83 = `
|
|
1632
|
+
attribute float size;
|
|
1633
|
+
attribute vec3 customColor;
|
|
1634
|
+
|
|
1635
|
+
varying vec3 vColor;
|
|
1636
|
+
|
|
1637
|
+
void main() {
|
|
1638
|
+
vColor = customColor;
|
|
1639
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1640
|
+
gl_PointSize = size * ( 300.0 / -mvPosition.z );
|
|
1641
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1642
|
+
}
|
|
1643
|
+
`;
|
|
1644
|
+
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
parcelRequire.register("8lQGS", function(module, exports) {
|
|
1648
|
+
|
|
1649
|
+
$parcel$export(module.exports, "fragmentShader", () => $61492820ee257def$export$4391ef72fa03c19);
|
|
1650
|
+
const $61492820ee257def$export$4391ef72fa03c19 = `
|
|
1651
|
+
uniform vec3 color;
|
|
1652
|
+
uniform sampler2D pointTexture;
|
|
1653
|
+
uniform float alphaTest;
|
|
1654
|
+
|
|
1655
|
+
varying vec3 vColor;
|
|
1656
|
+
|
|
1657
|
+
void main() {
|
|
1658
|
+
gl_FragColor = vec4( color * vColor, 1.0 );
|
|
1659
|
+
gl_FragColor = gl_FragColor * texture2D( pointTexture, gl_PointCoord );
|
|
1660
|
+
if ( gl_FragColor.a < alphaTest ) discard;
|
|
1661
|
+
}
|
|
1662
|
+
`;
|
|
1663
|
+
|
|
1664
|
+
});
|
|
1665
|
+
|
|
1666
|
+
|
|
1667
|
+
|
|
1668
|
+
$parcel$export(module.exports, "Graph", () => (parcelRequire("9TL8g")).default);
|
|
1669
|
+
$parcel$export(module.exports, "GraphMethods", () => (parcelRequire("cWcXJ")).default);
|
|
1670
|
+
$parcel$export(module.exports, "SampleData", () => $c57cf0c4853fb804$exports.default);
|
|
1671
|
+
$parcel$export(module.exports, "Constructors", () => $942e91a547b4130c$exports.default);
|
|
1672
|
+
$parcel$export(module.exports, "Drawing", () => (parcelRequire("jYcHE")).default);
|
|
1673
|
+
$parcel$export(module.exports, "Geometry", () => (parcelRequire("fd3jp")).default);
|
|
1674
|
+
$parcel$export(module.exports, "Utilities", () => (parcelRequire("6Xdhg")).default);
|
|
1675
|
+
$parcel$export(module.exports, "ThreeWrapper", () => (parcelRequire("eqUI8")).default);
|
|
1676
|
+
$parcel$export(module.exports, "GraphDrawer", () => $6abda68f7f78a6fb$exports.default);
|
|
1677
|
+
$parcel$export(module.exports, "Models", () => $7308258d93363088$exports.default);
|
|
1678
|
+
|
|
1679
|
+
var $9TL8g = parcelRequire("9TL8g");
|
|
1680
|
+
|
|
1681
|
+
var $cWcXJ = parcelRequire("cWcXJ");
|
|
1682
|
+
var $c57cf0c4853fb804$exports = {};
|
|
1683
|
+
|
|
1684
|
+
$parcel$export($c57cf0c4853fb804$exports, "default", () => $c57cf0c4853fb804$export$2e2bcd8739ae039);
|
|
1685
|
+
const $a79fcfb00e2fad28$export$b6cdfb6bd6195507 = {
|
|
1686
|
+
nodes: [
|
|
1687
|
+
0,
|
|
1688
|
+
1,
|
|
1689
|
+
2,
|
|
1690
|
+
3,
|
|
1691
|
+
4,
|
|
1692
|
+
5,
|
|
1693
|
+
6,
|
|
1694
|
+
7,
|
|
1695
|
+
8,
|
|
1696
|
+
9,
|
|
1697
|
+
10,
|
|
1698
|
+
11,
|
|
1699
|
+
12,
|
|
1700
|
+
13,
|
|
1701
|
+
14,
|
|
1702
|
+
15,
|
|
1703
|
+
16,
|
|
1704
|
+
17,
|
|
1705
|
+
18,
|
|
1706
|
+
19,
|
|
1707
|
+
20,
|
|
1708
|
+
21,
|
|
1709
|
+
22,
|
|
1710
|
+
23,
|
|
1711
|
+
24,
|
|
1712
|
+
25,
|
|
1713
|
+
26,
|
|
1714
|
+
27,
|
|
1715
|
+
28,
|
|
1716
|
+
29,
|
|
1717
|
+
30,
|
|
1718
|
+
31,
|
|
1719
|
+
32,
|
|
1720
|
+
33
|
|
1721
|
+
],
|
|
1722
|
+
edges: [
|
|
1723
|
+
[
|
|
1724
|
+
0,
|
|
1725
|
+
1
|
|
1726
|
+
],
|
|
1727
|
+
[
|
|
1728
|
+
0,
|
|
1729
|
+
2
|
|
1730
|
+
],
|
|
1731
|
+
[
|
|
1732
|
+
0,
|
|
1733
|
+
3
|
|
1734
|
+
],
|
|
1735
|
+
[
|
|
1736
|
+
0,
|
|
1737
|
+
4
|
|
1738
|
+
],
|
|
1739
|
+
[
|
|
1740
|
+
0,
|
|
1741
|
+
5
|
|
1742
|
+
],
|
|
1743
|
+
[
|
|
1744
|
+
0,
|
|
1745
|
+
6
|
|
1746
|
+
],
|
|
1747
|
+
[
|
|
1748
|
+
0,
|
|
1749
|
+
7
|
|
1750
|
+
],
|
|
1751
|
+
[
|
|
1752
|
+
0,
|
|
1753
|
+
8
|
|
1754
|
+
],
|
|
1755
|
+
[
|
|
1756
|
+
0,
|
|
1757
|
+
10
|
|
1758
|
+
],
|
|
1759
|
+
[
|
|
1760
|
+
0,
|
|
1761
|
+
11
|
|
1762
|
+
],
|
|
1763
|
+
[
|
|
1764
|
+
0,
|
|
1765
|
+
12
|
|
1766
|
+
],
|
|
1767
|
+
[
|
|
1768
|
+
0,
|
|
1769
|
+
13
|
|
1770
|
+
],
|
|
1771
|
+
[
|
|
1772
|
+
0,
|
|
1773
|
+
17
|
|
1774
|
+
],
|
|
1775
|
+
[
|
|
1776
|
+
0,
|
|
1777
|
+
19
|
|
1778
|
+
],
|
|
1779
|
+
[
|
|
1780
|
+
0,
|
|
1781
|
+
21
|
|
1782
|
+
],
|
|
1783
|
+
[
|
|
1784
|
+
0,
|
|
1785
|
+
31
|
|
1786
|
+
],
|
|
1787
|
+
[
|
|
1788
|
+
1,
|
|
1789
|
+
2
|
|
1790
|
+
],
|
|
1791
|
+
[
|
|
1792
|
+
1,
|
|
1793
|
+
3
|
|
1794
|
+
],
|
|
1795
|
+
[
|
|
1796
|
+
1,
|
|
1797
|
+
7
|
|
1798
|
+
],
|
|
1799
|
+
[
|
|
1800
|
+
1,
|
|
1801
|
+
13
|
|
1802
|
+
],
|
|
1803
|
+
[
|
|
1804
|
+
1,
|
|
1805
|
+
17
|
|
1806
|
+
],
|
|
1807
|
+
[
|
|
1808
|
+
1,
|
|
1809
|
+
19
|
|
1810
|
+
],
|
|
1811
|
+
[
|
|
1812
|
+
1,
|
|
1813
|
+
21
|
|
1814
|
+
],
|
|
1815
|
+
[
|
|
1816
|
+
1,
|
|
1817
|
+
30
|
|
1818
|
+
],
|
|
1819
|
+
[
|
|
1820
|
+
2,
|
|
1821
|
+
3
|
|
1822
|
+
],
|
|
1823
|
+
[
|
|
1824
|
+
2,
|
|
1825
|
+
7
|
|
1826
|
+
],
|
|
1827
|
+
[
|
|
1828
|
+
2,
|
|
1829
|
+
8
|
|
1830
|
+
],
|
|
1831
|
+
[
|
|
1832
|
+
2,
|
|
1833
|
+
9
|
|
1834
|
+
],
|
|
1835
|
+
[
|
|
1836
|
+
2,
|
|
1837
|
+
13
|
|
1838
|
+
],
|
|
1839
|
+
[
|
|
1840
|
+
2,
|
|
1841
|
+
27
|
|
1842
|
+
],
|
|
1843
|
+
[
|
|
1844
|
+
2,
|
|
1845
|
+
28
|
|
1846
|
+
],
|
|
1847
|
+
[
|
|
1848
|
+
2,
|
|
1849
|
+
32
|
|
1850
|
+
],
|
|
1851
|
+
[
|
|
1852
|
+
3,
|
|
1853
|
+
7
|
|
1854
|
+
],
|
|
1855
|
+
[
|
|
1856
|
+
3,
|
|
1857
|
+
12
|
|
1858
|
+
],
|
|
1859
|
+
[
|
|
1860
|
+
3,
|
|
1861
|
+
13
|
|
1862
|
+
],
|
|
1863
|
+
[
|
|
1864
|
+
4,
|
|
1865
|
+
6
|
|
1866
|
+
],
|
|
1867
|
+
[
|
|
1868
|
+
4,
|
|
1869
|
+
10
|
|
1870
|
+
],
|
|
1871
|
+
[
|
|
1872
|
+
5,
|
|
1873
|
+
6
|
|
1874
|
+
],
|
|
1875
|
+
[
|
|
1876
|
+
5,
|
|
1877
|
+
10
|
|
1878
|
+
],
|
|
1879
|
+
[
|
|
1880
|
+
5,
|
|
1881
|
+
16
|
|
1882
|
+
],
|
|
1883
|
+
[
|
|
1884
|
+
6,
|
|
1885
|
+
16
|
|
1886
|
+
],
|
|
1887
|
+
[
|
|
1888
|
+
8,
|
|
1889
|
+
30
|
|
1890
|
+
],
|
|
1891
|
+
[
|
|
1892
|
+
8,
|
|
1893
|
+
32
|
|
1894
|
+
],
|
|
1895
|
+
[
|
|
1896
|
+
8,
|
|
1897
|
+
33
|
|
1898
|
+
],
|
|
1899
|
+
[
|
|
1900
|
+
9,
|
|
1901
|
+
33
|
|
1902
|
+
],
|
|
1903
|
+
[
|
|
1904
|
+
13,
|
|
1905
|
+
33
|
|
1906
|
+
],
|
|
1907
|
+
[
|
|
1908
|
+
14,
|
|
1909
|
+
32
|
|
1910
|
+
],
|
|
1911
|
+
[
|
|
1912
|
+
14,
|
|
1913
|
+
33
|
|
1914
|
+
],
|
|
1915
|
+
[
|
|
1916
|
+
15,
|
|
1917
|
+
32
|
|
1918
|
+
],
|
|
1919
|
+
[
|
|
1920
|
+
15,
|
|
1921
|
+
33
|
|
1922
|
+
],
|
|
1923
|
+
[
|
|
1924
|
+
18,
|
|
1925
|
+
32
|
|
1926
|
+
],
|
|
1927
|
+
[
|
|
1928
|
+
18,
|
|
1929
|
+
33
|
|
1930
|
+
],
|
|
1931
|
+
[
|
|
1932
|
+
19,
|
|
1933
|
+
33
|
|
1934
|
+
],
|
|
1935
|
+
[
|
|
1936
|
+
20,
|
|
1937
|
+
32
|
|
1938
|
+
],
|
|
1939
|
+
[
|
|
1940
|
+
20,
|
|
1941
|
+
33
|
|
1942
|
+
],
|
|
1943
|
+
[
|
|
1944
|
+
22,
|
|
1945
|
+
32
|
|
1946
|
+
],
|
|
1947
|
+
[
|
|
1948
|
+
22,
|
|
1949
|
+
33
|
|
1950
|
+
],
|
|
1951
|
+
[
|
|
1952
|
+
23,
|
|
1953
|
+
25
|
|
1954
|
+
],
|
|
1955
|
+
[
|
|
1956
|
+
23,
|
|
1957
|
+
27
|
|
1958
|
+
],
|
|
1959
|
+
[
|
|
1960
|
+
23,
|
|
1961
|
+
29
|
|
1962
|
+
],
|
|
1963
|
+
[
|
|
1964
|
+
23,
|
|
1965
|
+
32
|
|
1966
|
+
],
|
|
1967
|
+
[
|
|
1968
|
+
23,
|
|
1969
|
+
33
|
|
1970
|
+
],
|
|
1971
|
+
[
|
|
1972
|
+
24,
|
|
1973
|
+
25
|
|
1974
|
+
],
|
|
1975
|
+
[
|
|
1976
|
+
24,
|
|
1977
|
+
27
|
|
1978
|
+
],
|
|
1979
|
+
[
|
|
1980
|
+
24,
|
|
1981
|
+
31
|
|
1982
|
+
],
|
|
1983
|
+
[
|
|
1984
|
+
25,
|
|
1985
|
+
31
|
|
1986
|
+
],
|
|
1987
|
+
[
|
|
1988
|
+
26,
|
|
1989
|
+
29
|
|
1990
|
+
],
|
|
1991
|
+
[
|
|
1992
|
+
26,
|
|
1993
|
+
33
|
|
1994
|
+
],
|
|
1995
|
+
[
|
|
1996
|
+
27,
|
|
1997
|
+
33
|
|
1998
|
+
],
|
|
1999
|
+
[
|
|
2000
|
+
28,
|
|
2001
|
+
31
|
|
2002
|
+
],
|
|
2003
|
+
[
|
|
2004
|
+
28,
|
|
2005
|
+
33
|
|
2006
|
+
],
|
|
2007
|
+
[
|
|
2008
|
+
29,
|
|
2009
|
+
32
|
|
2010
|
+
],
|
|
2011
|
+
[
|
|
2012
|
+
29,
|
|
2013
|
+
33
|
|
2014
|
+
],
|
|
2015
|
+
[
|
|
2016
|
+
30,
|
|
2017
|
+
32
|
|
2018
|
+
],
|
|
2019
|
+
[
|
|
2020
|
+
30,
|
|
2021
|
+
33
|
|
2022
|
+
],
|
|
2023
|
+
[
|
|
2024
|
+
31,
|
|
2025
|
+
32
|
|
2026
|
+
],
|
|
2027
|
+
[
|
|
2028
|
+
31,
|
|
2029
|
+
33
|
|
2030
|
+
],
|
|
2031
|
+
[
|
|
2032
|
+
32,
|
|
2033
|
+
33
|
|
2034
|
+
]
|
|
2035
|
+
]
|
|
2036
|
+
};
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
const $16cc01d9c2706f25$export$aa88f89bcd11f8a9 = {
|
|
2040
|
+
nodes: [
|
|
2041
|
+
{
|
|
2042
|
+
id: 0,
|
|
2043
|
+
px: 0.09083423378081436,
|
|
2044
|
+
py: 1.164162667707135,
|
|
2045
|
+
member: 0
|
|
2046
|
+
},
|
|
2047
|
+
{
|
|
2048
|
+
id: 1,
|
|
2049
|
+
px: -0.5395391223661004,
|
|
2050
|
+
py: 0.8787097882002372,
|
|
2051
|
+
member: 0
|
|
2052
|
+
},
|
|
2053
|
+
{
|
|
2054
|
+
id: 2,
|
|
2055
|
+
px: 0.25483951690897244,
|
|
2056
|
+
py: -0.011894166387290125,
|
|
2057
|
+
member: 0
|
|
2058
|
+
},
|
|
2059
|
+
{
|
|
2060
|
+
id: 3,
|
|
2061
|
+
px: 0.5292273814873625,
|
|
2062
|
+
py: 0.8137715604013231,
|
|
2063
|
+
member: 0
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
id: 4,
|
|
2067
|
+
px: 0.6759740200024705,
|
|
2068
|
+
py: 2.010590015934319,
|
|
2069
|
+
member: 3
|
|
2070
|
+
},
|
|
2071
|
+
{
|
|
2072
|
+
id: 5,
|
|
2073
|
+
px: 0.6648725961138767,
|
|
2074
|
+
py: 2.3765595730406712,
|
|
2075
|
+
member: 3
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
id: 6,
|
|
2079
|
+
px: -0.015476857282255526,
|
|
2080
|
+
py: 2.421851366492045,
|
|
2081
|
+
member: 3
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
id: 7,
|
|
2085
|
+
px: 0.9923183157183725,
|
|
2086
|
+
py: 0.7358251458599251,
|
|
2087
|
+
member: 0
|
|
2088
|
+
},
|
|
2089
|
+
{
|
|
2090
|
+
id: 8,
|
|
2091
|
+
px: -0.6148021363450372,
|
|
2092
|
+
py: -0.03465499210385469,
|
|
2093
|
+
member: 1
|
|
2094
|
+
},
|
|
2095
|
+
{
|
|
2096
|
+
id: 9,
|
|
2097
|
+
px: 0.24714516178546894,
|
|
2098
|
+
py: -1.012380550604274,
|
|
2099
|
+
member: 0
|
|
2100
|
+
},
|
|
2101
|
+
{
|
|
2102
|
+
id: 10,
|
|
2103
|
+
px: 1.3293288757439443,
|
|
2104
|
+
py: 1.8641805845025743,
|
|
2105
|
+
member: 3
|
|
2106
|
+
},
|
|
2107
|
+
{
|
|
2108
|
+
id: 11,
|
|
2109
|
+
px: -0.6571791278403557,
|
|
2110
|
+
py: 2.2163816367270526,
|
|
2111
|
+
member: 0
|
|
2112
|
+
},
|
|
2113
|
+
{
|
|
2114
|
+
id: 12,
|
|
2115
|
+
px: 1.5181044222926994,
|
|
2116
|
+
py: 1.3282665066698078,
|
|
2117
|
+
member: 0
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
id: 13,
|
|
2121
|
+
px: -0.2979203330003603,
|
|
2122
|
+
py: 0.18438685313887027,
|
|
2123
|
+
member: 0
|
|
2124
|
+
},
|
|
2125
|
+
{
|
|
2126
|
+
id: 14,
|
|
2127
|
+
px: -1.7502345807734376,
|
|
2128
|
+
py: -1.0935551887354324,
|
|
2129
|
+
member: 1
|
|
2130
|
+
},
|
|
2131
|
+
{
|
|
2132
|
+
id: 15,
|
|
2133
|
+
px: -1.630224787934251,
|
|
2134
|
+
py: -1.5015879850995024,
|
|
2135
|
+
member: 1
|
|
2136
|
+
},
|
|
2137
|
+
{
|
|
2138
|
+
id: 16,
|
|
2139
|
+
px: 0.5585243394360673,
|
|
2140
|
+
py: 3.5,
|
|
2141
|
+
member: 3
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
id: 17,
|
|
2145
|
+
px: -0.9776584881745712,
|
|
2146
|
+
py: 1.799718659872538,
|
|
2147
|
+
member: 0
|
|
2148
|
+
},
|
|
2149
|
+
{
|
|
2150
|
+
id: 18,
|
|
2151
|
+
px: -1.385649185975611,
|
|
2152
|
+
py: -1.870388302312794,
|
|
2153
|
+
member: 1
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
id: 19,
|
|
2157
|
+
px: -0.9638464461397331,
|
|
2158
|
+
py: 0.24226946279518707,
|
|
2159
|
+
member: 0
|
|
2160
|
+
},
|
|
2161
|
+
{
|
|
2162
|
+
id: 20,
|
|
2163
|
+
px: -1.0268125129631975,
|
|
2164
|
+
py: -2.1543990524894148,
|
|
2165
|
+
member: 1
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
id: 21,
|
|
2169
|
+
px: -1.3061680833745626,
|
|
2170
|
+
py: 1.527228276383933,
|
|
2171
|
+
member: 0
|
|
2172
|
+
},
|
|
2173
|
+
{
|
|
2174
|
+
id: 22,
|
|
2175
|
+
px: -0.5552461198316926,
|
|
2176
|
+
py: -2.2498070887997685,
|
|
2177
|
+
member: 1
|
|
2178
|
+
},
|
|
2179
|
+
{
|
|
2180
|
+
id: 23,
|
|
2181
|
+
px: 0.8262268914348979,
|
|
2182
|
+
py: -1.804253160744954,
|
|
2183
|
+
member: 2
|
|
2184
|
+
},
|
|
2185
|
+
{
|
|
2186
|
+
id: 24,
|
|
2187
|
+
px: 1.9952840970427212,
|
|
2188
|
+
py: -1.0382885070400036,
|
|
2189
|
+
member: 2
|
|
2190
|
+
},
|
|
2191
|
+
{
|
|
2192
|
+
id: 25,
|
|
2193
|
+
px: 1.9207660053211613,
|
|
2194
|
+
py: -0.5823795272244723,
|
|
2195
|
+
member: 2
|
|
2196
|
+
},
|
|
2197
|
+
{
|
|
2198
|
+
id: 26,
|
|
2199
|
+
px: -0.1664715343791652,
|
|
2200
|
+
py: -2.6527209168204373,
|
|
2201
|
+
member: 1
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
id: 27,
|
|
2205
|
+
px: 0.9961959436268844,
|
|
2206
|
+
py: -1.0143754028553023,
|
|
2207
|
+
member: 2
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
id: 28,
|
|
2211
|
+
px: 0.6488880579857091,
|
|
2212
|
+
py: -1.024671500275854,
|
|
2213
|
+
member: 2
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
id: 29,
|
|
2217
|
+
px: 0.2398196340697841,
|
|
2218
|
+
py: -2.171491081802323,
|
|
2219
|
+
member: 1
|
|
2220
|
+
},
|
|
2221
|
+
{
|
|
2222
|
+
id: 30,
|
|
2223
|
+
px: -1.3348117368940753,
|
|
2224
|
+
py: -0.31290471156377053,
|
|
2225
|
+
member: 1
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
id: 31,
|
|
2229
|
+
px: 0.6901260074375327,
|
|
2230
|
+
py: -0.2526601933356052,
|
|
2231
|
+
member: 2
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
id: 32,
|
|
2235
|
+
px: -0.6030949145287146,
|
|
2236
|
+
py: -1.0927507849665647,
|
|
2237
|
+
member: 1
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
id: 33,
|
|
2241
|
+
px: -0.3533395323856202,
|
|
2242
|
+
py: -1.1887389845640028,
|
|
2243
|
+
member: 1
|
|
2244
|
+
}
|
|
2245
|
+
],
|
|
2246
|
+
edges: [
|
|
2247
|
+
[
|
|
2248
|
+
0,
|
|
2249
|
+
1
|
|
2250
|
+
],
|
|
2251
|
+
[
|
|
2252
|
+
0,
|
|
2253
|
+
2
|
|
2254
|
+
],
|
|
2255
|
+
[
|
|
2256
|
+
0,
|
|
2257
|
+
3
|
|
2258
|
+
],
|
|
2259
|
+
[
|
|
2260
|
+
0,
|
|
2261
|
+
4
|
|
2262
|
+
],
|
|
2263
|
+
[
|
|
2264
|
+
0,
|
|
2265
|
+
5
|
|
2266
|
+
],
|
|
2267
|
+
[
|
|
2268
|
+
0,
|
|
2269
|
+
6
|
|
2270
|
+
],
|
|
2271
|
+
[
|
|
2272
|
+
0,
|
|
2273
|
+
7
|
|
2274
|
+
],
|
|
2275
|
+
[
|
|
2276
|
+
0,
|
|
2277
|
+
8
|
|
2278
|
+
],
|
|
2279
|
+
[
|
|
2280
|
+
0,
|
|
2281
|
+
10
|
|
2282
|
+
],
|
|
2283
|
+
[
|
|
2284
|
+
0,
|
|
2285
|
+
11
|
|
2286
|
+
],
|
|
2287
|
+
[
|
|
2288
|
+
0,
|
|
2289
|
+
12
|
|
2290
|
+
],
|
|
2291
|
+
[
|
|
2292
|
+
0,
|
|
2293
|
+
13
|
|
2294
|
+
],
|
|
2295
|
+
[
|
|
2296
|
+
0,
|
|
2297
|
+
17
|
|
2298
|
+
],
|
|
2299
|
+
[
|
|
2300
|
+
0,
|
|
2301
|
+
19
|
|
2302
|
+
],
|
|
2303
|
+
[
|
|
2304
|
+
0,
|
|
2305
|
+
21
|
|
2306
|
+
],
|
|
2307
|
+
[
|
|
2308
|
+
0,
|
|
2309
|
+
31
|
|
2310
|
+
],
|
|
2311
|
+
[
|
|
2312
|
+
1,
|
|
2313
|
+
2
|
|
2314
|
+
],
|
|
2315
|
+
[
|
|
2316
|
+
1,
|
|
2317
|
+
3
|
|
2318
|
+
],
|
|
2319
|
+
[
|
|
2320
|
+
1,
|
|
2321
|
+
7
|
|
2322
|
+
],
|
|
2323
|
+
[
|
|
2324
|
+
1,
|
|
2325
|
+
13
|
|
2326
|
+
],
|
|
2327
|
+
[
|
|
2328
|
+
1,
|
|
2329
|
+
17
|
|
2330
|
+
],
|
|
2331
|
+
[
|
|
2332
|
+
1,
|
|
2333
|
+
19
|
|
2334
|
+
],
|
|
2335
|
+
[
|
|
2336
|
+
1,
|
|
2337
|
+
21
|
|
2338
|
+
],
|
|
2339
|
+
[
|
|
2340
|
+
1,
|
|
2341
|
+
30
|
|
2342
|
+
],
|
|
2343
|
+
[
|
|
2344
|
+
2,
|
|
2345
|
+
3
|
|
2346
|
+
],
|
|
2347
|
+
[
|
|
2348
|
+
2,
|
|
2349
|
+
7
|
|
2350
|
+
],
|
|
2351
|
+
[
|
|
2352
|
+
2,
|
|
2353
|
+
8
|
|
2354
|
+
],
|
|
2355
|
+
[
|
|
2356
|
+
2,
|
|
2357
|
+
9
|
|
2358
|
+
],
|
|
2359
|
+
[
|
|
2360
|
+
2,
|
|
2361
|
+
13
|
|
2362
|
+
],
|
|
2363
|
+
[
|
|
2364
|
+
2,
|
|
2365
|
+
27
|
|
2366
|
+
],
|
|
2367
|
+
[
|
|
2368
|
+
2,
|
|
2369
|
+
28
|
|
2370
|
+
],
|
|
2371
|
+
[
|
|
2372
|
+
2,
|
|
2373
|
+
32
|
|
2374
|
+
],
|
|
2375
|
+
[
|
|
2376
|
+
3,
|
|
2377
|
+
7
|
|
2378
|
+
],
|
|
2379
|
+
[
|
|
2380
|
+
3,
|
|
2381
|
+
12
|
|
2382
|
+
],
|
|
2383
|
+
[
|
|
2384
|
+
3,
|
|
2385
|
+
13
|
|
2386
|
+
],
|
|
2387
|
+
[
|
|
2388
|
+
4,
|
|
2389
|
+
6
|
|
2390
|
+
],
|
|
2391
|
+
[
|
|
2392
|
+
4,
|
|
2393
|
+
10
|
|
2394
|
+
],
|
|
2395
|
+
[
|
|
2396
|
+
5,
|
|
2397
|
+
6
|
|
2398
|
+
],
|
|
2399
|
+
[
|
|
2400
|
+
5,
|
|
2401
|
+
10
|
|
2402
|
+
],
|
|
2403
|
+
[
|
|
2404
|
+
5,
|
|
2405
|
+
16
|
|
2406
|
+
],
|
|
2407
|
+
[
|
|
2408
|
+
6,
|
|
2409
|
+
16
|
|
2410
|
+
],
|
|
2411
|
+
[
|
|
2412
|
+
8,
|
|
2413
|
+
30
|
|
2414
|
+
],
|
|
2415
|
+
[
|
|
2416
|
+
8,
|
|
2417
|
+
32
|
|
2418
|
+
],
|
|
2419
|
+
[
|
|
2420
|
+
8,
|
|
2421
|
+
33
|
|
2422
|
+
],
|
|
2423
|
+
[
|
|
2424
|
+
9,
|
|
2425
|
+
33
|
|
2426
|
+
],
|
|
2427
|
+
[
|
|
2428
|
+
13,
|
|
2429
|
+
33
|
|
2430
|
+
],
|
|
2431
|
+
[
|
|
2432
|
+
14,
|
|
2433
|
+
32
|
|
2434
|
+
],
|
|
2435
|
+
[
|
|
2436
|
+
14,
|
|
2437
|
+
33
|
|
2438
|
+
],
|
|
2439
|
+
[
|
|
2440
|
+
15,
|
|
2441
|
+
32
|
|
2442
|
+
],
|
|
2443
|
+
[
|
|
2444
|
+
15,
|
|
2445
|
+
33
|
|
2446
|
+
],
|
|
2447
|
+
[
|
|
2448
|
+
18,
|
|
2449
|
+
32
|
|
2450
|
+
],
|
|
2451
|
+
[
|
|
2452
|
+
18,
|
|
2453
|
+
33
|
|
2454
|
+
],
|
|
2455
|
+
[
|
|
2456
|
+
19,
|
|
2457
|
+
33
|
|
2458
|
+
],
|
|
2459
|
+
[
|
|
2460
|
+
20,
|
|
2461
|
+
32
|
|
2462
|
+
],
|
|
2463
|
+
[
|
|
2464
|
+
20,
|
|
2465
|
+
33
|
|
2466
|
+
],
|
|
2467
|
+
[
|
|
2468
|
+
22,
|
|
2469
|
+
32
|
|
2470
|
+
],
|
|
2471
|
+
[
|
|
2472
|
+
22,
|
|
2473
|
+
33
|
|
2474
|
+
],
|
|
2475
|
+
[
|
|
2476
|
+
23,
|
|
2477
|
+
25
|
|
2478
|
+
],
|
|
2479
|
+
[
|
|
2480
|
+
23,
|
|
2481
|
+
27
|
|
2482
|
+
],
|
|
2483
|
+
[
|
|
2484
|
+
23,
|
|
2485
|
+
29
|
|
2486
|
+
],
|
|
2487
|
+
[
|
|
2488
|
+
23,
|
|
2489
|
+
32
|
|
2490
|
+
],
|
|
2491
|
+
[
|
|
2492
|
+
23,
|
|
2493
|
+
33
|
|
2494
|
+
],
|
|
2495
|
+
[
|
|
2496
|
+
24,
|
|
2497
|
+
25
|
|
2498
|
+
],
|
|
2499
|
+
[
|
|
2500
|
+
24,
|
|
2501
|
+
27
|
|
2502
|
+
],
|
|
2503
|
+
[
|
|
2504
|
+
24,
|
|
2505
|
+
31
|
|
2506
|
+
],
|
|
2507
|
+
[
|
|
2508
|
+
25,
|
|
2509
|
+
31
|
|
2510
|
+
],
|
|
2511
|
+
[
|
|
2512
|
+
26,
|
|
2513
|
+
29
|
|
2514
|
+
],
|
|
2515
|
+
[
|
|
2516
|
+
26,
|
|
2517
|
+
33
|
|
2518
|
+
],
|
|
2519
|
+
[
|
|
2520
|
+
27,
|
|
2521
|
+
33
|
|
2522
|
+
],
|
|
2523
|
+
[
|
|
2524
|
+
28,
|
|
2525
|
+
31
|
|
2526
|
+
],
|
|
2527
|
+
[
|
|
2528
|
+
28,
|
|
2529
|
+
33
|
|
2530
|
+
],
|
|
2531
|
+
[
|
|
2532
|
+
29,
|
|
2533
|
+
32
|
|
2534
|
+
],
|
|
2535
|
+
[
|
|
2536
|
+
29,
|
|
2537
|
+
33
|
|
2538
|
+
],
|
|
2539
|
+
[
|
|
2540
|
+
30,
|
|
2541
|
+
32
|
|
2542
|
+
],
|
|
2543
|
+
[
|
|
2544
|
+
30,
|
|
2545
|
+
33
|
|
2546
|
+
],
|
|
2547
|
+
[
|
|
2548
|
+
31,
|
|
2549
|
+
32
|
|
2550
|
+
],
|
|
2551
|
+
[
|
|
2552
|
+
31,
|
|
2553
|
+
33
|
|
2554
|
+
],
|
|
2555
|
+
[
|
|
2556
|
+
32,
|
|
2557
|
+
33
|
|
2558
|
+
]
|
|
2559
|
+
]
|
|
2560
|
+
};
|
|
2561
|
+
|
|
2562
|
+
|
|
2563
|
+
var $942e91a547b4130c$exports = {};
|
|
2564
|
+
|
|
2565
|
+
$parcel$export($942e91a547b4130c$exports, "default", () => $942e91a547b4130c$export$2e2bcd8739ae039);
|
|
2566
|
+
|
|
2567
|
+
var $9TL8g = parcelRequire("9TL8g");
|
|
2568
|
+
/**
|
|
2569
|
+
* This is the node class - they have an ID which is
|
|
2570
|
+
* essentially an index and some data associated with it
|
|
2571
|
+
* The data also contains the position of the
|
|
2572
|
+
*/ class $d0af3be0040778ae$var$_Node {
|
|
2573
|
+
/**
|
|
2574
|
+
*
|
|
2575
|
+
* @param data Data associated with the node, be sure to be careful to pass in any "pos" data as they correspond to position of the nodes in the visuals of the graph
|
|
2576
|
+
*/ constructor(data){
|
|
2577
|
+
// this data is an arbitrary thing with which I can create any object
|
|
2578
|
+
this.data = Object.assign({}, data);
|
|
2579
|
+
// the neighbours bit is explicity set from the code outside
|
|
2580
|
+
this.neighbours = [];
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
var $d0af3be0040778ae$export$2e2bcd8739ae039 = $d0af3be0040778ae$var$_Node;
|
|
2584
|
+
|
|
2585
|
+
|
|
2586
|
+
|
|
2587
|
+
var $i8obY = parcelRequire("i8obY");
|
|
2588
|
+
var $942e91a547b4130c$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2589
|
+
function adopt(value) {
|
|
2590
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2591
|
+
resolve(value);
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2595
|
+
function fulfilled(value) {
|
|
2596
|
+
try {
|
|
2597
|
+
step(generator.next(value));
|
|
2598
|
+
} catch (e) {
|
|
2599
|
+
reject(e);
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
function rejected(value) {
|
|
2603
|
+
try {
|
|
2604
|
+
step(generator["throw"](value));
|
|
2605
|
+
} catch (e) {
|
|
2606
|
+
reject(e);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
function step(result) {
|
|
2610
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2611
|
+
}
|
|
2612
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2613
|
+
});
|
|
2614
|
+
};
|
|
2615
|
+
// construct a graph based on an edge list etc
|
|
2616
|
+
/**
|
|
2617
|
+
* construct a graph based on an edge list and node list
|
|
2618
|
+
* @param nodes nodes as a list
|
|
2619
|
+
* @param edges edges as a list
|
|
2620
|
+
* @returns A graph that was construct from the list of nodes and edges
|
|
2621
|
+
*/ function $942e91a547b4130c$var$ConstructGraphNodeEdgesList(nodes, edges) {
|
|
2622
|
+
return $942e91a547b4130c$var$__awaiter(this, void 0, void 0, function*() {
|
|
2623
|
+
// make a node OBJ
|
|
2624
|
+
const nodeOBJ = new Map();
|
|
2625
|
+
for(let i = 0; i < nodes.length; i++){
|
|
2626
|
+
const n = new (0, $d0af3be0040778ae$export$2e2bcd8739ae039)(nodes[i].data);
|
|
2627
|
+
nodeOBJ.set(nodes[i], n);
|
|
2628
|
+
}
|
|
2629
|
+
// make an edge object
|
|
2630
|
+
const edgeOBJ = new Map();
|
|
2631
|
+
for(let i = 0; i < edges.length; i++){
|
|
2632
|
+
const e = new (0, $i8obY.default)(edges[i][0], edges[i][1], edges[i].data);
|
|
2633
|
+
edgeOBJ.set(i, e);
|
|
2634
|
+
}
|
|
2635
|
+
// make a graph object
|
|
2636
|
+
const G = yield (0, $9TL8g.default).create(nodeOBJ, edgeOBJ);
|
|
2637
|
+
return G;
|
|
2638
|
+
});
|
|
2639
|
+
}
|
|
2640
|
+
var $942e91a547b4130c$export$2e2bcd8739ae039 = {
|
|
2641
|
+
ConstructGraphNodeEdgesList: $942e91a547b4130c$var$ConstructGraphNodeEdgesList
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
var $9TL8g = parcelRequire("9TL8g");
|
|
2647
|
+
|
|
2648
|
+
var $fw40F = parcelRequire("fw40F");
|
|
2649
|
+
|
|
2650
|
+
|
|
2651
|
+
var $i8obY = parcelRequire("i8obY");
|
|
2652
|
+
|
|
2653
|
+
var $jYcHE = parcelRequire("jYcHE");
|
|
2654
|
+
var $c57cf0c4853fb804$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2655
|
+
function adopt(value) {
|
|
2656
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2657
|
+
resolve(value);
|
|
2658
|
+
});
|
|
2659
|
+
}
|
|
2660
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2661
|
+
function fulfilled(value) {
|
|
2662
|
+
try {
|
|
2663
|
+
step(generator.next(value));
|
|
2664
|
+
} catch (e) {
|
|
2665
|
+
reject(e);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
function rejected(value) {
|
|
2669
|
+
try {
|
|
2670
|
+
step(generator["throw"](value));
|
|
2671
|
+
} catch (e) {
|
|
2672
|
+
reject(e);
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
function step(result) {
|
|
2676
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2677
|
+
}
|
|
2678
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2679
|
+
});
|
|
2680
|
+
};
|
|
2681
|
+
/**
|
|
2682
|
+
*
|
|
2683
|
+
* @returns the raw ZKC dataset
|
|
2684
|
+
*/ function $c57cf0c4853fb804$var$LoadZKC() {
|
|
2685
|
+
return $c57cf0c4853fb804$var$__awaiter(this, void 0, void 0, function*() {
|
|
2686
|
+
// load up the dataset representation
|
|
2687
|
+
const data = (0, $a79fcfb00e2fad28$export$b6cdfb6bd6195507);
|
|
2688
|
+
const G = yield (0, $942e91a547b4130c$exports.default).ConstructGraphNodeEdgesList(data.nodes, data.edges);
|
|
2689
|
+
return G;
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
/**
|
|
2693
|
+
*
|
|
2694
|
+
* @returns the ZKC dataset with the positons simulated before hand
|
|
2695
|
+
*/ function $c57cf0c4853fb804$var$LoadZKCSimulated() {
|
|
2696
|
+
return $c57cf0c4853fb804$var$__awaiter(this, void 0, void 0, function*() {
|
|
2697
|
+
// make a map
|
|
2698
|
+
const data = (0, $16cc01d9c2706f25$export$aa88f89bcd11f8a9);
|
|
2699
|
+
const nodes = new Map();
|
|
2700
|
+
const edges = new Map();
|
|
2701
|
+
// set the node map
|
|
2702
|
+
data.nodes.forEach((node)=>{
|
|
2703
|
+
const id = node.id;
|
|
2704
|
+
const pos = new (0, $fw40F.default)(node.px * 50, 0, node.py * 50);
|
|
2705
|
+
const modularity = node.member;
|
|
2706
|
+
const n = new (0, $d0af3be0040778ae$export$2e2bcd8739ae039)({
|
|
2707
|
+
pos: pos,
|
|
2708
|
+
size: 10,
|
|
2709
|
+
info: "Node Info",
|
|
2710
|
+
modularity: modularity
|
|
2711
|
+
});
|
|
2712
|
+
nodes.set(id, n);
|
|
2713
|
+
});
|
|
2714
|
+
// set the edge map
|
|
2715
|
+
for(let i = 0; i < data.edges.length; i++){
|
|
2716
|
+
const edge = data.edges[i];
|
|
2717
|
+
const start = edge[0];
|
|
2718
|
+
const end = edge[1];
|
|
2719
|
+
const e = new (0, $i8obY.default)(start, end, {});
|
|
2720
|
+
edges.set(i, e);
|
|
2721
|
+
}
|
|
2722
|
+
// make a graph object
|
|
2723
|
+
const G = yield (0, $9TL8g.default).create(nodes, edges);
|
|
2724
|
+
const lmap = (0, $jYcHE.default).DrawEdgeLines(G, 20);
|
|
2725
|
+
G.apply_edge_pos_maps(lmap);
|
|
2726
|
+
return G;
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
var // exports
|
|
2730
|
+
$c57cf0c4853fb804$export$2e2bcd8739ae039 = {
|
|
2731
|
+
LoadZKC: $c57cf0c4853fb804$var$LoadZKC,
|
|
2732
|
+
LoadZKCSimulated: $c57cf0c4853fb804$var$LoadZKCSimulated
|
|
2733
|
+
};
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
|
|
2737
|
+
|
|
2738
|
+
var $jYcHE = parcelRequire("jYcHE");
|
|
2739
|
+
|
|
2740
|
+
var $fd3jp = parcelRequire("fd3jp");
|
|
2741
|
+
|
|
2742
|
+
var $6Xdhg = parcelRequire("6Xdhg");
|
|
2743
|
+
|
|
2744
|
+
var $eqUI8 = parcelRequire("eqUI8");
|
|
2745
|
+
var $6abda68f7f78a6fb$exports = {};
|
|
2746
|
+
|
|
2747
|
+
$parcel$export($6abda68f7f78a6fb$exports, "default", () => $6abda68f7f78a6fb$export$2e2bcd8739ae039);
|
|
2748
|
+
|
|
2749
|
+
|
|
2750
|
+
var $6abda68f7f78a6fb$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2751
|
+
function adopt(value) {
|
|
2752
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2753
|
+
resolve(value);
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2757
|
+
function fulfilled(value) {
|
|
2758
|
+
try {
|
|
2759
|
+
step(generator.next(value));
|
|
2760
|
+
} catch (e) {
|
|
2761
|
+
reject(e);
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
function rejected(value) {
|
|
2765
|
+
try {
|
|
2766
|
+
step(generator["throw"](value));
|
|
2767
|
+
} catch (e) {
|
|
2768
|
+
reject(e);
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
function step(result) {
|
|
2772
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2773
|
+
}
|
|
2774
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2775
|
+
});
|
|
2776
|
+
};
|
|
2777
|
+
/**
|
|
2778
|
+
* This is the main graph drawer class
|
|
2779
|
+
*/ class $6abda68f7f78a6fb$var$GraphDrawer3d {
|
|
2780
|
+
/**
|
|
2781
|
+
* To initialize the graph drawer there are a set of graph drawing settings that have to be set.
|
|
2782
|
+
* Here are the details to do the same:
|
|
2783
|
+
* canvas - the html canvas element that you would like to render
|
|
2784
|
+
* height - the the height of the initialized canvas
|
|
2785
|
+
* width - the width of the initialized canvas
|
|
2786
|
+
* geometry map - a map that keeps track of all the geometry in the scene (Optional)
|
|
2787
|
+
* material map - a mapt that keeps track of all the materials in the scene (Optional)
|
|
2788
|
+
* controls - Controls that define how one can navigate this 3d space (Self initialized)
|
|
2789
|
+
* renderer - Renderer element form the three JS library
|
|
2790
|
+
* camera - A perspective camera from the threeJS library
|
|
2791
|
+
* scene - The three JS scene that gets define automatically
|
|
2792
|
+
*
|
|
2793
|
+
* @param GraphDrawerOptions3d - These above options are construdeted into a single object and passed into the Options elem
|
|
2794
|
+
*/ constructor(GraphDrawerOptions3d){
|
|
2795
|
+
this.canvas = GraphDrawerOptions3d.canvas;
|
|
2796
|
+
this.width = GraphDrawerOptions3d.width;
|
|
2797
|
+
this.height = GraphDrawerOptions3d.height;
|
|
2798
|
+
// these maps are optional
|
|
2799
|
+
// ive kepth them in as a way of managing all the
|
|
2800
|
+
// geometry in the scene
|
|
2801
|
+
this.geometryMap = new Map();
|
|
2802
|
+
this.materialMap = new Map();
|
|
2803
|
+
this.meshMap = new Map();
|
|
2804
|
+
this.controls;
|
|
2805
|
+
this.renderer;
|
|
2806
|
+
this.camera;
|
|
2807
|
+
this.scene;
|
|
2808
|
+
// graph map is the hash map that holds all the
|
|
2809
|
+
// graphs that we are working with together
|
|
2810
|
+
this.graphs = new Map();
|
|
2811
|
+
}
|
|
2812
|
+
/**
|
|
2813
|
+
* This essentially initializes the drawing element based on the settings
|
|
2814
|
+
* Remember to do this since if if its not done the scene will not render
|
|
2815
|
+
*/ init() {
|
|
2816
|
+
return $6abda68f7f78a6fb$var$__awaiter(this, void 0, void 0, function*() {
|
|
2817
|
+
const t1 = performance.now();
|
|
2818
|
+
this.camera = new $h9nKb$three.PerspectiveCamera();
|
|
2819
|
+
// start up a new scene
|
|
2820
|
+
this.scene = new $h9nKb$three.Scene();
|
|
2821
|
+
// set up a renderer
|
|
2822
|
+
this.renderer = new $h9nKb$three.WebGLRenderer({
|
|
2823
|
+
canvas: this.canvas,
|
|
2824
|
+
antialias: true
|
|
2825
|
+
});
|
|
2826
|
+
this.renderer.setSize(this.width, this.height);
|
|
2827
|
+
this.renderer.setClearColor(0xff00ff, 0);
|
|
2828
|
+
// add in a light
|
|
2829
|
+
this.scene.add(new $h9nKb$three.AmbientLight(0xffffff));
|
|
2830
|
+
// add a spotlight
|
|
2831
|
+
const DirectionalLight = new $h9nKb$three.DirectionalLight(0xffffff, 1);
|
|
2832
|
+
DirectionalLight.position.set(0, 10, 0);
|
|
2833
|
+
this.scene.add(DirectionalLight);
|
|
2834
|
+
// set up the control system
|
|
2835
|
+
this.controls = new (0, $h9nKb$threeexamplesjsmcontrolsOrbitControls.OrbitControls)(this.camera, this.renderer.domElement);
|
|
2836
|
+
this.camera.position.set(0, 100, 100);
|
|
2837
|
+
this.controls.autoRotate = true;
|
|
2838
|
+
this.controls.maxPolarAngle = Math.PI * 0.5;
|
|
2839
|
+
this.controls.maxDistance = 10000;
|
|
2840
|
+
this.controls.minDistance = 10;
|
|
2841
|
+
this.controls.update();
|
|
2842
|
+
// finally print out that the initialization has finished
|
|
2843
|
+
const t2 = performance.now();
|
|
2844
|
+
console.log("initialization has finished");
|
|
2845
|
+
console.log(`Time to initialize ${t2 - t1} milliseconds`);
|
|
2846
|
+
});
|
|
2847
|
+
}
|
|
2848
|
+
//add graph
|
|
2849
|
+
// this adds a graph to the current visualizer
|
|
2850
|
+
/**
|
|
2851
|
+
*
|
|
2852
|
+
* This is the main way to add elements to the viewer window that gets initialized
|
|
2853
|
+
*
|
|
2854
|
+
* @param element A geomerty element + material element to add to the scene as a group line or point cloud
|
|
2855
|
+
*/ addVisElement(element) {
|
|
2856
|
+
this.scene.add(element);
|
|
2857
|
+
}
|
|
2858
|
+
// this stuff renders out one specific instances
|
|
2859
|
+
/**
|
|
2860
|
+
* This is the render call that is called every frame to update the rendering of the canvas
|
|
2861
|
+
* Remember to do this since this is a common are for bugs to occur
|
|
2862
|
+
*/ rendercall() {
|
|
2863
|
+
// this is the render draw call
|
|
2864
|
+
this.renderer.render(this.scene, this.camera);
|
|
2865
|
+
this.controls.update();
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
var $6abda68f7f78a6fb$export$2e2bcd8739ae039 = {
|
|
2869
|
+
GraphDrawer3d: $6abda68f7f78a6fb$var$GraphDrawer3d
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2872
|
+
|
|
2873
|
+
var $7308258d93363088$exports = {};
|
|
2874
|
+
|
|
2875
|
+
$parcel$export($7308258d93363088$exports, "default", () => $7308258d93363088$export$2e2bcd8739ae039);
|
|
2876
|
+
// This essentially generates a erdos reyni graph
|
|
2877
|
+
// Super useful for juszt getting a random graph and studying
|
|
2878
|
+
// graph structure. Read more https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model
|
|
2879
|
+
|
|
2880
|
+
var $i8obY = parcelRequire("i8obY");
|
|
2881
|
+
|
|
2882
|
+
var $9TL8g = parcelRequire("9TL8g");
|
|
2883
|
+
|
|
2884
|
+
var $7308258d93363088$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2885
|
+
function adopt(value) {
|
|
2886
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2887
|
+
resolve(value);
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2891
|
+
function fulfilled(value) {
|
|
2892
|
+
try {
|
|
2893
|
+
step(generator.next(value));
|
|
2894
|
+
} catch (e) {
|
|
2895
|
+
reject(e);
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
function rejected(value) {
|
|
2899
|
+
try {
|
|
2900
|
+
step(generator["throw"](value));
|
|
2901
|
+
} catch (e) {
|
|
2902
|
+
reject(e);
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
function step(result) {
|
|
2906
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2907
|
+
}
|
|
2908
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2909
|
+
});
|
|
2910
|
+
};
|
|
2911
|
+
/**
|
|
2912
|
+
* The G ( n , p ) G(n,p) model, a graph is constructed by connecting labeled nodes randomly. Each edge is included in the graph with probability p p, independently from every other edge.
|
|
2913
|
+
* https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model
|
|
2914
|
+
* @param n Number of nodes
|
|
2915
|
+
* @param p Probability of two edges to eb connected
|
|
2916
|
+
* @returns A Erdos Reyni graph
|
|
2917
|
+
*/ function $7308258d93363088$var$GenerateErdosReyni_n_p(n, p) {
|
|
2918
|
+
return $7308258d93363088$var$__awaiter(this, void 0, void 0, function*() {
|
|
2919
|
+
// first create a list of nodes
|
|
2920
|
+
const nodes = new Map();
|
|
2921
|
+
const edges = new Map();
|
|
2922
|
+
let node; // define once use many times basically
|
|
2923
|
+
for(let i = 0; i < n; i++){
|
|
2924
|
+
node = new (0, $d0af3be0040778ae$export$2e2bcd8739ae039)({});
|
|
2925
|
+
// set this node
|
|
2926
|
+
nodes.set(i, node);
|
|
2927
|
+
}
|
|
2928
|
+
// now that all the nodes have been created
|
|
2929
|
+
// now loop all the node combinations and then
|
|
2930
|
+
// create the edge
|
|
2931
|
+
let interimP;
|
|
2932
|
+
let edge;
|
|
2933
|
+
let index = 0;
|
|
2934
|
+
for(let i = 0; i < n; i++){
|
|
2935
|
+
for(let ii = 0; ii < n; ii++)// im skipping self loops so just make sure there is
|
|
2936
|
+
// an if statement for the settings
|
|
2937
|
+
if (i != ii) {
|
|
2938
|
+
interimP = Math.random();
|
|
2939
|
+
if (p > interimP) {
|
|
2940
|
+
// then create and edge and add that edge to the list of edges
|
|
2941
|
+
edge = new (0, $i8obY.default)(i, ii, {});
|
|
2942
|
+
edges.set(index, edge);
|
|
2943
|
+
index += 1;
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
// now create the actual graph
|
|
2948
|
+
const G = new (0, $9TL8g.default)(nodes, edges);
|
|
2949
|
+
// lastly return the graph
|
|
2950
|
+
return G;
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
var $7308258d93363088$export$2e2bcd8739ae039 = {
|
|
2954
|
+
GenerateErdosReyni_n_p: $7308258d93363088$var$GenerateErdosReyni_n_p
|
|
2955
|
+
};
|
|
2956
|
+
|
|
2957
|
+
|
|
2958
|
+
|
|
2959
|
+
|
|
2960
|
+
//# sourceMappingURL=pgl.js.map
|