cg-code-graph 0.10.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. cg_code_graph-0.10.1.dist-info/METADATA +678 -0
  2. cg_code_graph-0.10.1.dist-info/RECORD +174 -0
  3. cg_code_graph-0.10.1.dist-info/WHEEL +5 -0
  4. cg_code_graph-0.10.1.dist-info/entry_points.txt +3 -0
  5. cg_code_graph-0.10.1.dist-info/licenses/LICENSE +21 -0
  6. cg_code_graph-0.10.1.dist-info/top_level.txt +1 -0
  7. codegraph/__init__.py +2 -0
  8. codegraph/aitools.py +129 -0
  9. codegraph/apps.py +76 -0
  10. codegraph/blindspots.py +428 -0
  11. codegraph/bridges.py +1701 -0
  12. codegraph/cli.py +725 -0
  13. codegraph/concepts.py +362 -0
  14. codegraph/config.py +559 -0
  15. codegraph/core/__init__.py +0 -0
  16. codegraph/core/cache.py +375 -0
  17. codegraph/core/detect.py +80 -0
  18. codegraph/core/extractors.py +187 -0
  19. codegraph/core/fsutil.py +61 -0
  20. codegraph/core/generated.py +575 -0
  21. codegraph/core/model.py +174 -0
  22. codegraph/core/paths.py +175 -0
  23. codegraph/core/plugin.py +160 -0
  24. codegraph/core/store.py +80 -0
  25. codegraph/core/syntax_errors.py +132 -0
  26. codegraph/coverage.py +928 -0
  27. codegraph/doctor.py +453 -0
  28. codegraph/external.py +613 -0
  29. codegraph/indexer.py +336 -0
  30. codegraph/link.py +434 -0
  31. codegraph/lint_async.py +524 -0
  32. codegraph/mcp_server.py +1303 -0
  33. codegraph/parity.py +473 -0
  34. codegraph/parity_structure.py +307 -0
  35. codegraph/payload.py +321 -0
  36. codegraph/plans.py +1285 -0
  37. codegraph/platform_scan.py +643 -0
  38. codegraph/platforms.py +1369 -0
  39. codegraph/plugins/__init__.py +0 -0
  40. codegraph/plugins/cfamily/__init__.py +0 -0
  41. codegraph/plugins/cfamily/plugin.py +930 -0
  42. codegraph/plugins/cfamily/syntax.py +881 -0
  43. codegraph/plugins/dart/__init__.py +0 -0
  44. codegraph/plugins/dart/bridges.py +345 -0
  45. codegraph/plugins/dart/extractor/bin/extract.dart +717 -0
  46. codegraph/plugins/dart/extractor/pubspec.lock +149 -0
  47. codegraph/plugins/dart/extractor/pubspec.yaml +7 -0
  48. codegraph/plugins/dart/http.py +904 -0
  49. codegraph/plugins/dart/models.py +308 -0
  50. codegraph/plugins/dart/plugin.py +625 -0
  51. codegraph/plugins/dart/program.py +907 -0
  52. codegraph/plugins/django/__init__.py +0 -0
  53. codegraph/plugins/django/extras.py +378 -0
  54. codegraph/plugins/django/models.py +508 -0
  55. codegraph/plugins/django/plugin.py +728 -0
  56. codegraph/plugins/django/schemas.py +339 -0
  57. codegraph/plugins/django/shapes.py +216 -0
  58. codegraph/plugins/django/urls.py +603 -0
  59. codegraph/plugins/express/__init__.py +0 -0
  60. codegraph/plugins/express/plugin.py +428 -0
  61. codegraph/plugins/flutter/__init__.py +0 -0
  62. codegraph/plugins/flutter/plugin.py +538 -0
  63. codegraph/plugins/kotlin/__init__.py +0 -0
  64. codegraph/plugins/kotlin/exact.py +457 -0
  65. codegraph/plugins/kotlin/plugin.py +1961 -0
  66. codegraph/plugins/kotlin/reparse.py +234 -0
  67. codegraph/plugins/laravel/__init__.py +0 -0
  68. codegraph/plugins/laravel/broadcast.py +351 -0
  69. codegraph/plugins/laravel/plugin.py +863 -0
  70. codegraph/plugins/laravel/tests.py +262 -0
  71. codegraph/plugins/laravel/values.py +728 -0
  72. codegraph/plugins/native/__init__.py +0 -0
  73. codegraph/plugins/native/gates.py +286 -0
  74. codegraph/plugins/native/runner.py +183 -0
  75. codegraph/plugins/native/scipread.py +194 -0
  76. codegraph/plugins/native/ts.py +54 -0
  77. codegraph/plugins/nest/__init__.py +0 -0
  78. codegraph/plugins/nest/plugin.py +654 -0
  79. codegraph/plugins/nextjs/__init__.py +0 -0
  80. codegraph/plugins/nextjs/plugin.py +336 -0
  81. codegraph/plugins/nuxt/__init__.py +0 -0
  82. codegraph/plugins/nuxt/plugin.py +308 -0
  83. codegraph/plugins/php/__init__.py +0 -0
  84. codegraph/plugins/php/extractor/composer.json +5 -0
  85. codegraph/plugins/php/extractor/composer.lock +76 -0
  86. codegraph/plugins/php/extractor/extract.php +743 -0
  87. codegraph/plugins/php/gating.py +573 -0
  88. codegraph/plugins/php/plugin.py +668 -0
  89. codegraph/plugins/php/strings.py +197 -0
  90. codegraph/plugins/python/__init__.py +0 -0
  91. codegraph/plugins/python/aitools.py +664 -0
  92. codegraph/plugins/python/external.py +245 -0
  93. codegraph/plugins/python/fields.py +107 -0
  94. codegraph/plugins/python/plugin.py +1733 -0
  95. codegraph/plugins/python/refs.py +485 -0
  96. codegraph/plugins/python/roots.py +412 -0
  97. codegraph/plugins/python/socketio.py +210 -0
  98. codegraph/plugins/python/subproc.py +864 -0
  99. codegraph/plugins/python/tests.py +1040 -0
  100. codegraph/plugins/python/values.py +179 -0
  101. codegraph/plugins/pyweb/__init__.py +0 -0
  102. codegraph/plugins/pyweb/plugin.py +1334 -0
  103. codegraph/plugins/pyweb/values.py +68 -0
  104. codegraph/plugins/rust/__init__.py +0 -0
  105. codegraph/plugins/rust/cargo.py +226 -0
  106. codegraph/plugins/rust/plugin.py +980 -0
  107. codegraph/plugins/rust/syntax.py +678 -0
  108. codegraph/plugins/scip/__init__.py +0 -0
  109. codegraph/plugins/scip/importer.py +129 -0
  110. codegraph/plugins/scip/scip.proto +962 -0
  111. codegraph/plugins/scip/scip_pb2.py +97 -0
  112. codegraph/plugins/stubs/__init__.py +0 -0
  113. codegraph/plugins/stubs/plugins.py +38 -0
  114. codegraph/plugins/swift/__init__.py +0 -0
  115. codegraph/plugins/swift/baseurl.py +109 -0
  116. codegraph/plugins/swift/exact.py +415 -0
  117. codegraph/plugins/swift/indexstore.py +209 -0
  118. codegraph/plugins/swift/packages.py +174 -0
  119. codegraph/plugins/swift/plugin.py +2890 -0
  120. codegraph/plugins/ts/__init__.py +0 -0
  121. codegraph/plugins/ts/baseurl.py +185 -0
  122. codegraph/plugins/ts/extractor/extract.mjs +2652 -0
  123. codegraph/plugins/ts/extractor/fw.mjs +685 -0
  124. codegraph/plugins/ts/extractor/package-lock.json +205 -0
  125. codegraph/plugins/ts/extractor/package.json +9 -0
  126. codegraph/plugins/ts/plugin.py +480 -0
  127. codegraph/plugins/tsweb/__init__.py +0 -0
  128. codegraph/plugins/tsweb/common.py +290 -0
  129. codegraph/plugins/tsweb/data.py +276 -0
  130. codegraph/presets/__init__.py +146 -0
  131. codegraph/presets/c_cpp.yaml +9 -0
  132. codegraph/presets/common.yaml +66 -0
  133. codegraph/presets/dart.yaml +9 -0
  134. codegraph/presets/django-ninja.yaml +15 -0
  135. codegraph/presets/django.yaml +25 -0
  136. codegraph/presets/djangorestframework.yaml +17 -0
  137. codegraph/presets/express.yaml +17 -0
  138. codegraph/presets/kotlin.yaml +11 -0
  139. codegraph/presets/laravel.yaml +40 -0
  140. codegraph/presets/nest.yaml +11 -0
  141. codegraph/presets/nextjs.yaml +15 -0
  142. codegraph/presets/nuxt.yaml +9 -0
  143. codegraph/presets/php.yaml +5 -0
  144. codegraph/presets/python.yaml +10 -0
  145. codegraph/presets/rust.yaml +5 -0
  146. codegraph/presets/swift.yaml +10 -0
  147. codegraph/presets/typescript.yaml +13 -0
  148. codegraph/process_runs.py +328 -0
  149. codegraph/protocols/__init__.py +299 -0
  150. codegraph/protocols/builtin.py +67 -0
  151. codegraph/protocols/matchers.py +144 -0
  152. codegraph/protocols/view.py +334 -0
  153. codegraph/query.py +2089 -0
  154. codegraph/realtime.py +260 -0
  155. codegraph/roundtrip.py +346 -0
  156. codegraph/routes.py +442 -0
  157. codegraph/starters.py +218 -0
  158. codegraph/tests_index.py +117 -0
  159. codegraph/viz/__init__.py +0 -0
  160. codegraph/viz/graph.py +369 -0
  161. codegraph/viz/server.py +198 -0
  162. codegraph/viz/static/app.css +148 -0
  163. codegraph/viz/static/app.js +1082 -0
  164. codegraph/viz/static/index.html +81 -0
  165. codegraph/viz/static/layered.js +237 -0
  166. codegraph/viz/static/vendor/VERSIONS.txt +4 -0
  167. codegraph/viz/static/vendor/cose-base.js +3214 -0
  168. codegraph/viz/static/vendor/cytoscape-fcose.js +1549 -0
  169. codegraph/viz/static/vendor/cytoscape.min.js +31 -0
  170. codegraph/viz/static/vendor/layout-base.js +5230 -0
  171. codegraph/viz/tools/package-lock.json +303 -0
  172. codegraph/viz/tools/package.json +7 -0
  173. codegraph/viz/tools/shoot.mjs +165 -0
  174. codegraph/xcode.py +251 -0
