@deck.gl-community/graph-layers 9.0.2 → 9.1.0-beta.3

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 (118) hide show
  1. package/LICENSE +1 -1
  2. package/dist/core/graph-engine.d.ts +16 -7
  3. package/dist/core/graph-engine.d.ts.map +1 -1
  4. package/dist/core/graph-engine.js +13 -4
  5. package/dist/core/graph-layout.d.ts +69 -0
  6. package/dist/core/graph-layout.d.ts.map +1 -0
  7. package/dist/core/{base-layout.js → graph-layout.js} +63 -80
  8. package/dist/core/interaction-manager.d.ts +1 -1
  9. package/dist/core/interaction-manager.d.ts.map +1 -1
  10. package/dist/{core → graph}/edge.d.ts +18 -17
  11. package/dist/graph/edge.d.ts.map +1 -0
  12. package/dist/{core → graph}/edge.js +12 -15
  13. package/dist/{core → graph}/graph.d.ts +34 -31
  14. package/dist/graph/graph.d.ts.map +1 -0
  15. package/dist/{core → graph}/graph.js +43 -36
  16. package/dist/{core → graph}/node.d.ts +20 -20
  17. package/dist/graph/node.d.ts.map +1 -0
  18. package/dist/{core → graph}/node.js +16 -18
  19. package/dist/index.cjs +1181 -434
  20. package/dist/index.cjs.map +4 -4
  21. package/dist/index.d.ts +16 -14
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +19 -18
  24. package/dist/layers/graph-layer.d.ts +45 -5
  25. package/dist/layers/graph-layer.d.ts.map +1 -1
  26. package/dist/layers/graph-layer.js +80 -38
  27. package/dist/layers/node-layers/{path-rounded-rectange-layer.d.ts → path-rounded-rectangle-layer.d.ts} +1 -1
  28. package/dist/layers/node-layers/path-rounded-rectangle-layer.d.ts.map +1 -0
  29. package/dist/layers/node-layers/rounded-rectangle-layer-fragment.d.ts +1 -1
  30. package/dist/layers/node-layers/rounded-rectangle-layer-fragment.d.ts.map +1 -1
  31. package/dist/layers/node-layers/rounded-rectangle-layer-fragment.js +1 -3
  32. package/dist/layers/node-layers/rounded-rectangle-layer.d.ts +12 -3
  33. package/dist/layers/node-layers/rounded-rectangle-layer.d.ts.map +1 -1
  34. package/dist/layers/node-layers/rounded-rectangle-layer.js +25 -11
  35. package/dist/layouts/d3-force/d3-force-layout.d.ts +12 -3
  36. package/dist/layouts/d3-force/d3-force-layout.d.ts.map +1 -1
  37. package/dist/layouts/d3-force/d3-force-layout.js +11 -11
  38. package/dist/layouts/d3-force/worker.d.ts.map +1 -1
  39. package/dist/layouts/experimental/force-multi-graph-layout.d.ts +43 -0
  40. package/dist/layouts/experimental/force-multi-graph-layout.d.ts.map +1 -0
  41. package/dist/layouts/experimental/force-multi-graph-layout.js +226 -0
  42. package/dist/layouts/experimental/hive-plot-layout.d.ts +34 -0
  43. package/dist/layouts/experimental/hive-plot-layout.d.ts.map +1 -0
  44. package/dist/layouts/experimental/hive-plot-layout.js +142 -0
  45. package/dist/layouts/experimental/radial-layout.d.ts +28 -0
  46. package/dist/layouts/experimental/radial-layout.d.ts.map +1 -0
  47. package/dist/layouts/experimental/radial-layout.js +164 -0
  48. package/dist/layouts/gpu-force/gpu-force-layout.d.ts +15 -3
  49. package/dist/layouts/gpu-force/gpu-force-layout.d.ts.map +1 -1
  50. package/dist/layouts/gpu-force/gpu-force-layout.js +20 -18
  51. package/dist/layouts/gpu-force/worker.d.ts.map +1 -1
  52. package/dist/layouts/simple-layout.d.ts +42 -0
  53. package/dist/layouts/simple-layout.d.ts.map +1 -0
  54. package/dist/layouts/{simple-layout/simple-layout.js → simple-layout.js} +8 -7
  55. package/dist/loaders/create-graph.d.ts +13 -0
  56. package/dist/loaders/create-graph.d.ts.map +1 -0
  57. package/dist/{utils → loaders}/create-graph.js +9 -4
  58. package/dist/loaders/edge-parsers.d.ts +2 -6
  59. package/dist/loaders/edge-parsers.d.ts.map +1 -1
  60. package/dist/loaders/json-loader.js +1 -1
  61. package/dist/loaders/node-parsers.d.ts +2 -3
  62. package/dist/loaders/node-parsers.d.ts.map +1 -1
  63. package/dist/loaders/simple-json-graph-loader.d.ts +12 -0
  64. package/dist/loaders/simple-json-graph-loader.d.ts.map +1 -0
  65. package/dist/loaders/simple-json-graph-loader.js +20 -0
  66. package/dist/loaders/table-graph-loader.d.ts +17 -0
  67. package/dist/loaders/table-graph-loader.d.ts.map +1 -0
  68. package/dist/loaders/table-graph-loader.js +91 -0
  69. package/dist/utils/log.d.ts +1 -1
  70. package/dist/utils/log.d.ts.map +1 -1
  71. package/dist/utils/log.js +3 -3
  72. package/dist/widgets/long-press-button.d.ts +13 -0
  73. package/dist/widgets/long-press-button.d.ts.map +1 -0
  74. package/dist/widgets/long-press-button.js +31 -0
  75. package/dist/widgets/view-control-widget.d.ts +78 -0
  76. package/dist/widgets/view-control-widget.d.ts.map +1 -0
  77. package/dist/widgets/view-control-widget.js +194 -0
  78. package/package.json +8 -6
  79. package/src/core/graph-engine.ts +30 -10
  80. package/src/core/graph-layout.ts +146 -0
  81. package/src/core/interaction-manager.ts +2 -2
  82. package/src/{core → graph}/edge.ts +19 -17
  83. package/src/{core → graph}/graph.ts +51 -36
  84. package/src/{core → graph}/node.ts +21 -20
  85. package/src/index.ts +28 -28
  86. package/src/layers/graph-layer.ts +133 -46
  87. package/src/layers/node-layers/rounded-rectangle-layer-fragment.ts +1 -3
  88. package/src/layers/node-layers/rounded-rectangle-layer.ts +34 -10
  89. package/src/layouts/d3-force/d3-force-layout.ts +21 -11
  90. package/src/layouts/experimental/force-multi-graph-layout.ts +268 -0
  91. package/src/layouts/experimental/hive-plot-layout.ts +182 -0
  92. package/src/layouts/experimental/radial-layout.ts +210 -0
  93. package/src/layouts/gpu-force/gpu-force-layout.ts +32 -17
  94. package/src/layouts/{simple-layout/simple-layout.ts → simple-layout.ts} +34 -19
  95. package/src/{utils → loaders}/create-graph.ts +9 -4
  96. package/src/loaders/edge-parsers.ts +2 -1
  97. package/src/loaders/json-loader.ts +1 -1
  98. package/src/loaders/node-parsers.ts +2 -1
  99. package/src/loaders/simple-json-graph-loader.ts +28 -0
  100. package/src/loaders/table-graph-loader.ts +124 -0
  101. package/src/utils/log.ts +3 -3
  102. package/src/widgets/long-press-button.tsx +50 -0
  103. package/src/widgets/view-control-widget.tsx +337 -0
  104. package/dist/core/base-layout.d.ts +0 -72
  105. package/dist/core/base-layout.d.ts.map +0 -1
  106. package/dist/core/edge.d.ts.map +0 -1
  107. package/dist/core/graph.d.ts.map +0 -1
  108. package/dist/core/node.d.ts.map +0 -1
  109. package/dist/layers/node-layers/path-rounded-rectange-layer.d.ts.map +0 -1
  110. package/dist/layouts/simple-layout/simple-layout.d.ts +0 -23
  111. package/dist/layouts/simple-layout/simple-layout.d.ts.map +0 -1
  112. package/dist/utils/create-graph.d.ts +0 -9
  113. package/dist/utils/create-graph.d.ts.map +0 -1
  114. package/src/core/base-layout.ts +0 -154
  115. /package/dist/layers/node-layers/{path-rounded-rectange-layer.js → path-rounded-rectangle-layer.js} +0 -0
  116. /package/src/layers/node-layers/{path-rounded-rectange-layer.ts → path-rounded-rectangle-layer.ts} +0 -0
  117. /package/src/layouts/d3-force/{worker.ts → worker.js} +0 -0
  118. /package/src/layouts/gpu-force/{worker.ts → worker.js} +0 -0
