@deck.gl-community/graph-layers 9.0.1 → 9.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/core/cache.d.ts +1 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/graph-engine.d.ts +17 -7
- package/dist/core/graph-engine.d.ts.map +1 -0
- package/dist/core/graph-engine.js +14 -5
- package/dist/core/graph-layout.d.ts +69 -0
- package/dist/core/graph-layout.d.ts.map +1 -0
- package/dist/core/{base-layout.js → graph-layout.js} +63 -80
- package/dist/core/interaction-manager.d.ts +3 -2
- package/dist/core/interaction-manager.d.ts.map +1 -0
- package/dist/core/interaction-manager.js +1 -1
- package/dist/{core → graph}/edge.d.ts +20 -18
- package/dist/graph/edge.d.ts.map +1 -0
- package/dist/{core → graph}/edge.js +12 -15
- package/dist/{core → graph}/graph.d.ts +37 -33
- package/dist/graph/graph.d.ts.map +1 -0
- package/dist/{core → graph}/graph.js +44 -37
- package/dist/{core → graph}/node.d.ts +22 -21
- package/dist/graph/node.d.ts.map +1 -0
- package/dist/{core → graph}/node.js +16 -18
- package/dist/index.cjs +1181 -434
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +22 -19
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -23
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-fragment.glsl.d.ts +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-fragment.glsl.d.ts.map +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex-tf.glsl.d.ts +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex-tf.glsl.d.ts.map +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex.glsl.d.ts +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer.d.ts +1 -0
- package/dist/layers/common-layers/flow-path-layer/flow-path-layer.d.ts.map +1 -0
- package/dist/layers/common-layers/marker-layer/atlas-data-url.d.ts +1 -0
- package/dist/layers/common-layers/marker-layer/atlas-data-url.d.ts.map +1 -0
- package/dist/layers/common-layers/marker-layer/marker-layer.d.ts +1 -0
- package/dist/layers/common-layers/marker-layer/marker-layer.d.ts.map +1 -0
- package/dist/layers/common-layers/marker-layer/marker-layer.js +2 -2
- package/dist/layers/common-layers/marker-layer/marker-list.d.ts +1 -0
- package/dist/layers/common-layers/marker-layer/marker-list.d.ts.map +1 -0
- package/dist/layers/common-layers/marker-layer/marker-mapping.d.ts +1 -0
- package/dist/layers/common-layers/marker-layer/marker-mapping.d.ts.map +1 -0
- package/dist/layers/common-layers/spline-layer/spline-layer.d.ts +1 -0
- package/dist/layers/common-layers/spline-layer/spline-layer.d.ts.map +1 -0
- package/dist/layers/common-layers/zoomable-text-layer/zoomable-text-layer.d.ts +1 -0
- package/dist/layers/common-layers/zoomable-text-layer/zoomable-text-layer.d.ts.map +1 -0
- package/dist/layers/edge-layer.d.ts +4 -3
- package/dist/layers/edge-layer.d.ts.map +1 -0
- package/dist/layers/edge-layer.js +4 -4
- package/dist/layers/edge-layers/curved-edge-layer.d.ts +2 -1
- package/dist/layers/edge-layers/curved-edge-layer.d.ts.map +1 -0
- package/dist/layers/edge-layers/curved-edge-layer.js +1 -1
- package/dist/layers/edge-layers/edge-label-layer.d.ts +2 -1
- package/dist/layers/edge-layers/edge-label-layer.d.ts.map +1 -0
- package/dist/layers/edge-layers/edge-label-layer.js +1 -1
- package/dist/layers/edge-layers/flow-layer.d.ts +2 -1
- package/dist/layers/edge-layers/flow-layer.d.ts.map +1 -0
- package/dist/layers/edge-layers/flow-layer.js +1 -1
- package/dist/layers/edge-layers/path-edge-layer.d.ts +1 -0
- package/dist/layers/edge-layers/path-edge-layer.d.ts.map +1 -0
- package/dist/layers/edge-layers/straight-line-edge-layer.d.ts +1 -0
- package/dist/layers/edge-layers/straight-line-edge-layer.d.ts.map +1 -0
- package/dist/layers/graph-layer.d.ts +54 -13
- package/dist/layers/graph-layer.d.ts.map +1 -0
- package/dist/layers/graph-layer.js +93 -51
- package/dist/layers/node-layers/circle-layer.d.ts +1 -0
- package/dist/layers/node-layers/circle-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/image-layer.d.ts +1 -0
- package/dist/layers/node-layers/image-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/label-layer.d.ts +2 -1
- package/dist/layers/node-layers/label-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/label-layer.js +1 -1
- package/dist/layers/node-layers/{path-rounded-rectange-layer.d.ts → path-rounded-rectangle-layer.d.ts} +1 -0
- package/dist/layers/node-layers/path-rounded-rectangle-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/{path-rounded-rectange-layer.js → path-rounded-rectangle-layer.js} +1 -1
- package/dist/layers/node-layers/rectangle-layer.d.ts +1 -0
- package/dist/layers/node-layers/rectangle-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/rounded-rectangle-layer-fragment.d.ts +2 -1
- package/dist/layers/node-layers/rounded-rectangle-layer-fragment.d.ts.map +1 -0
- package/dist/layers/node-layers/rounded-rectangle-layer-fragment.js +1 -3
- package/dist/layers/node-layers/rounded-rectangle-layer.d.ts +14 -4
- package/dist/layers/node-layers/rounded-rectangle-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/rounded-rectangle-layer.js +27 -13
- package/dist/layers/node-layers/zoomable-marker-layer.d.ts +2 -1
- package/dist/layers/node-layers/zoomable-marker-layer.d.ts.map +1 -0
- package/dist/layers/node-layers/zoomable-marker-layer.js +1 -1
- package/dist/layouts/d3-force/d3-force-layout.d.ts +13 -3
- package/dist/layouts/d3-force/d3-force-layout.d.ts.map +1 -0
- package/dist/layouts/d3-force/d3-force-layout.js +12 -12
- package/dist/layouts/d3-force/worker.d.ts +1 -0
- package/dist/layouts/d3-force/worker.d.ts.map +1 -0
- package/dist/layouts/experimental/force-multi-graph-layout.d.ts +43 -0
- package/dist/layouts/experimental/force-multi-graph-layout.d.ts.map +1 -0
- package/dist/layouts/experimental/force-multi-graph-layout.js +226 -0
- package/dist/layouts/experimental/hive-plot-layout.d.ts +34 -0
- package/dist/layouts/experimental/hive-plot-layout.d.ts.map +1 -0
- package/dist/layouts/experimental/hive-plot-layout.js +142 -0
- package/dist/layouts/experimental/radial-layout.d.ts +28 -0
- package/dist/layouts/experimental/radial-layout.d.ts.map +1 -0
- package/dist/layouts/experimental/radial-layout.js +164 -0
- package/dist/layouts/gpu-force/gpu-force-layout.d.ts +16 -3
- package/dist/layouts/gpu-force/gpu-force-layout.d.ts.map +1 -0
- package/dist/layouts/gpu-force/gpu-force-layout.js +21 -19
- package/dist/layouts/gpu-force/worker.d.ts +1 -0
- package/dist/layouts/gpu-force/worker.d.ts.map +1 -0
- package/dist/layouts/simple-layout.d.ts +42 -0
- package/dist/layouts/simple-layout.d.ts.map +1 -0
- package/dist/layouts/{simple-layout/simple-layout.js → simple-layout.js} +8 -7
- package/dist/loaders/create-graph.d.ts +13 -0
- package/dist/loaders/create-graph.d.ts.map +1 -0
- package/dist/{utils → loaders}/create-graph.js +9 -4
- package/dist/loaders/edge-parsers.d.ts +3 -6
- package/dist/loaders/edge-parsers.d.ts.map +1 -0
- package/dist/loaders/edge-parsers.js +1 -1
- package/dist/loaders/json-loader.d.ts +3 -2
- package/dist/loaders/json-loader.d.ts.map +1 -0
- package/dist/loaders/json-loader.js +4 -4
- package/dist/loaders/node-parsers.d.ts +3 -3
- package/dist/loaders/node-parsers.d.ts.map +1 -0
- package/dist/loaders/node-parsers.js +1 -1
- package/dist/loaders/simple-json-graph-loader.d.ts +12 -0
- package/dist/loaders/simple-json-graph-loader.d.ts.map +1 -0
- package/dist/loaders/simple-json-graph-loader.js +20 -0
- package/dist/loaders/table-graph-loader.d.ts +17 -0
- package/dist/loaders/table-graph-loader.d.ts.map +1 -0
- package/dist/loaders/table-graph-loader.js +91 -0
- package/dist/style/style-property.d.ts +1 -0
- package/dist/style/style-property.d.ts.map +1 -0
- package/dist/style/style-property.js +1 -1
- package/dist/style/style-sheet.d.ts +1 -0
- package/dist/style/style-sheet.d.ts.map +1 -0
- package/dist/style/style-sheet.js +3 -3
- package/dist/utils/layer-utils.d.ts +1 -0
- package/dist/utils/layer-utils.d.ts.map +1 -0
- package/dist/utils/log.d.ts +2 -1
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/log.js +3 -3
- package/dist/utils/polygon-calculations.d.ts +1 -0
- package/dist/utils/polygon-calculations.d.ts.map +1 -0
- package/dist/widgets/long-press-button.d.ts +13 -0
- package/dist/widgets/long-press-button.d.ts.map +1 -0
- package/dist/widgets/long-press-button.js +31 -0
- package/dist/widgets/view-control-widget.d.ts +78 -0
- package/dist/widgets/view-control-widget.d.ts.map +1 -0
- package/dist/widgets/view-control-widget.js +194 -0
- package/package.json +8 -7
- package/src/core/graph-engine.ts +30 -10
- package/src/core/graph-layout.ts +146 -0
- package/src/core/interaction-manager.ts +2 -2
- package/src/{core → graph}/edge.ts +19 -17
- package/src/{core → graph}/graph.ts +51 -36
- package/src/{core → graph}/node.ts +21 -20
- package/src/index.ts +28 -28
- package/src/layers/graph-layer.ts +133 -46
- package/src/layers/node-layers/rounded-rectangle-layer-fragment.ts +1 -3
- package/src/layers/node-layers/rounded-rectangle-layer.ts +34 -10
- package/src/layouts/d3-force/d3-force-layout.ts +21 -11
- package/src/layouts/experimental/force-multi-graph-layout.ts +268 -0
- package/src/layouts/experimental/hive-plot-layout.ts +182 -0
- package/src/layouts/experimental/radial-layout.ts +210 -0
- package/src/layouts/gpu-force/gpu-force-layout.ts +32 -17
- package/src/layouts/{simple-layout/simple-layout.ts → simple-layout.ts} +34 -19
- package/src/{utils → loaders}/create-graph.ts +9 -4
- package/src/loaders/edge-parsers.ts +2 -1
- package/src/loaders/json-loader.ts +1 -1
- package/src/loaders/node-parsers.ts +2 -1
- package/src/loaders/simple-json-graph-loader.ts +28 -0
- package/src/loaders/table-graph-loader.ts +124 -0
- package/src/utils/log.ts +3 -3
- package/src/widgets/long-press-button.tsx +50 -0
- package/src/widgets/view-control-widget.tsx +337 -0
- package/dist/core/base-layout.d.ts +0 -71
- package/dist/layouts/simple-layout/simple-layout.d.ts +0 -22
- package/dist/utils/create-graph.d.ts +0 -8
- package/src/core/base-layout.ts +0 -154
- /package/src/layers/node-layers/{path-rounded-rectange-layer.ts → path-rounded-rectangle-layer.ts} +0 -0
- /package/src/layouts/d3-force/{worker.ts → worker.js} +0 -0
- /package/src/layouts/gpu-force/{worker.ts → worker.js} +0 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { Edge } from
|
|
2
|
-
import { Node } from
|
|
1
|
+
import { Edge } from "./edge.js";
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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
|
|
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
|
|
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
|
|
59
|
-
* @return
|
|
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
|
|
67
|
+
* @param node
|
|
65
68
|
*/
|
|
66
69
|
updateNode(node: Node): void;
|
|
67
70
|
/**
|
|
68
71
|
* Add a new edge to the graph.
|
|
69
|
-
* @param
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
105
|
-
* @return
|
|
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
|
|
111
|
-
* @return
|
|
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
|
|
117
|
-
* @return
|
|
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
|
|
123
|
-
* @return
|
|
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,11 @@ 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
|
|
150
|
-
* @return
|
|
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(
|
|
155
|
+
equals(graph: Graph): boolean;
|
|
153
156
|
_bumpVersion(): void;
|
|
154
157
|
_updateCache(key: 'nodes' | 'edges', updateValue: unknown): void;
|
|
155
158
|
}
|
|
159
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -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,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAalC;;;OAGG;IACH,QAAQ,IAAI,IAAI,EAAE;IAMlB;;;OAGG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC;IAI3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS;IAInD;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAM5B;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAgBzB;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI;IAKlC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAM5B;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAgBzC;;;OAGG;IACH,QAAQ,IAAI,IAAI,EAAE;IAMlB;;;OAGG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;IAIlC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAezC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIvC;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE;IASlD;;;;OAIG;IACH,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE;IAShD;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;IAS1C;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;OAEG;IACH,UAAU,IAAI,IAAI;IAKlB;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,aAAa,IAAI,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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// deck.gl-community
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { log } from
|
|
5
|
-
import { Cache } from
|
|
6
|
-
|
|
4
|
+
import { log } from "../utils/log.js";
|
|
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
|
|
23
|
+
* @param graph - copy the graph if this exists.
|
|
24
24
|
*/
|
|
25
|
-
constructor(
|
|
25
|
+
constructor(propsOrGraph) {
|
|
26
26
|
super();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
* @
|
|
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
|
|
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
|
|
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
|
|
103
|
-
* @return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
205
|
-
* @return
|
|
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
|
|
213
|
-
* @return
|
|
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
|
|
226
|
-
* @return
|
|
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
|
|
239
|
-
* @return
|
|
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
|
|
287
|
-
* @return
|
|
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(
|
|
290
|
-
if (!
|
|
296
|
+
equals(graph) {
|
|
297
|
+
if (!graph || !(graph instanceof Graph)) {
|
|
291
298
|
return false;
|
|
292
299
|
}
|
|
293
|
-
return this.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
|
|
2
|
-
import { Edge } from
|
|
3
|
-
|
|
1
|
+
import { NODE_STATE, ValueOf } from "../core/constants.js";
|
|
2
|
+
import { Edge } from "./edge.js";
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
52
|
+
* @return [description]
|
|
52
53
|
*/
|
|
53
54
|
getSiblingIds(): (string | number)[];
|
|
54
55
|
/**
|
|
55
56
|
* Return all the connected edges.
|
|
56
|
-
* @return
|
|
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
|
|
62
|
-
* @return
|
|
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
|
|
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
|
|
73
|
-
* @param
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,4 +101,4 @@ export declare class Node {
|
|
|
100
101
|
isSelectable(): boolean;
|
|
101
102
|
shouldHighlightConnectedEdges(): boolean;
|
|
102
103
|
}
|
|
103
|
-
|
|
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,GAAG,MAAM,CAAC;IAC3B,uCAAuC;IACvC,OAAO,CAAC,KAAK,CAA0B;IACvC,kBAAkB;IAClB,OAAO,CAAC,eAAe,CAA4B;IACnD,qCAAqC;IAC9B,KAAK,EAAE,OAAO,CAAC,OAAO,UAAU,CAAC,CAAsB;IAC9D,gCAAgC;IAChC,OAAO,CAAC,WAAW,CAAU;IAC7B,6EAA6E;IAC7E,OAAO,CAAC,wBAAwB,CAAU;IAC1C,gEAAgE;IAChE,SAAgB,MAAM,QAAQ;IAC9B;;OAEG;gBACS,EAAC,EAAE,EAAE,UAAkB,EAAE,uBAA+B,EAAE,IAAS,EAAC,EAAE,WAAW;IAO7F;;;OAGG;IACH,KAAK,IAAI,MAAM,GAAG,MAAM;IAIxB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,WAAW,IAAI,MAAM;IAWrB;;;OAGG;IACH,YAAY,IAAI,MAAM;IAWtB;;;OAGG;IACH,aAAa,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;IAepC;;;OAGG;IACH,iBAAiB,IAAI,IAAI,EAAE;IAI3B;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAatC;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI5C;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAIlD;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,UAAU,CAAC,GAAG,IAAI;IAIjD;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,OAAO,UAAU,CAAC;IAItC;;;OAGG;IACH,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI;IAQ5C;;;OAGG;IACH,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,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
|
|
5
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
99
|
-
* @return
|
|
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
|
|
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
|
|
123
|
-
* @param
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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];
|