@@ -0,0 +1,1549 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("cose-base"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["cose-base"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["cytoscapeFcose"] = factory(require("cose-base"));
8
+ else
9
+ root["cytoscapeFcose"] = factory(root["coseBase"]);
10
+ })(this, function(__WEBPACK_EXTERNAL_MODULE__140__) {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 658:
16
+ /***/ ((module) => {
17
+
18
+
19
+
20
+ // Simple, internal Object.assign() polyfill for options objects etc.
21
+
22
+ module.exports = Object.assign != null ? Object.assign.bind(Object) : function (tgt) {
23
+ for (var _len = arguments.length, srcs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
24
+ srcs[_key - 1] = arguments[_key];
25
+ }
26
+
27
+ srcs.forEach(function (src) {
28
+ Object.keys(src).forEach(function (k) {
29
+ return tgt[k] = src[k];
30
+ });
31
+ });
32
+
33
+ return tgt;
34
+ };
35
+
36
+ /***/ }),
37
+
38
+ /***/ 548:
39
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
40
+
41
+
42
+
43
+ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
44
+
45
+ /*
46
+ * Auxiliary functions
47
+ */
48
+
49
+ var LinkedList = __webpack_require__(140).layoutBase.LinkedList;
50
+
51
+ var auxiliary = {};
52
+
53
+ // get the top most nodes
54
+ auxiliary.getTopMostNodes = function (nodes) {
55
+ var nodesMap = {};
56
+ for (var i = 0; i < nodes.length; i++) {
57
+ nodesMap[nodes[i].id()] = true;
58
+ }
59
+ var roots = nodes.filter(function (ele, i) {
60
+ if (typeof ele === "number") {
61
+ ele = i;
62
+ }
63
+ var parent = ele.parent()[0];
64
+ while (parent != null) {
65
+ if (nodesMap[parent.id()]) {
66
+ return false;
67
+ }
68
+ parent = parent.parent()[0];
69
+ }
70
+ return true;
71
+ });
72
+
73
+ return roots;
74
+ };
75
+
76
+ // find disconnected components and create dummy nodes that connect them
77
+ auxiliary.connectComponents = function (cy, eles, topMostNodes, dummyNodes) {
78
+ var queue = new LinkedList();
79
+ var visited = new Set();
80
+ var visitedTopMostNodes = [];
81
+ var currentNeighbor = void 0;
82
+ var minDegreeNode = void 0;
83
+ var minDegree = void 0;
84
+
85
+ var isConnected = false;
86
+ var count = 1;
87
+ var nodesConnectedToDummy = [];
88
+ var components = [];
89
+
90
+ var _loop = function _loop() {
91
+ var cmpt = cy.collection();
92
+ components.push(cmpt);
93
+
94
+ var currentNode = topMostNodes[0];
95
+ var childrenOfCurrentNode = cy.collection();
96
+ childrenOfCurrentNode.merge(currentNode).merge(currentNode.descendants().intersection(eles));
97
+ visitedTopMostNodes.push(currentNode);
98
+
99
+ childrenOfCurrentNode.forEach(function (node) {
100
+ queue.push(node);
101
+ visited.add(node);
102
+ cmpt.merge(node);
103
+ });
104
+
105
+ var _loop2 = function _loop2() {
106
+ currentNode = queue.shift();
107
+
108
+ // Traverse all neighbors of this node
109
+ var neighborNodes = cy.collection();
110
+ currentNode.neighborhood().nodes().forEach(function (node) {
111
+ if (eles.intersection(currentNode.edgesWith(node)).length > 0) {
112
+ neighborNodes.merge(node);
113
+ }
114
+ });
115
+
116
+ for (var i = 0; i < neighborNodes.length; i++) {
117
+ var neighborNode = neighborNodes[i];
118
+ currentNeighbor = topMostNodes.intersection(neighborNode.union(neighborNode.ancestors()));
119
+ if (currentNeighbor != null && !visited.has(currentNeighbor[0])) {
120
+ var childrenOfNeighbor = currentNeighbor.union(currentNeighbor.descendants());
121
+
122
+ childrenOfNeighbor.forEach(function (node) {
123
+ queue.push(node);
124
+ visited.add(node);
125
+ cmpt.merge(node);
126
+ if (topMostNodes.has(node)) {
127
+ visitedTopMostNodes.push(node);
128
+ }
129
+ });
130
+ }
131
+ }
132
+ };
133
+
134
+ while (queue.length != 0) {
135
+ _loop2();
136
+ }
137
+
138
+ cmpt.forEach(function (node) {
139
+ eles.intersection(node.connectedEdges()).forEach(function (e) {
140
+ // connectedEdges() usually cached
141
+ if (cmpt.has(e.source()) && cmpt.has(e.target())) {
142
+ // has() is cheap
143
+ cmpt.merge(e);
144
+ }
145
+ });
146
+ });
147
+
148
+ if (visitedTopMostNodes.length == topMostNodes.length) {
149
+ isConnected = true;
150
+ }
151
+
152
+ if (!isConnected || isConnected && count > 1) {
153
+ minDegreeNode = visitedTopMostNodes[0];
154
+ minDegree = minDegreeNode.connectedEdges().length;
155
+ visitedTopMostNodes.forEach(function (node) {
156
+ if (node.connectedEdges().length < minDegree) {
157
+ minDegree = node.connectedEdges().length;
158
+ minDegreeNode = node;
159
+ }
160
+ });
161
+ nodesConnectedToDummy.push(minDegreeNode.id());
162
+ // TO DO: Check efficiency of this part
163
+ var temp = cy.collection();
164
+ temp.merge(visitedTopMostNodes[0]);
165
+ visitedTopMostNodes.forEach(function (node) {
166
+ temp.merge(node);
167
+ });
168
+ visitedTopMostNodes = [];
169
+ topMostNodes = topMostNodes.difference(temp);
170
+ count++;
171
+ }
172
+ };
173
+
174
+ do {
175
+ _loop();
176
+ } while (!isConnected);
177
+
178
+ if (dummyNodes) {
179
+ if (nodesConnectedToDummy.length > 0) {
180
+ dummyNodes.set('dummy' + (dummyNodes.size + 1), nodesConnectedToDummy);
181
+ }
182
+ }
183
+ return components;
184
+ };
185
+
186
+ // relocates componentResult to originalCenter if there is no fixedNodeConstraint
187
+ auxiliary.relocateComponent = function (originalCenter, componentResult, options) {
188
+ if (!options.fixedNodeConstraint) {
189
+ var minXCoord = Number.POSITIVE_INFINITY;
190
+ var maxXCoord = Number.NEGATIVE_INFINITY;
191
+ var minYCoord = Number.POSITIVE_INFINITY;
192
+ var maxYCoord = Number.NEGATIVE_INFINITY;
193
+ if (options.quality == "draft") {
194
+ // calculate current bounding box
195
+ var _iteratorNormalCompletion = true;
196
+ var _didIteratorError = false;
197
+ var _iteratorError = undefined;
198
+
199
+ try {
200
+ for (var _iterator = componentResult.nodeIndexes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
201
+ var _ref = _step.value;
202
+
203
+ var _ref2 = _slicedToArray(_ref, 2);
204
+
205
+ var key = _ref2[0];
206
+ var value = _ref2[1];
207
+
208
+ var cyNode = options.cy.getElementById(key);
209
+ if (cyNode) {
210
+ var nodeBB = cyNode.boundingBox();
211
+ var leftX = componentResult.xCoords[value] - nodeBB.w / 2;
212
+ var rightX = componentResult.xCoords[value] + nodeBB.w / 2;
213
+ var topY = componentResult.yCoords[value] - nodeBB.h / 2;
214
+ var bottomY = componentResult.yCoords[value] + nodeBB.h / 2;
215
+
216
+ if (leftX < minXCoord) minXCoord = leftX;
217
+ if (rightX > maxXCoord) maxXCoord = rightX;
218
+ if (topY < minYCoord) minYCoord = topY;
219
+ if (bottomY > maxYCoord) maxYCoord = bottomY;
220
+ }
221
+ }
222
+ // find difference between current and original center
223
+ } catch (err) {
224
+ _didIteratorError = true;
225
+ _iteratorError = err;
226
+ } finally {
227
+ try {
228
+ if (!_iteratorNormalCompletion && _iterator.return) {
229
+ _iterator.return();
230
+ }
231
+ } finally {
232
+ if (_didIteratorError) {
233
+ throw _iteratorError;
234
+ }
235
+ }
236
+ }
237
+
238
+ var diffOnX = originalCenter.x - (maxXCoord + minXCoord) / 2;
239
+ var diffOnY = originalCenter.y - (maxYCoord + minYCoord) / 2;
240
+ // move component to original center
241
+ componentResult.xCoords = componentResult.xCoords.map(function (x) {
242
+ return x + diffOnX;
243
+ });
244
+ componentResult.yCoords = componentResult.yCoords.map(function (y) {
245
+ return y + diffOnY;
246
+ });
247
+ } else {
248
+ // calculate current bounding box
249
+ Object.keys(componentResult).forEach(function (item) {
250
+ var node = componentResult[item];
251
+ var leftX = node.getRect().x;
252
+ var rightX = node.getRect().x + node.getRect().width;
253
+ var topY = node.getRect().y;
254
+ var bottomY = node.getRect().y + node.getRect().height;
255
+
256
+ if (leftX < minXCoord) minXCoord = leftX;
257
+ if (rightX > maxXCoord) maxXCoord = rightX;
258
+ if (topY < minYCoord) minYCoord = topY;
259
+ if (bottomY > maxYCoord) maxYCoord = bottomY;
260
+ });
261
+ // find difference between current and original center
262
+ var _diffOnX = originalCenter.x - (maxXCoord + minXCoord) / 2;
263
+ var _diffOnY = originalCenter.y - (maxYCoord + minYCoord) / 2;
264
+ // move component to original center
265
+ Object.keys(componentResult).forEach(function (item) {
266
+ var node = componentResult[item];
267
+ node.setCenter(node.getCenterX() + _diffOnX, node.getCenterY() + _diffOnY);
268
+ });
269
+ }
270
+ }
271
+ };
272
+
273
+ auxiliary.calcBoundingBox = function (parentNode, xCoords, yCoords, nodeIndexes) {
274
+ // calculate bounds
275
+ var left = Number.MAX_SAFE_INTEGER;
276
+ var right = Number.MIN_SAFE_INTEGER;
277
+ var top = Number.MAX_SAFE_INTEGER;
278
+ var bottom = Number.MIN_SAFE_INTEGER;
279
+ var nodeLeft = void 0;
280
+ var nodeRight = void 0;
281
+ var nodeTop = void 0;
282
+ var nodeBottom = void 0;
283
+
284
+ var nodes = parentNode.descendants().not(":parent");
285
+ var s = nodes.length;
286
+ for (var i = 0; i < s; i++) {
287
+ var node = nodes[i];
288
+
289
+ nodeLeft = xCoords[nodeIndexes.get(node.id())] - node.width() / 2;
290
+ nodeRight = xCoords[nodeIndexes.get(node.id())] + node.width() / 2;
291
+ nodeTop = yCoords[nodeIndexes.get(node.id())] - node.height() / 2;
292
+ nodeBottom = yCoords[nodeIndexes.get(node.id())] + node.height() / 2;
293
+
294
+ if (left > nodeLeft) {
295
+ left = nodeLeft;
296
+ }
297
+
298
+ if (right < nodeRight) {
299
+ right = nodeRight;
300
+ }
301
+
302
+ if (top > nodeTop) {
303
+ top = nodeTop;
304
+ }
305
+
306
+ if (bottom < nodeBottom) {
307
+ bottom = nodeBottom;
308
+ }
309
+ }
310
+
311
+ var boundingBox = {};
312
+ boundingBox.topLeftX = left;
313
+ boundingBox.topLeftY = top;
314
+ boundingBox.width = right - left;
315
+ boundingBox.height = bottom - top;
316
+ return boundingBox;
317
+ };
318
+
319
+ // This function finds and returns parent nodes whose all children are hidden
320
+ auxiliary.calcParentsWithoutChildren = function (cy, eles) {
321
+ var parentsWithoutChildren = cy.collection();
322
+ eles.nodes(':parent').forEach(function (parent) {
323
+ var check = false;
324
+ parent.children().forEach(function (child) {
325
+ if (child.css('display') != 'none') {
326
+ check = true;
327
+ }
328
+ });
329
+ if (!check) {
330
+ parentsWithoutChildren.merge(parent);
331
+ }
332
+ });
333
+
334
+ return parentsWithoutChildren;
335
+ };
336
+
337
+ module.exports = auxiliary;
338
+
339
+ /***/ }),
340
+
341
+ /***/ 816:
342
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
343
+
344
+
345
+
346
+ /**
347
+ The implementation of the postprocessing part that applies CoSE layout over the spectral layout
348
+ */
349
+
350
+ var aux = __webpack_require__(548);
351
+ var CoSELayout = __webpack_require__(140).CoSELayout;
352
+ var CoSENode = __webpack_require__(140).CoSENode;
353
+ var PointD = __webpack_require__(140).layoutBase.PointD;
354
+ var DimensionD = __webpack_require__(140).layoutBase.DimensionD;
355
+ var LayoutConstants = __webpack_require__(140).layoutBase.LayoutConstants;
356
+ var FDLayoutConstants = __webpack_require__(140).layoutBase.FDLayoutConstants;
357
+ var CoSEConstants = __webpack_require__(140).CoSEConstants;
358
+
359
+ // main function that cose layout is processed
360
+ var coseLayout = function coseLayout(options, spectralResult) {
361
+
362
+ var cy = options.cy;
363
+ var eles = options.eles;
364
+ var nodes = eles.nodes();
365
+ var edges = eles.edges();
366
+
367
+ var nodeIndexes = void 0;
368
+ var xCoords = void 0;
369
+ var yCoords = void 0;
370
+ var idToLNode = {};
371
+
372
+ if (options.randomize) {
373
+ nodeIndexes = spectralResult["nodeIndexes"];
374
+ xCoords = spectralResult["xCoords"];
375
+ yCoords = spectralResult["yCoords"];
376
+ }
377
+
378
+ var isFn = function isFn(fn) {
379
+ return typeof fn === 'function';
380
+ };
381
+
382
+ var optFn = function optFn(opt, ele) {
383
+ if (isFn(opt)) {
384
+ return opt(ele);
385
+ } else {
386
+ return opt;
387
+ }
388
+ };
389
+
390
+ /**** Postprocessing functions ****/
391
+
392
+ var parentsWithoutChildren = aux.calcParentsWithoutChildren(cy, eles);
393
+
394
+ // transfer cytoscape nodes to cose nodes
395
+ var processChildrenList = function processChildrenList(parent, children, layout, options) {
396
+ var size = children.length;
397
+ for (var i = 0; i < size; i++) {
398
+ var theChild = children[i];
399
+ var children_of_children = null;
400
+ if (theChild.intersection(parentsWithoutChildren).length == 0) {
401
+ children_of_children = theChild.children();
402
+ }
403
+ var theNode = void 0;
404
+
405
+ var dimensions = theChild.layoutDimensions({
406
+ nodeDimensionsIncludeLabels: options.nodeDimensionsIncludeLabels
407
+ });
408
+
409
+ if (theChild.outerWidth() != null && theChild.outerHeight() != null) {
410
+ if (options.randomize) {
411
+ if (!theChild.isParent()) {
412
+ theNode = parent.add(new CoSENode(layout.graphManager, new PointD(xCoords[nodeIndexes.get(theChild.id())] - dimensions.w / 2, yCoords[nodeIndexes.get(theChild.id())] - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h))));
413
+ } else {
414
+ var parentInfo = aux.calcBoundingBox(theChild, xCoords, yCoords, nodeIndexes);
415
+ if (theChild.intersection(parentsWithoutChildren).length == 0) {
416
+ theNode = parent.add(new CoSENode(layout.graphManager, new PointD(parentInfo.topLeftX, parentInfo.topLeftY), new DimensionD(parentInfo.width, parentInfo.height)));
417
+ } else {
418
+ // for the parentsWithoutChildren
419
+ theNode = parent.add(new CoSENode(layout.graphManager, new PointD(parentInfo.topLeftX, parentInfo.topLeftY), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h))));
420
+ }
421
+ }
422
+ } else {
423
+ theNode = parent.add(new CoSENode(layout.graphManager, new PointD(theChild.position('x') - dimensions.w / 2, theChild.position('y') - dimensions.h / 2), new DimensionD(parseFloat(dimensions.w), parseFloat(dimensions.h))));
424
+ }
425
+ } else {
426
+ theNode = parent.add(new CoSENode(this.graphManager));
427
+ }
428
+ // Attach id to the layout node and repulsion value
429
+ theNode.id = theChild.data("id");
430
+ theNode.nodeRepulsion = optFn(options.nodeRepulsion, theChild);
431
+ // Attach the paddings of cy node to layout node
432
+ theNode.paddingLeft = parseInt(theChild.css('padding'));
433
+ theNode.paddingTop = parseInt(theChild.css('padding'));
434
+ theNode.paddingRight = parseInt(theChild.css('padding'));
435
+ theNode.paddingBottom = parseInt(theChild.css('padding'));
436
+
437
+ //Attach the label properties to both compound and simple nodes if labels will be included in node dimensions
438
+ //These properties will be used while updating bounds of compounds during iterations or tiling
439
+ //and will be used for simple nodes while transferring final positions to cytoscape
440
+ if (options.nodeDimensionsIncludeLabels) {
441
+ theNode.labelWidth = theChild.boundingBox({ includeLabels: true, includeNodes: false, includeOverlays: false }).w;
442
+ theNode.labelHeight = theChild.boundingBox({ includeLabels: true, includeNodes: false, includeOverlays: false }).h;
443
+ theNode.labelPosVertical = theChild.css("text-valign");
444
+ theNode.labelPosHorizontal = theChild.css("text-halign");
445
+ }
446
+
447
+ // Map the layout node
448
+ idToLNode[theChild.data("id")] = theNode;
449
+
450
+ if (isNaN(theNode.rect.x)) {
451
+ theNode.rect.x = 0;
452
+ }
453
+
454
+ if (isNaN(theNode.rect.y)) {
455
+ theNode.rect.y = 0;
456
+ }
457
+
458
+ if (children_of_children != null && children_of_children.length > 0) {
459
+ var theNewGraph = void 0;
460
+ theNewGraph = layout.getGraphManager().add(layout.newGraph(), theNode);
461
+ processChildrenList(theNewGraph, children_of_children, layout, options);
462
+ }
463
+ }
464
+ };
465
+
466
+ // transfer cytoscape edges to cose edges
467
+ var processEdges = function processEdges(layout, gm, edges) {
468
+ var idealLengthTotal = 0;
469
+ var edgeCount = 0;
470
+ for (var i = 0; i < edges.length; i++) {
471
+ var edge = edges[i];
472
+ var sourceNode = idToLNode[edge.data("source")];
473
+ var targetNode = idToLNode[edge.data("target")];
474
+ if (sourceNode && targetNode && sourceNode !== targetNode && sourceNode.getEdgesBetween(targetNode).length == 0) {
475
+ var e1 = gm.add(layout.newEdge(), sourceNode, targetNode);
476
+ e1.id = edge.id();
477
+ e1.idealLength = optFn(options.idealEdgeLength, edge);
478
+ e1.edgeElasticity = optFn(options.edgeElasticity, edge);
479
+ idealLengthTotal += e1.idealLength;
480
+ edgeCount++;
481
+ }
482
+ }
483
+ // we need to update the ideal edge length constant with the avg. ideal length value after processing edges
484
+ // in case there is no edge, use other options
485
+ if (options.idealEdgeLength != null) {
486
+ if (edgeCount > 0) CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = idealLengthTotal / edgeCount;else if (!isFn(options.idealEdgeLength)) // in case there is no edge, but option gives a value to use
487
+ CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = options.idealEdgeLength;else // in case there is no edge and we cannot get a value from option (because it's a function)
488
+ CoSEConstants.DEFAULT_EDGE_LENGTH = FDLayoutConstants.DEFAULT_EDGE_LENGTH = 50;
489
+ // we need to update these constant values based on the ideal edge length constant
490
+ CoSEConstants.MIN_REPULSION_DIST = FDLayoutConstants.MIN_REPULSION_DIST = FDLayoutConstants.DEFAULT_EDGE_LENGTH / 10.0;
491
+ CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
492
+ }
493
+ };
494
+
495
+ // transfer cytoscape constraints to cose layout
496
+ var processConstraints = function processConstraints(layout, options) {
497
+ // get nodes to be fixed
498
+ if (options.fixedNodeConstraint) {
499
+ layout.constraints["fixedNodeConstraint"] = options.fixedNodeConstraint;
500
+ }
501
+ // get nodes to be aligned
502
+ if (options.alignmentConstraint) {
503
+ layout.constraints["alignmentConstraint"] = options.alignmentConstraint;
504
+ }
505
+ // get nodes to be relatively placed
506
+ if (options.relativePlacementConstraint) {
507
+ layout.constraints["relativePlacementConstraint"] = options.relativePlacementConstraint;
508
+ }
509
+ };
510
+
511
+ /**** Apply postprocessing ****/
512
+ if (options.nestingFactor != null) CoSEConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = FDLayoutConstants.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR = options.nestingFactor;
513
+ if (options.gravity != null) CoSEConstants.DEFAULT_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH = options.gravity;
514
+ if (options.numIter != null) CoSEConstants.MAX_ITERATIONS = FDLayoutConstants.MAX_ITERATIONS = options.numIter;
515
+ if (options.gravityRange != null) CoSEConstants.DEFAULT_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR = options.gravityRange;
516
+ if (options.gravityCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH = options.gravityCompound;
517
+ if (options.gravityRangeCompound != null) CoSEConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR = options.gravityRangeCompound;
518
+ if (options.initialEnergyOnIncremental != null) CoSEConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL = options.initialEnergyOnIncremental;
519
+
520
+ if (options.tilingCompareBy != null) CoSEConstants.TILING_COMPARE_BY = options.tilingCompareBy;
521
+
522
+ if (options.quality == 'proof') LayoutConstants.QUALITY = 2;else LayoutConstants.QUALITY = 0;
523
+
524
+ CoSEConstants.NODE_DIMENSIONS_INCLUDE_LABELS = FDLayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = LayoutConstants.NODE_DIMENSIONS_INCLUDE_LABELS = options.nodeDimensionsIncludeLabels;
525
+ CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = !options.randomize;
526
+ CoSEConstants.ANIMATE = FDLayoutConstants.ANIMATE = LayoutConstants.ANIMATE = options.animate;
527
+ CoSEConstants.TILE = options.tile;
528
+ CoSEConstants.TILING_PADDING_VERTICAL = typeof options.tilingPaddingVertical === 'function' ? options.tilingPaddingVertical.call() : options.tilingPaddingVertical;
529
+ CoSEConstants.TILING_PADDING_HORIZONTAL = typeof options.tilingPaddingHorizontal === 'function' ? options.tilingPaddingHorizontal.call() : options.tilingPaddingHorizontal;
530
+
531
+ CoSEConstants.DEFAULT_INCREMENTAL = FDLayoutConstants.DEFAULT_INCREMENTAL = LayoutConstants.DEFAULT_INCREMENTAL = true;
532
+ CoSEConstants.PURE_INCREMENTAL = !options.randomize;
533
+ LayoutConstants.DEFAULT_UNIFORM_LEAF_NODE_SIZES = options.uniformNodeDimensions;
534
+
535
+ // This part is for debug/demo purpose
536
+ if (options.step == "transformed") {
537
+ CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = true;
538
+ CoSEConstants.ENFORCE_CONSTRAINTS = false;
539
+ CoSEConstants.APPLY_LAYOUT = false;
540
+ }
541
+ if (options.step == "enforced") {
542
+ CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false;
543
+ CoSEConstants.ENFORCE_CONSTRAINTS = true;
544
+ CoSEConstants.APPLY_LAYOUT = false;
545
+ }
546
+ if (options.step == "cose") {
547
+ CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false;
548
+ CoSEConstants.ENFORCE_CONSTRAINTS = false;
549
+ CoSEConstants.APPLY_LAYOUT = true;
550
+ }
551
+ if (options.step == "all") {
552
+ if (options.randomize) CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = true;else CoSEConstants.TRANSFORM_ON_CONSTRAINT_HANDLING = false;
553
+ CoSEConstants.ENFORCE_CONSTRAINTS = true;
554
+ CoSEConstants.APPLY_LAYOUT = true;
555
+ }
556
+
557
+ if (options.fixedNodeConstraint || options.alignmentConstraint || options.relativePlacementConstraint) {
558
+ CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false;
559
+ } else {
560
+ CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = true;
561
+ }
562
+
563
+ var coseLayout = new CoSELayout();
564
+ var gm = coseLayout.newGraphManager();
565
+
566
+ processChildrenList(gm.addRoot(), aux.getTopMostNodes(nodes), coseLayout, options);
567
+ processEdges(coseLayout, gm, edges);
568
+ processConstraints(coseLayout, options);
569
+
570
+ coseLayout.runLayout();
571
+
572
+ return idToLNode;
573
+ };
574
+
575
+ module.exports = { coseLayout: coseLayout };
576
+
577
+ /***/ }),
578
+
579
+ /***/ 212:
580
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
581
+
582
+
583
+
584
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
585
+
586
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
587
+
588
+ /**
589
+ The implementation of the fcose layout algorithm
590
+ */
591
+
592
+ var assign = __webpack_require__(658);
593
+ var aux = __webpack_require__(548);
594
+
595
+ var _require = __webpack_require__(657),
596
+ spectralLayout = _require.spectralLayout;
597
+
598
+ var _require2 = __webpack_require__(816),
599
+ coseLayout = _require2.coseLayout;
600
+
601
+ var defaults = Object.freeze({
602
+
603
+ // 'draft', 'default' or 'proof'
604
+ // - 'draft' only applies spectral layout
605
+ // - 'default' improves the quality with subsequent CoSE layout (fast cooling rate)
606
+ // - 'proof' improves the quality with subsequent CoSE layout (slow cooling rate)
607
+ quality: "default",
608
+ // Use random node positions at beginning of layout
609
+ // if this is set to false, then quality option must be "proof"
610
+ randomize: true,
611
+ // Whether or not to animate the layout
612
+ animate: true,
613
+ // Duration of animation in ms, if enabled
614
+ animationDuration: 1000,
615
+ // Easing of animation, if enabled
616
+ animationEasing: undefined,
617
+ // Fit the viewport to the repositioned nodes
618
+ fit: true,
619
+ // Padding around layout
620
+ padding: 30,
621
+ // Whether to include labels in node dimensions. Valid in "proof" quality
622
+ nodeDimensionsIncludeLabels: false,
623
+ // Whether or not simple nodes (non-compound nodes) are of uniform dimensions
624
+ uniformNodeDimensions: false,
625
+ // Whether to pack disconnected components - valid only if randomize: true
626
+ packComponents: true,
627
+ // Layout step - all, transformed, enforced, cose - for debug purpose only
628
+ step: "all",
629
+
630
+ /* spectral layout options */
631
+
632
+ // False for random, true for greedy
633
+ samplingType: true,
634
+ // Sample size to construct distance matrix
635
+ sampleSize: 25,
636
+ // Separation amount between nodes
637
+ nodeSeparation: 75,
638
+ // Power iteration tolerance
639
+ piTol: 0.0000001,
640
+
641
+ /* CoSE layout options */
642
+
643
+ // Node repulsion (non overlapping) multiplier
644
+ nodeRepulsion: function nodeRepulsion(node) {
645
+ return 4500;
646
+ },
647
+ // Ideal edge (non nested) length
648
+ idealEdgeLength: function idealEdgeLength(edge) {
649
+ return 50;
650
+ },
651
+ // Divisor to compute edge forces
652
+ edgeElasticity: function edgeElasticity(edge) {
653
+ return 0.45;
654
+ },
655
+ // Nesting factor (multiplier) to compute ideal edge length for nested edges
656
+ nestingFactor: 0.1,
657
+ // Gravity force (constant)
658
+ gravity: 0.25,
659
+ // Maximum number of iterations to perform
660
+ numIter: 2500,
661
+ // For enabling tiling
662
+ tile: true,
663
+ // The function that specifies the criteria for comparing nodes while sorting them during tiling operation.
664
+ // Takes the node id as a parameter and the default tiling operation is perfomed when this option is not set.
665
+ tilingCompareBy: undefined,
666
+ // Represents the amount of the vertical space to put between the zero degree members during the tiling operation(can also be a function)
667
+ tilingPaddingVertical: 10,
668
+ // Represents the amount of the horizontal space to put between the zero degree members during the tiling operation(can also be a function)
669
+ tilingPaddingHorizontal: 10,
670
+ // Gravity range (constant) for compounds
671
+ gravityRangeCompound: 1.5,
672
+ // Gravity force (constant) for compounds
673
+ gravityCompound: 1.0,
674
+ // Gravity range (constant)
675
+ gravityRange: 3.8,
676
+ // Initial cooling factor for incremental layout
677
+ initialEnergyOnIncremental: 0.3,
678
+
679
+ /* constraint options */
680
+
681
+ // Fix required nodes to predefined positions
682
+ // [{nodeId: 'n1', position: {x: 100, y: 200}, {...}]
683
+ fixedNodeConstraint: undefined,
684
+ // Align required nodes in vertical/horizontal direction
685
+ // {vertical: [['n1', 'n2')], ['n3', 'n4']], horizontal: ['n2', 'n4']}
686
+ alignmentConstraint: undefined,
687
+ // Place two nodes relatively in vertical/horizontal direction
688
+ // [{top: 'n1', bottom: 'n2', gap: 100}, {left: 'n3', right: 'n4', gap: 75}]
689
+ relativePlacementConstraint: undefined,
690
+
691
+ /* layout event callbacks */
692
+ ready: function ready() {}, // on layoutready
693
+ stop: function stop() {} // on layoutstop
694
+ });
695
+
696
+ var Layout = function () {
697
+ function Layout(options) {
698
+ _classCallCheck(this, Layout);
699
+
700
+ this.options = assign({}, defaults, options);
701
+ }
702
+
703
+ _createClass(Layout, [{
704
+ key: 'run',
705
+ value: function run() {
706
+ var layout = this;
707
+ var options = this.options;
708
+ var cy = options.cy;
709
+ var eles = options.eles;
710
+
711
+ var spectralResult = [];
712
+ var xCoords = void 0;
713
+ var yCoords = void 0;
714
+ var coseResult = [];
715
+ var components = void 0;
716
+ var componentCenters = [];
717
+
718
+ // basic validity check for constraint inputs
719
+ if (options.fixedNodeConstraint && (!Array.isArray(options.fixedNodeConstraint) || options.fixedNodeConstraint.length == 0)) {
720
+ options.fixedNodeConstraint = undefined;
721
+ }
722
+
723
+ if (options.alignmentConstraint) {
724
+ if (options.alignmentConstraint.vertical && (!Array.isArray(options.alignmentConstraint.vertical) || options.alignmentConstraint.vertical.length == 0)) {
725
+ options.alignmentConstraint.vertical = undefined;
726
+ }
727
+ if (options.alignmentConstraint.horizontal && (!Array.isArray(options.alignmentConstraint.horizontal) || options.alignmentConstraint.horizontal.length == 0)) {
728
+ options.alignmentConstraint.horizontal = undefined;
729
+ }
730
+ }
731
+
732
+ if (options.relativePlacementConstraint && (!Array.isArray(options.relativePlacementConstraint) || options.relativePlacementConstraint.length == 0)) {
733
+ options.relativePlacementConstraint = undefined;
734
+ }
735
+
736
+ // if any constraint exists, set some options
737
+ var constraintExist = options.fixedNodeConstraint || options.alignmentConstraint || options.relativePlacementConstraint;
738
+ if (constraintExist) {
739
+ // constraints work with these options
740
+ options.tile = false;
741
+ options.packComponents = false;
742
+ }
743
+
744
+ // decide component packing is enabled or not
745
+ var layUtil = void 0;
746
+ var packingEnabled = false;
747
+ if (cy.layoutUtilities && options.packComponents) {
748
+ layUtil = cy.layoutUtilities("get");
749
+ if (!layUtil) layUtil = cy.layoutUtilities();
750
+ packingEnabled = true;
751
+ }
752
+
753
+ if (eles.nodes().length > 0) {
754
+ // if packing is not enabled, perform layout on the whole graph
755
+ if (!packingEnabled) {
756
+ // store component center
757
+ var boundingBox = options.eles.boundingBox();
758
+ componentCenters.push({ x: boundingBox.x1 + boundingBox.w / 2, y: boundingBox.y1 + boundingBox.h / 2 });
759
+ // apply spectral layout
760
+ if (options.randomize) {
761
+ var result = spectralLayout(options);
762
+ spectralResult.push(result);
763
+ }
764
+ // apply cose layout as postprocessing
765
+ if (options.quality == "default" || options.quality == "proof") {
766
+ coseResult.push(coseLayout(options, spectralResult[0]));
767
+ aux.relocateComponent(componentCenters[0], coseResult[0], options); // relocate center to original position
768
+ } else {
769
+ aux.relocateComponent(componentCenters[0], spectralResult[0], options); // relocate center to original position
770
+ }
771
+ } else {
772
+ // packing is enabled
773
+ var topMostNodes = aux.getTopMostNodes(options.eles.nodes());
774
+ components = aux.connectComponents(cy, options.eles, topMostNodes);
775
+ // store component centers
776
+ components.forEach(function (component) {
777
+ var boundingBox = component.boundingBox();
778
+ componentCenters.push({ x: boundingBox.x1 + boundingBox.w / 2, y: boundingBox.y1 + boundingBox.h / 2 });
779
+ });
780
+
781
+ //send each component to spectral layout if randomized
782
+ if (options.randomize) {
783
+ components.forEach(function (component) {
784
+ options.eles = component;
785
+ spectralResult.push(spectralLayout(options));
786
+ });
787
+ }
788
+
789
+ if (options.quality == "default" || options.quality == "proof") {
790
+ var toBeTiledNodes = cy.collection();
791
+ if (options.tile) {
792
+ // behave nodes to be tiled as one component
793
+ var nodeIndexes = new Map();
794
+ var _xCoords = [];
795
+ var _yCoords = [];
796
+ var count = 0;
797
+ var tempSpectralResult = { nodeIndexes: nodeIndexes, xCoords: _xCoords, yCoords: _yCoords };
798
+ var indexesToBeDeleted = [];
799
+ components.forEach(function (component, index) {
800
+ if (component.edges().length == 0) {
801
+ component.nodes().forEach(function (node, i) {
802
+ toBeTiledNodes.merge(component.nodes()[i]);
803
+ if (!node.isParent()) {
804
+ tempSpectralResult.nodeIndexes.set(component.nodes()[i].id(), count++);
805
+ tempSpectralResult.xCoords.push(component.nodes()[0].position().x);
806
+ tempSpectralResult.yCoords.push(component.nodes()[0].position().y);
807
+ }
808
+ });
809
+ indexesToBeDeleted.push(index);
810
+ }
811
+ });
812
+ if (toBeTiledNodes.length > 1) {
813
+ var _boundingBox = toBeTiledNodes.boundingBox();
814
+ componentCenters.push({ x: _boundingBox.x1 + _boundingBox.w / 2, y: _boundingBox.y1 + _boundingBox.h / 2 });
815
+ components.push(toBeTiledNodes);
816
+ spectralResult.push(tempSpectralResult);
817
+ for (var i = indexesToBeDeleted.length - 1; i >= 0; i--) {
818
+ components.splice(indexesToBeDeleted[i], 1);
819
+ spectralResult.splice(indexesToBeDeleted[i], 1);
820
+ componentCenters.splice(indexesToBeDeleted[i], 1);
821
+ };
822
+ }
823
+ }
824
+ components.forEach(function (component, index) {
825
+ // send each component to cose layout
826
+ options.eles = component;
827
+ coseResult.push(coseLayout(options, spectralResult[index]));
828
+ aux.relocateComponent(componentCenters[index], coseResult[index], options); // relocate center to original position
829
+ });
830
+ } else {
831
+ components.forEach(function (component, index) {
832
+ aux.relocateComponent(componentCenters[index], spectralResult[index], options); // relocate center to original position
833
+ });
834
+ }
835
+
836
+ // packing
837
+ var componentsEvaluated = new Set();
838
+ if (components.length > 1) {
839
+ var subgraphs = [];
840
+ var hiddenEles = eles.filter(function (ele) {
841
+ return ele.css('display') == 'none';
842
+ });
843
+ components.forEach(function (component, index) {
844
+ var nodeIndexes = void 0;
845
+ if (options.quality == "draft") {
846
+ nodeIndexes = spectralResult[index].nodeIndexes;
847
+ }
848
+
849
+ if (component.nodes().not(hiddenEles).length > 0) {
850
+ var subgraph = {};
851
+ subgraph.edges = [];
852
+ subgraph.nodes = [];
853
+ var nodeIndex = void 0;
854
+ component.nodes().not(hiddenEles).forEach(function (node) {
855
+ if (options.quality == "draft") {
856
+ if (!node.isParent()) {
857
+ nodeIndex = nodeIndexes.get(node.id());
858
+ subgraph.nodes.push({ x: spectralResult[index].xCoords[nodeIndex] - node.boundingbox().w / 2, y: spectralResult[index].yCoords[nodeIndex] - node.boundingbox().h / 2, width: node.boundingbox().w, height: node.boundingbox().h });
859
+ } else {
860
+ var parentInfo = aux.calcBoundingBox(node, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
861
+ subgraph.nodes.push({ x: parentInfo.topLeftX, y: parentInfo.topLeftY, width: parentInfo.width, height: parentInfo.height });
862
+ }
863
+ } else {
864
+ if (coseResult[index][node.id()]) {
865
+ subgraph.nodes.push({ x: coseResult[index][node.id()].getLeft(), y: coseResult[index][node.id()].getTop(), width: coseResult[index][node.id()].getWidth(), height: coseResult[index][node.id()].getHeight() });
866
+ }
867
+ }
868
+ });
869
+ component.edges().forEach(function (edge) {
870
+ var source = edge.source();
871
+ var target = edge.target();
872
+ if (source.css("display") != "none" && target.css("display") != "none") {
873
+ if (options.quality == "draft") {
874
+ var sourceNodeIndex = nodeIndexes.get(source.id());
875
+ var targetNodeIndex = nodeIndexes.get(target.id());
876
+ var sourceCenter = [];
877
+ var targetCenter = [];
878
+ if (source.isParent()) {
879
+ var parentInfo = aux.calcBoundingBox(source, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
880
+ sourceCenter.push(parentInfo.topLeftX + parentInfo.width / 2);
881
+ sourceCenter.push(parentInfo.topLeftY + parentInfo.height / 2);
882
+ } else {
883
+ sourceCenter.push(spectralResult[index].xCoords[sourceNodeIndex]);
884
+ sourceCenter.push(spectralResult[index].yCoords[sourceNodeIndex]);
885
+ }
886
+ if (target.isParent()) {
887
+ var _parentInfo = aux.calcBoundingBox(target, spectralResult[index].xCoords, spectralResult[index].yCoords, nodeIndexes);
888
+ targetCenter.push(_parentInfo.topLeftX + _parentInfo.width / 2);
889
+ targetCenter.push(_parentInfo.topLeftY + _parentInfo.height / 2);
890
+ } else {
891
+ targetCenter.push(spectralResult[index].xCoords[targetNodeIndex]);
892
+ targetCenter.push(spectralResult[index].yCoords[targetNodeIndex]);
893
+ }
894
+ subgraph.edges.push({ startX: sourceCenter[0], startY: sourceCenter[1], endX: targetCenter[0], endY: targetCenter[1] });
895
+ } else {
896
+ if (coseResult[index][source.id()] && coseResult[index][target.id()]) {
897
+ subgraph.edges.push({ startX: coseResult[index][source.id()].getCenterX(), startY: coseResult[index][source.id()].getCenterY(), endX: coseResult[index][target.id()].getCenterX(), endY: coseResult[index][target.id()].getCenterY() });
898
+ }
899
+ }
900
+ }
901
+ });
902
+ if (subgraph.nodes.length > 0) {
903
+ subgraphs.push(subgraph);
904
+ componentsEvaluated.add(index);
905
+ }
906
+ }
907
+ });
908
+ var shiftResult = layUtil.packComponents(subgraphs, options.randomize).shifts;
909
+ if (options.quality == "draft") {
910
+ spectralResult.forEach(function (result, index) {
911
+ var newXCoords = result.xCoords.map(function (x) {
912
+ return x + shiftResult[index].dx;
913
+ });
914
+ var newYCoords = result.yCoords.map(function (y) {
915
+ return y + shiftResult[index].dy;
916
+ });
917
+ result.xCoords = newXCoords;
918
+ result.yCoords = newYCoords;
919
+ });
920
+ } else {
921
+ var _count = 0;
922
+ componentsEvaluated.forEach(function (index) {
923
+ Object.keys(coseResult[index]).forEach(function (item) {
924
+ var nodeRectangle = coseResult[index][item];
925
+ nodeRectangle.setCenter(nodeRectangle.getCenterX() + shiftResult[_count].dx, nodeRectangle.getCenterY() + shiftResult[_count].dy);
926
+ });
927
+ _count++;
928
+ });
929
+ }
930
+ }
931
+ }
932
+ }
933
+
934
+ // get each element's calculated position
935
+ var getPositions = function getPositions(ele, i) {
936
+ if (options.quality == "default" || options.quality == "proof") {
937
+ if (typeof ele === "number") {
938
+ ele = i;
939
+ }
940
+ var pos = void 0;
941
+ var node = void 0;
942
+ var theId = ele.data('id');
943
+ coseResult.forEach(function (result) {
944
+ if (theId in result) {
945
+ pos = { x: result[theId].getRect().getCenterX(), y: result[theId].getRect().getCenterY() };
946
+ node = result[theId];
947
+ }
948
+ });
949
+ if (options.nodeDimensionsIncludeLabels) {
950
+ if (node.labelWidth) {
951
+ if (node.labelPosHorizontal == "left") {
952
+ pos.x += node.labelWidth / 2;
953
+ } else if (node.labelPosHorizontal == "right") {
954
+ pos.x -= node.labelWidth / 2;
955
+ }
956
+ }
957
+ if (node.labelHeight) {
958
+ if (node.labelPosVertical == "top") {
959
+ pos.y += node.labelHeight / 2;
960
+ } else if (node.labelPosVertical == "bottom") {
961
+ pos.y -= node.labelHeight / 2;
962
+ }
963
+ }
964
+ }
965
+ if (pos == undefined) pos = { x: ele.position("x"), y: ele.position("y") };
966
+ return {
967
+ x: pos.x,
968
+ y: pos.y
969
+ };
970
+ } else {
971
+ var _pos = void 0;
972
+ spectralResult.forEach(function (result) {
973
+ var index = result.nodeIndexes.get(ele.id());
974
+ if (index != undefined) {
975
+ _pos = { x: result.xCoords[index], y: result.yCoords[index] };
976
+ }
977
+ });
978
+ if (_pos == undefined) _pos = { x: ele.position("x"), y: ele.position("y") };
979
+ return {
980
+ x: _pos.x,
981
+ y: _pos.y
982
+ };
983
+ }
984
+ };
985
+
986
+ // quality = "draft" and randomize = false are contradictive so in that case positions don't change
987
+ if (options.quality == "default" || options.quality == "proof" || options.randomize) {
988
+ // transfer calculated positions to nodes (positions of only simple nodes are evaluated, compounds are positioned automatically)
989
+ var parentsWithoutChildren = aux.calcParentsWithoutChildren(cy, eles);
990
+ var _hiddenEles = eles.filter(function (ele) {
991
+ return ele.css('display') == 'none';
992
+ });
993
+ options.eles = eles.not(_hiddenEles);
994
+
995
+ eles.nodes().not(":parent").not(_hiddenEles).layoutPositions(layout, options, getPositions);
996
+
997
+ if (parentsWithoutChildren.length > 0) {
998
+ parentsWithoutChildren.forEach(function (ele) {
999
+ ele.position(getPositions(ele));
1000
+ });
1001
+ }
1002
+ } else {
1003
+ console.log("If randomize option is set to false, then quality option must be 'default' or 'proof'.");
1004
+ }
1005
+ }
1006
+ }]);
1007
+
1008
+ return Layout;
1009
+ }();
1010
+
1011
+ module.exports = Layout;
1012
+
1013
+ /***/ }),
1014
+
1015
+ /***/ 657:
1016
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1017
+
1018
+
1019
+
1020
+ /**
1021
+ The implementation of the spectral layout that is the first part of the fcose layout algorithm
1022
+ */
1023
+
1024
+ var aux = __webpack_require__(548);
1025
+ var Matrix = __webpack_require__(140).layoutBase.Matrix;
1026
+ var SVD = __webpack_require__(140).layoutBase.SVD;
1027
+
1028
+ // main function that spectral layout is processed
1029
+ var spectralLayout = function spectralLayout(options) {
1030
+
1031
+ var cy = options.cy;
1032
+ var eles = options.eles;
1033
+ var nodes = eles.nodes();
1034
+ var parentNodes = eles.nodes(":parent");
1035
+
1036
+ var dummyNodes = new Map(); // map to keep dummy nodes and their neighbors
1037
+ var nodeIndexes = new Map(); // map to keep indexes to nodes
1038
+ var parentChildMap = new Map(); // mapping btw. compound and its representative node
1039
+ var allNodesNeighborhood = []; // array to keep neighborhood of all nodes
1040
+ var xCoords = [];
1041
+ var yCoords = [];
1042
+
1043
+ var samplesColumn = []; // sampled vertices
1044
+ var minDistancesColumn = [];
1045
+ var C = []; // column sampling matrix
1046
+ var PHI = []; // intersection of column and row sampling matrices
1047
+ var INV = []; // inverse of PHI
1048
+
1049
+ var firstSample = void 0; // the first sampled node
1050
+ var nodeSize = void 0;
1051
+
1052
+ var infinity = 100000000;
1053
+ var small = 0.000000001;
1054
+
1055
+ var piTol = options.piTol;
1056
+ var samplingType = options.samplingType; // false for random, true for greedy
1057
+ var nodeSeparation = options.nodeSeparation;
1058
+ var sampleSize = void 0;
1059
+
1060
+ /**** Spectral-preprocessing functions ****/
1061
+
1062
+ /**** Spectral layout functions ****/
1063
+
1064
+ // determine which columns to be sampled
1065
+ var randomSampleCR = function randomSampleCR() {
1066
+ var sample = 0;
1067
+ var count = 0;
1068
+ var flag = false;
1069
+
1070
+ while (count < sampleSize) {
1071
+ sample = Math.floor(Math.random() * nodeSize);
1072
+
1073
+ flag = false;
1074
+ for (var i = 0; i < count; i++) {
1075
+ if (samplesColumn[i] == sample) {
1076
+ flag = true;
1077
+ break;
1078
+ }
1079
+ }
1080
+
1081
+ if (!flag) {
1082
+ samplesColumn[count] = sample;
1083
+ count++;
1084
+ } else {
1085
+ continue;
1086
+ }
1087
+ }
1088
+ };
1089
+
1090
+ // takes the index of the node(pivot) to initiate BFS as a parameter
1091
+ var BFS = function BFS(pivot, index, samplingMethod) {
1092
+ var path = []; // the front of the path
1093
+ var front = 0; // the back of the path
1094
+ var back = 0;
1095
+ var current = 0;
1096
+ var temp = void 0;
1097
+ var distance = [];
1098
+
1099
+ var max_dist = 0; // the furthest node to be returned
1100
+ var max_ind = 1;
1101
+
1102
+ for (var i = 0; i < nodeSize; i++) {
1103
+ distance[i] = infinity;
1104
+ }
1105
+
1106
+ path[back] = pivot;
1107
+ distance[pivot] = 0;
1108
+
1109
+ while (back >= front) {
1110
+ current = path[front++];
1111
+ var neighbors = allNodesNeighborhood[current];
1112
+ for (var _i = 0; _i < neighbors.length; _i++) {
1113
+ temp = nodeIndexes.get(neighbors[_i]);
1114
+ if (distance[temp] == infinity) {
1115
+ distance[temp] = distance[current] + 1;
1116
+ path[++back] = temp;
1117
+ }
1118
+ }
1119
+ C[current][index] = distance[current] * nodeSeparation;
1120
+ }
1121
+
1122
+ if (samplingMethod) {
1123
+ for (var _i2 = 0; _i2 < nodeSize; _i2++) {
1124
+ if (C[_i2][index] < minDistancesColumn[_i2]) minDistancesColumn[_i2] = C[_i2][index];
1125
+ }
1126
+
1127
+ for (var _i3 = 0; _i3 < nodeSize; _i3++) {
1128
+ if (minDistancesColumn[_i3] > max_dist) {
1129
+ max_dist = minDistancesColumn[_i3];
1130
+ max_ind = _i3;
1131
+ }
1132
+ }
1133
+ }
1134
+ return max_ind;
1135
+ };
1136
+
1137
+ // apply BFS to all nodes or selected samples
1138
+ var allBFS = function allBFS(samplingMethod) {
1139
+
1140
+ var sample = void 0;
1141
+
1142
+ if (!samplingMethod) {
1143
+ randomSampleCR();
1144
+
1145
+ // call BFS
1146
+ for (var i = 0; i < sampleSize; i++) {
1147
+ BFS(samplesColumn[i], i, samplingMethod, false);
1148
+ }
1149
+ } else {
1150
+ sample = Math.floor(Math.random() * nodeSize);
1151
+ firstSample = sample;
1152
+
1153
+ for (var _i4 = 0; _i4 < nodeSize; _i4++) {
1154
+ minDistancesColumn[_i4] = infinity;
1155
+ }
1156
+
1157
+ for (var _i5 = 0; _i5 < sampleSize; _i5++) {
1158
+ samplesColumn[_i5] = sample;
1159
+ sample = BFS(sample, _i5, samplingMethod);
1160
+ }
1161
+ }
1162
+
1163
+ // form the squared distances for C
1164
+ for (var _i6 = 0; _i6 < nodeSize; _i6++) {
1165
+ for (var j = 0; j < sampleSize; j++) {
1166
+ C[_i6][j] *= C[_i6][j];
1167
+ }
1168
+ }
1169
+
1170
+ // form PHI
1171
+ for (var _i7 = 0; _i7 < sampleSize; _i7++) {
1172
+ PHI[_i7] = [];
1173
+ }
1174
+
1175
+ for (var _i8 = 0; _i8 < sampleSize; _i8++) {
1176
+ for (var _j = 0; _j < sampleSize; _j++) {
1177
+ PHI[_i8][_j] = C[samplesColumn[_j]][_i8];
1178
+ }
1179
+ }
1180
+ };
1181
+
1182
+ // perform the SVD algorithm and apply a regularization step
1183
+ var sample = function sample() {
1184
+
1185
+ var SVDResult = SVD.svd(PHI);
1186
+
1187
+ var a_q = SVDResult.S;
1188
+ var a_u = SVDResult.U;
1189
+ var a_v = SVDResult.V;
1190
+
1191
+ var max_s = a_q[0] * a_q[0] * a_q[0];
1192
+
1193
+ var a_Sig = [];
1194
+
1195
+ // regularization
1196
+ for (var i = 0; i < sampleSize; i++) {
1197
+ a_Sig[i] = [];
1198
+ for (var j = 0; j < sampleSize; j++) {
1199
+ a_Sig[i][j] = 0;
1200
+ if (i == j) {
1201
+ a_Sig[i][j] = a_q[i] / (a_q[i] * a_q[i] + max_s / (a_q[i] * a_q[i]));
1202
+ }
1203
+ }
1204
+ }
1205
+
1206
+ INV = Matrix.multMat(Matrix.multMat(a_v, a_Sig), Matrix.transpose(a_u));
1207
+ };
1208
+
1209
+ // calculate final coordinates
1210
+ var powerIteration = function powerIteration() {
1211
+ // two largest eigenvalues
1212
+ var theta1 = void 0;
1213
+ var theta2 = void 0;
1214
+
1215
+ // initial guesses for eigenvectors
1216
+ var Y1 = [];
1217
+ var Y2 = [];
1218
+
1219
+ var V1 = [];
1220
+ var V2 = [];
1221
+
1222
+ for (var i = 0; i < nodeSize; i++) {
1223
+ Y1[i] = Math.random();
1224
+ Y2[i] = Math.random();
1225
+ }
1226
+
1227
+ Y1 = Matrix.normalize(Y1);
1228
+ Y2 = Matrix.normalize(Y2);
1229
+
1230
+ var count = 0;
1231
+ // to keep track of the improvement ratio in power iteration
1232
+ var current = small;
1233
+ var previous = small;
1234
+
1235
+ var temp = void 0;
1236
+
1237
+ while (true) {
1238
+ count++;
1239
+
1240
+ for (var _i9 = 0; _i9 < nodeSize; _i9++) {
1241
+ V1[_i9] = Y1[_i9];
1242
+ }
1243
+
1244
+ Y1 = Matrix.multGamma(Matrix.multL(Matrix.multGamma(V1), C, INV));
1245
+ theta1 = Matrix.dotProduct(V1, Y1);
1246
+ Y1 = Matrix.normalize(Y1);
1247
+
1248
+ current = Matrix.dotProduct(V1, Y1);
1249
+
1250
+ temp = Math.abs(current / previous);
1251
+
1252
+ if (temp <= 1 + piTol && temp >= 1) {
1253
+ break;
1254
+ }
1255
+
1256
+ previous = current;
1257
+ }
1258
+
1259
+ for (var _i10 = 0; _i10 < nodeSize; _i10++) {
1260
+ V1[_i10] = Y1[_i10];
1261
+ }
1262
+
1263
+ count = 0;
1264
+ previous = small;
1265
+ while (true) {
1266
+ count++;
1267
+
1268
+ for (var _i11 = 0; _i11 < nodeSize; _i11++) {
1269
+ V2[_i11] = Y2[_i11];
1270
+ }
1271
+
1272
+ V2 = Matrix.minusOp(V2, Matrix.multCons(V1, Matrix.dotProduct(V1, V2)));
1273
+ Y2 = Matrix.multGamma(Matrix.multL(Matrix.multGamma(V2), C, INV));
1274
+ theta2 = Matrix.dotProduct(V2, Y2);
1275
+ Y2 = Matrix.normalize(Y2);
1276
+
1277
+ current = Matrix.dotProduct(V2, Y2);
1278
+
1279
+ temp = Math.abs(current / previous);
1280
+
1281
+ if (temp <= 1 + piTol && temp >= 1) {
1282
+ break;
1283
+ }
1284
+
1285
+ previous = current;
1286
+ }
1287
+
1288
+ for (var _i12 = 0; _i12 < nodeSize; _i12++) {
1289
+ V2[_i12] = Y2[_i12];
1290
+ }
1291
+
1292
+ // theta1 now contains dominant eigenvalue
1293
+ // theta2 now contains the second-largest eigenvalue
1294
+ // V1 now contains theta1's eigenvector
1295
+ // V2 now contains theta2's eigenvector
1296
+
1297
+ //populate the two vectors
1298
+ xCoords = Matrix.multCons(V1, Math.sqrt(Math.abs(theta1)));
1299
+ yCoords = Matrix.multCons(V2, Math.sqrt(Math.abs(theta2)));
1300
+ };
1301
+
1302
+ /**** Preparation for spectral layout (Preprocessing) ****/
1303
+
1304
+ // connect disconnected components (first top level, then inside of each compound node)
1305
+ aux.connectComponents(cy, eles, aux.getTopMostNodes(nodes), dummyNodes);
1306
+
1307
+ parentNodes.forEach(function (ele) {
1308
+ aux.connectComponents(cy, eles, aux.getTopMostNodes(ele.descendants().intersection(eles)), dummyNodes);
1309
+ });
1310
+
1311
+ // assign indexes to nodes (first real, then dummy nodes)
1312
+ var index = 0;
1313
+ for (var i = 0; i < nodes.length; i++) {
1314
+ if (!nodes[i].isParent()) {
1315
+ nodeIndexes.set(nodes[i].id(), index++);
1316
+ }
1317
+ }
1318
+
1319
+ var _iteratorNormalCompletion = true;
1320
+ var _didIteratorError = false;
1321
+ var _iteratorError = undefined;
1322
+
1323
+ try {
1324
+ for (var _iterator = dummyNodes.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1325
+ var key = _step.value;
1326
+
1327
+ nodeIndexes.set(key, index++);
1328
+ }
1329
+
1330
+ // instantiate the neighborhood matrix
1331
+ } catch (err) {
1332
+ _didIteratorError = true;
1333
+ _iteratorError = err;
1334
+ } finally {
1335
+ try {
1336
+ if (!_iteratorNormalCompletion && _iterator.return) {
1337
+ _iterator.return();
1338
+ }
1339
+ } finally {
1340
+ if (_didIteratorError) {
1341
+ throw _iteratorError;
1342
+ }
1343
+ }
1344
+ }
1345
+
1346
+ for (var _i13 = 0; _i13 < nodeIndexes.size; _i13++) {
1347
+ allNodesNeighborhood[_i13] = [];
1348
+ }
1349
+
1350
+ // form a parent-child map to keep representative node of each compound node
1351
+ parentNodes.forEach(function (ele) {
1352
+ var children = ele.children().intersection(eles);
1353
+
1354
+ // let random = 0;
1355
+ while (children.nodes(":childless").length == 0) {
1356
+ // random = Math.floor(Math.random() * children.nodes().length); // if all children are compound then proceed randomly
1357
+ children = children.nodes()[0].children().intersection(eles);
1358
+ }
1359
+ // select the representative node - we can apply different methods here
1360
+ // random = Math.floor(Math.random() * children.nodes(":childless").length);
1361
+ var index = 0;
1362
+ var min = children.nodes(":childless")[0].connectedEdges().length;
1363
+ children.nodes(":childless").forEach(function (ele2, i) {
1364
+ if (ele2.connectedEdges().length < min) {
1365
+ min = ele2.connectedEdges().length;
1366
+ index = i;
1367
+ }
1368
+ });
1369
+ parentChildMap.set(ele.id(), children.nodes(":childless")[index].id());
1370
+ });
1371
+
1372
+ // add neighborhood relations (first real, then dummy nodes)
1373
+ nodes.forEach(function (ele) {
1374
+ var eleIndex = void 0;
1375
+
1376
+ if (ele.isParent()) eleIndex = nodeIndexes.get(parentChildMap.get(ele.id()));else eleIndex = nodeIndexes.get(ele.id());
1377
+
1378
+ ele.neighborhood().nodes().forEach(function (node) {
1379
+ if (eles.intersection(ele.edgesWith(node)).length > 0) {
1380
+ if (node.isParent()) allNodesNeighborhood[eleIndex].push(parentChildMap.get(node.id()));else allNodesNeighborhood[eleIndex].push(node.id());
1381
+ }
1382
+ });
1383
+ });
1384
+
1385
+ var _loop = function _loop(_key) {
1386
+ var eleIndex = nodeIndexes.get(_key);
1387
+ var disconnectedId = void 0;
1388
+ dummyNodes.get(_key).forEach(function (id) {
1389
+ if (cy.getElementById(id).isParent()) disconnectedId = parentChildMap.get(id);else disconnectedId = id;
1390
+
1391
+ allNodesNeighborhood[eleIndex].push(disconnectedId);
1392
+ allNodesNeighborhood[nodeIndexes.get(disconnectedId)].push(_key);
1393
+ });
1394
+ };
1395
+
1396
+ var _iteratorNormalCompletion2 = true;
1397
+ var _didIteratorError2 = false;
1398
+ var _iteratorError2 = undefined;
1399
+
1400
+ try {
1401
+ for (var _iterator2 = dummyNodes.keys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
1402
+ var _key = _step2.value;
1403
+
1404
+ _loop(_key);
1405
+ }
1406
+
1407
+ // nodeSize now only considers the size of transformed graph
1408
+ } catch (err) {
1409
+ _didIteratorError2 = true;
1410
+ _iteratorError2 = err;
1411
+ } finally {
1412
+ try {
1413
+ if (!_iteratorNormalCompletion2 && _iterator2.return) {
1414
+ _iterator2.return();
1415
+ }
1416
+ } finally {
1417
+ if (_didIteratorError2) {
1418
+ throw _iteratorError2;
1419
+ }
1420
+ }
1421
+ }
1422
+
1423
+ nodeSize = nodeIndexes.size;
1424
+
1425
+ var spectralResult = void 0;
1426
+
1427
+ // If number of nodes in transformed graph is 1 or 2, either SVD or powerIteration causes problem
1428
+ // So skip spectral and layout the graph with cose
1429
+ if (nodeSize > 2) {
1430
+ // if # of nodes in transformed graph is smaller than sample size,
1431
+ // then use # of nodes as sample size
1432
+ sampleSize = nodeSize < options.sampleSize ? nodeSize : options.sampleSize;
1433
+
1434
+ // instantiates the partial matrices that will be used in spectral layout
1435
+ for (var _i14 = 0; _i14 < nodeSize; _i14++) {
1436
+ C[_i14] = [];
1437
+ }
1438
+ for (var _i15 = 0; _i15 < sampleSize; _i15++) {
1439
+ INV[_i15] = [];
1440
+ }
1441
+
1442
+ /**** Apply spectral layout ****/
1443
+
1444
+ if (options.quality == "draft" || options.step == "all") {
1445
+ allBFS(samplingType);
1446
+ sample();
1447
+ powerIteration();
1448
+
1449
+ spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords };
1450
+ } else {
1451
+ nodeIndexes.forEach(function (value, key) {
1452
+ xCoords.push(cy.getElementById(key).position("x"));
1453
+ yCoords.push(cy.getElementById(key).position("y"));
1454
+ });
1455
+ spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords };
1456
+ }
1457
+ return spectralResult;
1458
+ } else {
1459
+ var iterator = nodeIndexes.keys();
1460
+ var firstNode = cy.getElementById(iterator.next().value);
1461
+ var firstNodePos = firstNode.position();
1462
+ var firstNodeWidth = firstNode.outerWidth();
1463
+ xCoords.push(firstNodePos.x);
1464
+ yCoords.push(firstNodePos.y);
1465
+ if (nodeSize == 2) {
1466
+ var secondNode = cy.getElementById(iterator.next().value);
1467
+ var secondNodeWidth = secondNode.outerWidth();
1468
+ xCoords.push(firstNodePos.x + firstNodeWidth / 2 + secondNodeWidth / 2 + options.idealEdgeLength);
1469
+ yCoords.push(firstNodePos.y);
1470
+ }
1471
+
1472
+ spectralResult = { nodeIndexes: nodeIndexes, xCoords: xCoords, yCoords: yCoords };
1473
+ return spectralResult;
1474
+ }
1475
+ };
1476
+
1477
+ module.exports = { spectralLayout: spectralLayout };
1478
+
1479
+ /***/ }),
1480
+
1481
+ /***/ 579:
1482
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1483
+
1484
+
1485
+
1486
+ var impl = __webpack_require__(212);
1487
+
1488
+ // registers the extension on a cytoscape lib ref
1489
+ var register = function register(cytoscape) {
1490
+ if (!cytoscape) {
1491
+ return;
1492
+ } // can't register if cytoscape unspecified
1493
+
1494
+ cytoscape('layout', 'fcose', impl); // register with cytoscape.js
1495
+ };
1496
+
1497
+ if (typeof cytoscape !== 'undefined') {
1498
+ // expose to global cytoscape (i.e. window.cytoscape)
1499
+ register(cytoscape);
1500
+ }
1501
+
1502
+ module.exports = register;
1503
+
1504
+ /***/ }),
1505
+
1506
+ /***/ 140:
1507
+ /***/ ((module) => {
1508
+
1509
+ module.exports = __WEBPACK_EXTERNAL_MODULE__140__;
1510
+
1511
+ /***/ })
1512
+
1513
+ /******/ });
1514
+ /************************************************************************/
1515
+ /******/ // The module cache
1516
+ /******/ var __webpack_module_cache__ = {};
1517
+ /******/
1518
+ /******/ // The require function
1519
+ /******/ function __webpack_require__(moduleId) {
1520
+ /******/ // Check if module is in cache
1521
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
1522
+ /******/ if (cachedModule !== undefined) {
1523
+ /******/ return cachedModule.exports;
1524
+ /******/ }
1525
+ /******/ // Create a new module (and put it into the cache)
1526
+ /******/ var module = __webpack_module_cache__[moduleId] = {
1527
+ /******/ // no module.id needed
1528
+ /******/ // no module.loaded needed
1529
+ /******/ exports: {}
1530
+ /******/ };
1531
+ /******/
1532
+ /******/ // Execute the module function
1533
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1534
+ /******/
1535
+ /******/ // Return the exports of the module
1536
+ /******/ return module.exports;
1537
+ /******/ }
1538
+ /******/
1539
+ /************************************************************************/
1540
+ /******/
1541
+ /******/ // startup
1542
+ /******/ // Load entry module and return exports
1543
+ /******/ // This entry module is referenced by other modules so it can't be inlined
1544
+ /******/ var __webpack_exports__ = __webpack_require__(579);
1545
+ /******/
1546
+ /******/ return __webpack_exports__;
1547
+ /******/ })()
1548
+ ;
1549
+ });