@@ -1,5 +1,11 @@
1
1
  import { Edge } from "./edge.js";
2
2
  import { Node } from "./node.js";
3
+ export type GraphProps = {
4
+ name?: string;
5
+ nodes?: Node[];
6
+ edges?: Edge[];
7
+ };
8
+ /** Basic graph data structure */
3
9
  export declare class Graph extends EventTarget {
4
10
  /** List object of nodes. */
5
11
  private _nodeMap;
@@ -14,33 +20,30 @@ export declare class Graph extends EventTarget {
14
20
  version: number;
15
21
  /** Cached data: create array data from maps. */
16
22
  private _cache;
17
- /**
18
- * The constructor of the Graph class.
19
- * @param {Object} graph - copy the graph if this exists.
20
- */
21
- constructor(graph?: Graph | null);
23
+ constructor(props?: GraphProps);
24
+ constructor(graph: Graph);
22
25
  /**
23
26
  * Set graph name
24
- * @param {string} name
27
+ * @param name
25
28
  */
26
29
  setGraphName(name: string): void;
27
30
  /** Get the name of the graph. Default value is the time stamp when creating this graph.
28
- * @return {string} graph name.
31
+ * @return graph name.
29
32
  */
30
33
  getGraphName(): string;
31
34
  /**
32
35
  * Perform a batch of operations defined by cb before indicating graph is updated
33
- * @param {function} cb - a callback fuction containing the operations to perform
36
+ * @param {function} cb - a callback function containing the operations to perform
34
37
  */
35
38
  transaction<T>(cb: (...args: unknown[]) => T): T;
36
39
  /**
37
40
  * Add a new node to the graph.
38
- * @param {Node} node - expect a Node object to be added to the graph.
41
+ * @paramnode - expect a Node object to be added to the graph.
39
42
  */
40
43
  addNode(node: Node): void;
41
44
  /**
42
45
  * Batch add nodes to the graph.
43
- * @param {Node[]} nodes - a list of nodes to be added.
46
+ * @param nodes - a list of nodes to be added.
44
47
  */
45
48
  batchAddNodes(nodes: Node[]): void;
46
49
  /**
@@ -50,48 +53,48 @@ export declare class Graph extends EventTarget {
50
53
  getNodes(): Node[];
51
54
  /**
52
55
  * Get the node map of the graph. The key of the map is the ID of the nodes.
53
- * @return {Object} - a map of nodes keyed by node IDs.
56
+ * @return - a map of nodes keyed by node IDs.
54
57
  */
55
58
  getNodeMap(): Record<string | number, Node>;
56
59
  /**
57
60
  * Find a node by id
58
- * @param {String} nodeId The id of the node
59
- * @return {Object} Node
61
+ * @param nodeId The id of the node
62
+ * @return Node
60
63
  */
61
64
  findNode(nodeId: string | number): Node | undefined;
62
65
  /**
63
66
  * Update the indicated node to the provided value
64
- * @param {Node} node
67
+ * @param node
65
68
  */
66
69
  updateNode(node: Node): void;
67
70
  /**
68
71
  * Add a new edge to the graph.
69
- * @param {Edge} edge - expect a Edge object to be added to the graph.
72
+ * @param edge - expect a Edge object to be added to the graph.
70
73
  */
71
74
  addEdge(edge: Edge): void;
72
75
  /**
73
76
  * Batch add edges to the graph
74
- * @param {Edge[]} edges - a list of edges to be added.
77
+ * @param edges - a list of edges to be added.
75
78
  */
76
79
  batchAddEdges(edges: Edge[]): void;
77
80
  /**
78
81
  * Update the indicated edge to the provided value
79
- * @param {Edge} edge
82
+ * @param edge
80
83
  */
81
84
  updateEdge(edge: Edge): void;
82
85
  /**
83
86
  * Remove a node from the graph by node ID
84
- * @param {String|Number} nodeId - the ID of the target node.
87
+ * @param nodeId - the ID of the target node.
85
88
  */
86
89
  removeNode(nodeId: string | number): void;
87
90
  /**
88
91
  * Get all the edges of the graph.
89
- * @return {Edge[]} get all the edges in the graph.
92
+ * @return get all the edges in the graph.
90
93
  */
91
94
  getEdges(): Edge[];
92
95
  /**
93
96
  * Get the edge map of the graph. The key of the map is the ID of the edges.
94
- * @return {Object} - a map of edges keyed by edge IDs.
97
+ * @return - a map of edges keyed by edge IDs.
95
98
  */
96
99
  getEdgeMap(): Record<string, Edge>;
97
100
  /**
@@ -101,26 +104,26 @@ export declare class Graph extends EventTarget {
101
104
  removeEdge(edgeId: string | number): void;
102
105
  /**
103
106
  * Find the edge by edge ID.
104
- * @param {String|Number} id - the target edge ID
105
- * @return {Edge} - the target edge.
107
+ * @param id - the target edge ID
108
+ * @return - the target edge.
106
109
  */
107
110
  findEdge(edgeId: string | number): Edge;
108
111
  /**
109
112
  * Return all the connected edges of a node by nodeID.
110
- * @param {String|Number} nodeId - the target node ID
111
- * @return {Edge[]} - an array of the connected edges.
113
+ * @param nodeId - the target node ID
114
+ * @return - an array of the connected edges.
112
115
  */
113
116
  getConnectedEdges(nodeId: string | number): Edge[];
114
117
  /**
115
118
  * Return all the sibling nodes of a node by nodeID.
116
- * @param {String|Number} nodeId - the target node ID
117
- * @return {Node[]} - an array of the sibling nodes.
119
+ * @param nodeId - the target node ID
120
+ * @return - an array of the sibling nodes.
118
121
  */
119
122
  getNodeSiblings(nodeId: string | number): Node[];
120
123
  /**
121
124
  * Get the degree of a node.
122
- * @param {String|Number} nodeId - the target node ID.
123
- * @return {Number} - the degree of the node.
125
+ * @param nodeId - the target node ID.
126
+ * @return - the degree of the node.
124
127
  */
125
128
  getDegree(nodeId: string | number): number;
126
129
  /**
@@ -146,10 +149,10 @@ export declare class Graph extends EventTarget {
146
149
  isEmpty(): boolean;
147
150
  /**
148
151
  * Check the equality of two graphs data by checking last update time stamp
149
- * @param {Object} g Another graph to be compared against itself
150
- * @return {Bool} True if the graph is the same as itself.
152
+ * @param graph Another graph to be compared against itself
153
+ * @return true if the graph is the same as itself.
151
154
  */
152
- equals(g: Graph): boolean;
155
+ equals(graph: Graph): boolean;
153
156
  _bumpVersion(): void;
154
157
  _updateCache(key: 'nodes' | 'edges', updateValue: unknown): void;
155
158
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph/graph.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,IAAI,EAAC,kBAAe;AAC5B,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB,CAAC;AAEF,iCAAiC;AACjC,qBAAa,KAAM,SAAQ,WAAW;IACpC,4BAA4B;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,4BAA4B;IAC5B,OAAO,CAAC,QAAQ,CAA4B;IAC5C;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAiC;IAC9C,oGAAoG;IAC7F,OAAO,SAAK;IACnB,gDAAgD;IAChD,OAAO,CAAC,MAAM,CAAmD;gBAErD,KAAK,CAAC,EAAE,UAAU;gBAClB,KAAK,EAAE,KAAK;IAwBxB;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIhC;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;;OAGG;IACH,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC;IAShD;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAQzB;;;OAGG;IACH,aAAa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AI,IAAI;IAIrB;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAO7B,YAAY,IAAI,IAAI;IAIpB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;CAGjE"}
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { log } from "../utils/log.js";
5
- import { Cache } from "./cache.js";
6
- // Basic graph data structure
5
+ import { Cache } from "../core/cache.js";
6
+ /** Basic graph data structure */
7
7
  export class Graph extends EventTarget {
8
8
  /** List object of nodes. */
9
9
  _nodeMap = {};
@@ -20,34 +20,41 @@ export class Graph extends EventTarget {
20
20
  _cache = new Cache();
21
21
  /**
22
22
  * The constructor of the Graph class.
23
- * @param {Object} graph - copy the graph if this exists.
23
+ * @param graph - copy the graph if this exists.
24
24
  */
25
- constructor(graph = null) {
25
+ constructor(propsOrGraph) {
26
26
  super();
27
- // copy the graph if it exists in the parameter
28
- if (graph) {
29
- // start copying the graph
27
+ if (propsOrGraph instanceof Graph) {
28
+ // if a Graph instance was supplied, copy the supplied graph into this graph
29
+ const graph = propsOrGraph;
30
+ this._name = graph?._name || this._name;
30
31
  this._nodeMap = graph._nodeMap;
31
32
  this._edgeMap = graph._edgeMap;
32
- this._name = graph && graph._name;
33
+ }
34
+ else {
35
+ // If graphProps were supplied, initialize this graph from the supplied props
36
+ const props = propsOrGraph;
37
+ this._name = props?.name || this._name;
38
+ this.batchAddNodes(props?.nodes || []);
39
+ this.batchAddEdges(props?.edges || []);
33
40
  }
34
41
  }
35
42
  /**
36
43
  * Set graph name
37
- * @param {string} name
44
+ * @param name
38
45
  */
39
46
  setGraphName(name) {
40
47
  this._name = name;
41
48
  }
42
49
  /** Get the name of the graph. Default value is the time stamp when creating this graph.
43
- * @return {string} graph name.
50
+ * @return graph name.
44
51
  */
45
52
  getGraphName() {
46
53
  return this._name.toString();
47
54
  }
48
55
  /**
49
56
  * Perform a batch of operations defined by cb before indicating graph is updated
50
- * @param {function} cb - a callback fuction containing the operations to perform
57
+ * @param {function} cb - a callback function containing the operations to perform
51
58
  */
52
59
  transaction(cb) {
53
60
  try {
@@ -60,7 +67,7 @@ export class Graph extends EventTarget {
60
67
  }
61
68
  /**
62
69
  * Add a new node to the graph.
63
- * @param {Node} node - expect a Node object to be added to the graph.
70
+ * @paramnode - expect a Node object to be added to the graph.
64
71
  */
65
72
  addNode(node) {
66
73
  // add it to the list and map
@@ -71,7 +78,7 @@ export class Graph extends EventTarget {
71
78
  }
72
79
  /**
73
80
  * Batch add nodes to the graph.
74
- * @param {Node[]} nodes - a list of nodes to be added.
81
+ * @param nodes - a list of nodes to be added.
75
82
  */
76
83
  batchAddNodes(nodes) {
77
84
  // convert an array of objects to an object
@@ -92,22 +99,22 @@ export class Graph extends EventTarget {
92
99
  }
93
100
  /**
94
101
  * Get the node map of the graph. The key of the map is the ID of the nodes.
95
- * @return {Object} - a map of nodes keyed by node IDs.
102
+ * @return - a map of nodes keyed by node IDs.
96
103
  */
97
104
  getNodeMap() {
98
105
  return this._nodeMap;
99
106
  }
100
107
  /**
101
108
  * Find a node by id
102
- * @param {String} nodeId The id of the node
103
- * @return {Object} Node
109
+ * @param nodeId The id of the node
110
+ * @return Node
104
111
  */
105
112
  findNode(nodeId) {
106
113
  return this._nodeMap[nodeId];
107
114
  }
108
115
  /**
109
116
  * Update the indicated node to the provided value
110
- * @param {Node} node
117
+ * @param node
111
118
  */
112
119
  updateNode(node) {
113
120
  this._nodeMap[node.getId()] = node;
@@ -116,7 +123,7 @@ export class Graph extends EventTarget {
116
123
  }
117
124
  /**
118
125
  * Add a new edge to the graph.
119
- * @param {Edge} edge - expect a Edge object to be added to the graph.
126
+ * @param edge - expect a Edge object to be added to the graph.
120
127
  */
121
128
  addEdge(edge) {
122
129
  const sourceNode = this.findNode(edge.getSourceNodeId());
@@ -133,7 +140,7 @@ export class Graph extends EventTarget {
133
140
  }
134
141
  /**
135
142
  * Batch add edges to the graph
136
- * @param {Edge[]} edges - a list of edges to be added.
143
+ * @param edges - a list of edges to be added.
137
144
  */
138
145
  batchAddEdges(edges) {
139
146
  edges.forEach((edge) => this.addEdge(edge));
@@ -141,7 +148,7 @@ export class Graph extends EventTarget {
141
148
  }
142
149
  /**
143
150
  * Update the indicated edge to the provided value
144
- * @param {Edge} edge
151
+ * @param edge
145
152
  */
146
153
  updateEdge(edge) {
147
154
  this._edgeMap[edge.getId()] = edge;
@@ -150,7 +157,7 @@ export class Graph extends EventTarget {
150
157
  }
151
158
  /**
152
159
  * Remove a node from the graph by node ID
153
- * @param {String|Number} nodeId - the ID of the target node.
160
+ * @param nodeId - the ID of the target node.
154
161
  */
155
162
  removeNode(nodeId) {
156
163
  const node = this.findNode(nodeId);
@@ -169,7 +176,7 @@ export class Graph extends EventTarget {
169
176
  }
170
177
  /**
171
178
  * Get all the edges of the graph.
172
- * @return {Edge[]} get all the edges in the graph.
179
+ * @return get all the edges in the graph.
173
180
  */
174
181
  getEdges() {
175
182
  this._updateCache('edges', () => Object.values(this._edgeMap));
@@ -177,7 +184,7 @@ export class Graph extends EventTarget {
177
184
  }
178
185
  /**
179
186
  * Get the edge map of the graph. The key of the map is the ID of the edges.
180
- * @return {Object} - a map of edges keyed by edge IDs.
187
+ * @return - a map of edges keyed by edge IDs.
181
188
  */
182
189
  getEdgeMap() {
183
190
  return this._edgeMap;
@@ -201,16 +208,16 @@ export class Graph extends EventTarget {
201
208
  }
202
209
  /**
203
210
  * Find the edge by edge ID.
204
- * @param {String|Number} id - the target edge ID
205
- * @return {Edge} - the target edge.
211
+ * @param id - the target edge ID
212
+ * @return - the target edge.
206
213
  */
207
214
  findEdge(edgeId) {
208
215
  return this._edgeMap[edgeId];
209
216
  }
210
217
  /**
211
218
  * Return all the connected edges of a node by nodeID.
212
- * @param {String|Number} nodeId - the target node ID
213
- * @return {Edge[]} - an array of the connected edges.
219
+ * @param nodeId - the target node ID
220
+ * @return - an array of the connected edges.
214
221
  */
215
222
  getConnectedEdges(nodeId) {
216
223
  const node = this.findNode(nodeId);
@@ -222,8 +229,8 @@ export class Graph extends EventTarget {
222
229
  }
223
230
  /**
224
231
  * Return all the sibling nodes of a node by nodeID.
225
- * @param {String|Number} nodeId - the target node ID
226
- * @return {Node[]} - an array of the sibling nodes.
232
+ * @param nodeId - the target node ID
233
+ * @return - an array of the sibling nodes.
227
234
  */
228
235
  getNodeSiblings(nodeId) {
229
236
  const node = this.findNode(nodeId);
@@ -235,8 +242,8 @@ export class Graph extends EventTarget {
235
242
  }
236
243
  /**
237
244
  * Get the degree of a node.
238
- * @param {String|Number} nodeId - the target node ID.
239
- * @return {Number} - the degree of the node.
245
+ * @param nodeId - the target node ID.
246
+ * @return - the degree of the node.
240
247
  */
241
248
  getDegree(nodeId) {
242
249
  const node = this.findNode(nodeId);
@@ -283,14 +290,14 @@ export class Graph extends EventTarget {
283
290
  }
284
291
  /**
285
292
  * Check the equality of two graphs data by checking last update time stamp
286
- * @param {Object} g Another graph to be compared against itself
287
- * @return {Bool} True if the graph is the same as itself.
293
+ * @param graph Another graph to be compared against itself
294
+ * @return true if the graph is the same as itself.
288
295
  */
289
- equals(g) {
290
- if (!g || !(g instanceof Graph)) {
296
+ equals(graph) {
297
+ if (!graph || !(graph instanceof Graph)) {
291
298
  return false;
292
299
  }
293
- return this.version === g.version;
300
+ return this.version === graph.version;
294
301
  }
295
302
  _bumpVersion() {
296
303
  this.version += 1;
@@ -1,11 +1,14 @@
1
- import { NODE_STATE, ValueOf } from "./constants.js";
1
+ import { NODE_STATE, ValueOf } from "../core/constants.js";
2
2
  import { Edge } from "./edge.js";
3
- interface NodeOptions {
3
+ /** Properties for creating a new node */
4
+ export interface NodeOptions {
5
+ /** the unique ID of the node */
4
6
  id: number | string;
5
7
  selectable?: boolean;
6
8
  highlightConnectedEdges?: boolean;
7
- data: Record<string, unknown>;
9
+ data?: Record<string, unknown>;
8
10
  }
11
+ /** Basic data structure of a node */
9
12
  export declare class Node {
10
13
  id: string | number;
11
14
  /** Keep a reference to origin data. */
@@ -22,13 +25,11 @@ export declare class Node {
22
25
  readonly isNode = true;
23
26
  /**
24
27
  * The constructor of a node
25
- * @param {String|Number} options.id - the unique ID of the node
26
- * @param {Record<string, unknown>} options.data - origin data reference
27
28
  */
28
29
  constructor({ id, selectable, highlightConnectedEdges, data }: NodeOptions);
29
30
  /**
30
31
  * Return the ID of the node
31
- * @return {String|Number} - the ID of the node.
32
+ * @return - the ID of the node.
32
33
  */
33
34
  getId(): string | number;
34
35
  /**
@@ -38,59 +39,59 @@ export declare class Node {
38
39
  getDegree(): number;
39
40
  /**
40
41
  * Return the in-degree of the node.
41
- * @return {Number} - the in-degree of the node.
42
+ * @return - the in-degree of the node.
42
43
  */
43
44
  getInDegree(): number;
44
45
  /**
45
46
  * Return the out-degree of the node.
46
- * @return {Number} - the out-degree of the node.
47
+ * @return - the out-degree of the node.
47
48
  */
48
49
  getOutDegree(): number;
49
50
  /**
50
51
  * Return all the IDs of the sibling nodes.
51
- * @return {String[]} [description]
52
+ * @return [description]
52
53
  */
53
54
  getSiblingIds(): (string | number)[];
54
55
  /**
55
56
  * Return all the connected edges.
56
- * @return {Object[]} - an array of the connected edges.
57
+ * @return - an array of the connected edges.
57
58
  */
58
59
  getConnectedEdges(): Edge[];
59
60
  /**
60
61
  * Return of the value of the selected property key.
61
- * @param {String} key - property key.
62
- * @return {Any} - the value of the property or undefined (not found).
62
+ * @param key - property key.
63
+ * @return - the value of the property or undefined (not found).
63
64
  */
64
65
  getPropertyValue(key: string): unknown;
65
66
  /**
66
67
  * Set the new node data.
67
- * @param {Record<string, unknown>} data - the new data of the node
68
+ * @param data - the new data of the node
68
69
  */
69
70
  setData(data: Record<string, unknown>): void;
70
71
  /**
71
72
  * Update a data property.
72
- * @param {String} key - the key of the property
73
- * @param {Any} value - the value of the property.
73
+ * @param key - the key of the property
74
+ * @param value - the value of the property.
74
75
  */
75
76
  setDataProperty(key: string, value: unknown): void;
76
77
  /**
77
78
  * Set node state
78
- * @param {String} state - one of NODE_STATE
79
+ * @param state - one of NODE_STATE
79
80
  */
80
81
  setState(state: ValueOf<typeof NODE_STATE>): void;
81
82
  /**
82
83
  * Get node state
83
- * @returns {string} state - one of NODE_STATE
84
+ * @returns state - one of NODE_STATE
84
85
  */
85
86
  getState(): ValueOf<typeof NODE_STATE>;
86
87
  /**
87
88
  * Add connected edges to the node
88
- * @param {Edge || Edge[]} edge an edge or an array of edges to be added to this._connectedEdges
89
+ * @param edge an edge or an array of edges to be added to this._connectedEdges
89
90
  */
90
91
  addConnectedEdges(edge: Edge | Edge[]): void;
91
92
  /**
92
93
  * Remove edges from this._connectedEdges
93
- * @param {Edge | Edge[]} edge an edge or an array of edges to be removed from this._connectedEdges
94
+ * @param edge an edge or an array of edges to be removed from this._connectedEdges
94
95
  */
95
96
  removeConnectedEdges(edge: Edge | Edge[]): void;
96
97
  /**
@@ -100,5 +101,4 @@ export declare class Node {
100
101
  isSelectable(): boolean;
101
102
  shouldHighlightConnectedEdges(): boolean;
102
103
  }
103
- export {};
104
104
  //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/graph/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,OAAO,EAAC,6BAA0B;AACtD,OAAO,EAAC,IAAI,EAAC,kBAAe;AAE5B,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAElC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,qCAAqC;AACrC,qBAAa,IAAI;IACR,EAAE,EAAE,MAAM,GAA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AE,GAAG,IAAI;IAQ/C;;OAEG;IACH,mBAAmB,IAAI,IAAI;IAK3B,YAAY,IAAI,OAAO;IAIvB,6BAA6B,IAAI,OAAO;CAGzC"}
@@ -1,8 +1,8 @@
1
1
  // deck.gl-community
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { NODE_STATE } from "./constants.js";
5
- // Basic data structure of a node
4
+ import { NODE_STATE } from "../core/constants.js";
5
+ /** Basic data structure of a node */
6
6
  export class Node {
7
7
  id;
8
8
  /** Keep a reference to origin data. */
@@ -19,8 +19,6 @@ export class Node {
19
19
  isNode = true;
20
20
  /**
21
21
  * The constructor of a node
22
- * @param {String|Number} options.id - the unique ID of the node
23
- * @param {Record<string, unknown>} options.data - origin data reference
24
22
  */
25
23
  constructor({ id, selectable = false, highlightConnectedEdges = false, data = {} }) {
26
24
  this.id = id;
@@ -30,7 +28,7 @@ export class Node {
30
28
  }
31
29
  /**
32
30
  * Return the ID of the node
33
- * @return {String|Number} - the ID of the node.
31
+ * @return - the ID of the node.
34
32
  */
35
33
  getId() {
36
34
  return this.id;
@@ -44,7 +42,7 @@ export class Node {
44
42
  }
45
43
  /**
46
44
  * Return the in-degree of the node.
47
- * @return {Number} - the in-degree of the node.
45
+ * @return - the in-degree of the node.
48
46
  */
49
47
  getInDegree() {
50
48
  const nodeId = this.getId();
@@ -58,7 +56,7 @@ export class Node {
58
56
  }
59
57
  /**
60
58
  * Return the out-degree of the node.
61
- * @return {Number} - the out-degree of the node.
59
+ * @return - the out-degree of the node.
62
60
  */
63
61
  getOutDegree() {
64
62
  const nodeId = this.getId();
@@ -72,7 +70,7 @@ export class Node {
72
70
  }
73
71
  /**
74
72
  * Return all the IDs of the sibling nodes.
75
- * @return {String[]} [description]
73
+ * @return [description]
76
74
  */
77
75
  getSiblingIds() {
78
76
  const nodeId = this.getId();
@@ -88,15 +86,15 @@ export class Node {
88
86
  }
89
87
  /**
90
88
  * Return all the connected edges.
91
- * @return {Object[]} - an array of the connected edges.
89
+ * @return - an array of the connected edges.
92
90
  */
93
91
  getConnectedEdges() {
94
92
  return Object.values(this._connectedEdges);
95
93
  }
96
94
  /**
97
95
  * Return of the value of the selected property key.
98
- * @param {String} key - property key.
99
- * @return {Any} - the value of the property or undefined (not found).
96
+ * @param key - property key.
97
+ * @return - the value of the property or undefined (not found).
100
98
  */
101
99
  getPropertyValue(key) {
102
100
  // try to search the key within this object
@@ -112,36 +110,36 @@ export class Node {
112
110
  }
113
111
  /**
114
112
  * Set the new node data.
115
- * @param {Record<string, unknown>} data - the new data of the node
113
+ * @param data - the new data of the node
116
114
  */
117
115
  setData(data) {
118
116
  this._data = data;
119
117
  }
120
118
  /**
121
119
  * Update a data property.
122
- * @param {String} key - the key of the property
123
- * @param {Any} value - the value of the property.
120
+ * @param key - the key of the property
121
+ * @param value - the value of the property.
124
122
  */
125
123
  setDataProperty(key, value) {
126
124
  this._data[key] = value;
127
125
  }
128
126
  /**
129
127
  * Set node state
130
- * @param {String} state - one of NODE_STATE
128
+ * @param state - one of NODE_STATE
131
129
  */
132
130
  setState(state) {
133
131
  this.state = state;
134
132
  }
135
133
  /**
136
134
  * Get node state
137
- * @returns {string} state - one of NODE_STATE
135
+ * @returns state - one of NODE_STATE
138
136
  */
139
137
  getState() {
140
138
  return this.state;
141
139
  }
142
140
  /**
143
141
  * Add connected edges to the node
144
- * @param {Edge || Edge[]} edge an edge or an array of edges to be added to this._connectedEdges
142
+ * @param edge an edge or an array of edges to be added to this._connectedEdges
145
143
  */
146
144
  addConnectedEdges(edge) {
147
145
  const iterableEdges = Array.isArray(edge) ? edge : [edge];
@@ -152,7 +150,7 @@ export class Node {
152
150
  }
153
151
  /**
154
152
  * Remove edges from this._connectedEdges
155
- * @param {Edge | Edge[]} edge an edge or an array of edges to be removed from this._connectedEdges
153
+ * @param edge an edge or an array of edges to be removed from this._connectedEdges
156
154
  */
157
155
  removeConnectedEdges(edge) {
158
156
  const iterableEdges = Array.isArray(edge) ? edge : [edge];