agent-docs 1.0.0
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/.cursor/plans/OPTIMISE.md +379 -0
- package/.cursor/plans/VERSIONING.md +207 -0
- package/.cursor/rules/IMPORTANT.mdc +97 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +13 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- package/.github/dependabot.yml +38 -0
- package/.github/pull_request_template.md +10 -0
- package/.github/workflows/format.yml +35 -0
- package/CODE_OF_CONDUCT.md +64 -0
- package/CONTRIBUTING.md +52 -0
- package/LICENSE.md +20 -0
- package/PLAN.md +707 -0
- package/README.md +133 -0
- package/SECURITY.md +21 -0
- package/docs/APEXANNOTATIONS.md +472 -0
- package/docs/APEXDOC.md +198 -0
- package/docs/CML.md +877 -0
- package/docs/CODEANALYZER.md +435 -0
- package/docs/CONTEXTDEFINITIONS.md +617 -0
- package/docs/ESLINT.md +827 -0
- package/docs/ESLINTJSDOC.md +520 -0
- package/docs/FIELDSERVICE.md +4452 -0
- package/docs/GRAPHBINARY.md +208 -0
- package/docs/GRAPHENGINE.md +616 -0
- package/docs/GRAPHML.md +337 -0
- package/docs/GRAPHSON.md +302 -0
- package/docs/GREMLIN.md +490 -0
- package/docs/GRYO.md +232 -0
- package/docs/HUSKY.md +106 -0
- package/docs/JEST.md +387 -0
- package/docs/JORJE.md +537 -0
- package/docs/JSDOC.md +621 -0
- package/docs/PMD.md +910 -0
- package/docs/PNPM.md +409 -0
- package/docs/PRETTIER.md +716 -0
- package/docs/PRETTIERAPEX.md +874 -0
- package/docs/REVENUETRANSACTIONMANAGEMENT.md +887 -0
- package/docs/TINKERPOP.md +252 -0
- package/docs/VITEST.md +706 -0
- package/docs/VSCODE.md +231 -0
- package/docs/XPATH31.md +213 -0
- package/package.json +32 -0
- package/postinstall.mjs +51 -0
- package/prettier.config.js +18 -0
package/docs/GRAPHML.md
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# GraphML Format Specification
|
|
2
|
+
|
|
3
|
+
> **Version**: 1.0.0
|
|
4
|
+
|
|
5
|
+
XML-based format for graph serialization defined by GraphML specification (DTD
|
|
6
|
+
and XSD).
|
|
7
|
+
|
|
8
|
+
**Related Docs:** [GRAPHENGINE.md](GRAPHENGINE.md),
|
|
9
|
+
[TINKERPOP.md](TINKERPOP.md), [GRAPHSON.md](GRAPHSON.md), [GRYO.md](GRYO.md),
|
|
10
|
+
[GRAPHBINARY.md](GRAPHBINARY.md), [CODEANALYZER.md](CODEANALYZER.md)
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
GraphML: XML-based format for representing graph structures. TinkerGraph can
|
|
15
|
+
load/save graphs in GraphML format. Enables graph persistence and exchange.
|
|
16
|
+
Useful for testing and development. Conforms to GraphML DTD and XSD
|
|
17
|
+
specifications. Human-readable XML format.
|
|
18
|
+
|
|
19
|
+
## GraphML Document Structure
|
|
20
|
+
|
|
21
|
+
### Root Element: `<graphml>`
|
|
22
|
+
|
|
23
|
+
Root element containing namespace declarations, `<key>` elements (property
|
|
24
|
+
definitions), and `<graph>` elements (graph data). Keys must appear before
|
|
25
|
+
graphs. Multiple graphs allowed.
|
|
26
|
+
|
|
27
|
+
**Attributes:** `xmlns` (XML namespace, typically
|
|
28
|
+
`http://graphml.graphdrawing.org/xmlns`), `xmlns:xsi` (XML Schema instance
|
|
29
|
+
namespace), `xsi:schemaLocation` (Location of XSD schema)
|
|
30
|
+
|
|
31
|
+
**Example:**
|
|
32
|
+
|
|
33
|
+
```xml
|
|
34
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
35
|
+
<graphml
|
|
36
|
+
xmlns="http://graphml.graphdrawing.org/xmlns"
|
|
37
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
38
|
+
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
|
|
39
|
+
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"
|
|
40
|
+
>
|
|
41
|
+
<!-- keys and graphs -->
|
|
42
|
+
</graphml>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Key Element: `<key>`
|
|
46
|
+
|
|
47
|
+
Defines property keys used in graph elements. Must appear before `<graph>`
|
|
48
|
+
elements. Optional `<desc>` and `<default>`.
|
|
49
|
+
|
|
50
|
+
**Attributes:** `id` (required, unique identifier), `for` (optional, element
|
|
51
|
+
type: `all`, `graph`, `node`, `edge`, default: `all`), `attr.name` (optional,
|
|
52
|
+
property name), `attr.type` (optional, data type: `string`, `int`, `long`,
|
|
53
|
+
`float`, `double`, `boolean`, default: `string`), `attr.list` (optional, whether
|
|
54
|
+
property is a list: `true`/`false`, default: `false`), `attr.domain` (optional,
|
|
55
|
+
domain specification)
|
|
56
|
+
|
|
57
|
+
**Example:**
|
|
58
|
+
|
|
59
|
+
```xml
|
|
60
|
+
<key id="name" for="node" attr.name="name" attr.type="string"/>
|
|
61
|
+
<key id="weight" for="edge" attr.name="weight" attr.type="double"/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Graph Element: `<graph>`
|
|
65
|
+
|
|
66
|
+
Represents a graph structure. Contains `<node>`, `<edge>`, `<hyperedge>`, and
|
|
67
|
+
`<data>` elements.
|
|
68
|
+
|
|
69
|
+
**Attributes:** `id` (optional, unique identifier), `edgedefault` (required,
|
|
70
|
+
default edge direction: `directed` or `undirected`), `parse.nodes`,
|
|
71
|
+
`parse.edges` (optional, hints for parsers to pre-allocate memory),
|
|
72
|
+
`parse.maxindegree`, `parse.maxoutdegree` (optional, hints for optimizing data
|
|
73
|
+
structures), `parse.nodeids`, `parse.edgeids` (optional, ID type: `canonical` =
|
|
74
|
+
sequential integers starting at 0, `free` = arbitrary IDs), `parse.order`
|
|
75
|
+
(optional, element ordering: `nodesfirst`, `edgesfirst`, `adjacencylist`)
|
|
76
|
+
|
|
77
|
+
### Node Element: `<node>`
|
|
78
|
+
|
|
79
|
+
Represents a vertex. Contains `<data>` elements for properties, optional
|
|
80
|
+
`<port>` elements (for hyperedges), optional nested `<graph>` (for hierarchical
|
|
81
|
+
graphs).
|
|
82
|
+
|
|
83
|
+
**Attributes:** `id` (required, unique identifier)
|
|
84
|
+
|
|
85
|
+
**Example:**
|
|
86
|
+
|
|
87
|
+
```xml
|
|
88
|
+
<node id="1">
|
|
89
|
+
<data key="name">Vertex 1</data>
|
|
90
|
+
<data key="type">Person</data>
|
|
91
|
+
</node>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Edge Element: `<edge>`
|
|
95
|
+
|
|
96
|
+
Represents an edge connecting two nodes. Contains `<data>` elements for
|
|
97
|
+
properties, optional nested `<graph>`.
|
|
98
|
+
|
|
99
|
+
**Attributes:** `id` (optional, unique identifier), `source` (required, ID of
|
|
100
|
+
source node), `target` (required, ID of target node), `directed` (optional,
|
|
101
|
+
whether edge is directed: `true`/`false`, defaults to `edgedefault` from graph)
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
|
|
105
|
+
```xml
|
|
106
|
+
<edge id="e1" source="1" target="2">
|
|
107
|
+
<data key="weight">1.5</data>
|
|
108
|
+
</edge>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Hyperedge Element: `<hyperedge>`
|
|
112
|
+
|
|
113
|
+
Represents hyperedge connecting multiple nodes (n-ary relationship). Contains
|
|
114
|
+
`<endpoint>` elements, `<data>` elements, optional nested `<graph>`.
|
|
115
|
+
|
|
116
|
+
**Attributes:** `id` (optional, unique identifier)
|
|
117
|
+
|
|
118
|
+
### Endpoint Element: `<endpoint>`
|
|
119
|
+
|
|
120
|
+
Represents connection point in hyperedge. Specifies which node and port the
|
|
121
|
+
hyperedge connects to.
|
|
122
|
+
|
|
123
|
+
**Attributes:** `id` (optional, unique identifier), `node` (required, ID of
|
|
124
|
+
connected node), `port` (optional, port name on the node)
|
|
125
|
+
|
|
126
|
+
### Port Element: `<port>`
|
|
127
|
+
|
|
128
|
+
Represents port on a node (connection point for hyperedges). Used in
|
|
129
|
+
hierarchical graphs and hyperedge connections.
|
|
130
|
+
|
|
131
|
+
**Attributes:** `name` (required, port name/identifier)
|
|
132
|
+
|
|
133
|
+
### Data Element: `<data>`
|
|
134
|
+
|
|
135
|
+
Contains property value for graph, node, or edge. References a `<key>` element
|
|
136
|
+
via `key` attribute. Can contain text content or nested elements.
|
|
137
|
+
|
|
138
|
+
**Attributes:** `key` (required, ID of corresponding `<key>` element)
|
|
139
|
+
|
|
140
|
+
### Desc/Default Elements
|
|
141
|
+
|
|
142
|
+
- `<desc>`: Optional description element (text content)
|
|
143
|
+
- `<default>`: Optional default value element (text content, used in `<key>`
|
|
144
|
+
elements)
|
|
145
|
+
|
|
146
|
+
## Complete GraphML Example
|
|
147
|
+
|
|
148
|
+
```xml
|
|
149
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
150
|
+
<graphml
|
|
151
|
+
xmlns="http://graphml.graphdrawing.org/xmlns"
|
|
152
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
153
|
+
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
|
|
154
|
+
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"
|
|
155
|
+
>
|
|
156
|
+
<key id="name" for="node" attr.name="name" attr.type="string" />
|
|
157
|
+
<key id="weight" for="edge" attr.name="weight" attr.type="double" />
|
|
158
|
+
<graph id="G" edgedefault="directed">
|
|
159
|
+
<node id="1">
|
|
160
|
+
<data key="name">Vertex 1</data>
|
|
161
|
+
</node>
|
|
162
|
+
<node id="2">
|
|
163
|
+
<data key="name">Vertex 2</data>
|
|
164
|
+
</node>
|
|
165
|
+
<edge id="e1" source="1" target="2">
|
|
166
|
+
<data key="weight">1.5</data>
|
|
167
|
+
</edge>
|
|
168
|
+
</graph>
|
|
169
|
+
</graphml>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## TinkerPop GraphML Support
|
|
173
|
+
|
|
174
|
+
**GraphMLReader:** Reads GraphML files into TinkerPop graphs, parses all GraphML
|
|
175
|
+
elements, handles property key definitions, supports all GraphML data types.
|
|
176
|
+
Builder: `GraphMLReader.build().create()`. Methods:
|
|
177
|
+
`readGraph(InputStream|File|URL, Graph)`. **Limitation:** Does not fully support
|
|
178
|
+
hyperedges and ports (simplified to regular edges).
|
|
179
|
+
|
|
180
|
+
**GraphMLWriter:** Writes TinkerPop graphs to GraphML format, generates valid
|
|
181
|
+
GraphML documents, includes property key definitions. Builder:
|
|
182
|
+
`GraphMLWriter.build().normalize(boolean).xmlMapper(XMLMapper).create()`.
|
|
183
|
+
Methods: `writeGraph(OutputStream|File|URL, Graph)`. Configuration: `normalize`
|
|
184
|
+
(default: false), `xmlMapper` (custom XML mapper). **Limitation:** Does not
|
|
185
|
+
support hyperedges and ports (converts to regular edges).
|
|
186
|
+
|
|
187
|
+
**Usage:**
|
|
188
|
+
|
|
189
|
+
```java
|
|
190
|
+
Graph graph = TinkerGraph.open();
|
|
191
|
+
GraphReader reader = GraphMLReader.build().create();
|
|
192
|
+
reader.readGraph(new FileInputStream("graph.graphml"), graph);
|
|
193
|
+
|
|
194
|
+
GraphWriter writer = GraphMLWriter.build().create();
|
|
195
|
+
writer.writeGraph(new FileOutputStream("graph.graphml"), graph);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Limitations:** Does not support meta-properties (vertex properties on vertex
|
|
199
|
+
properties) as GraphML specification does not define this concept. Hyperedges
|
|
200
|
+
and ports are simplified to regular edges in TinkerPop implementation.
|
|
201
|
+
|
|
202
|
+
## DTD Specification
|
|
203
|
+
|
|
204
|
+
Document Type Definition (DTD) defines structure and validation rules.
|
|
205
|
+
|
|
206
|
+
**Element Definitions:**
|
|
207
|
+
|
|
208
|
+
- `<!ELEMENT graphml (key*,graph*)>`: Root element (keys before graphs, multiple
|
|
209
|
+
graphs allowed)
|
|
210
|
+
- `<!ELEMENT key (desc?,default?)>`: Property key definition
|
|
211
|
+
- `<!ELEMENT graph (data*,node*,edge*,hyperedge*)>`: Graph structure
|
|
212
|
+
- `<!ELEMENT node (data*,port*,graph?)>`: Vertex (can contain nested graph,
|
|
213
|
+
ports)
|
|
214
|
+
- `<!ELEMENT edge (data*,graph?)>`: Edge connecting two nodes
|
|
215
|
+
- `<!ELEMENT hyperedge (data*,endpoint*,graph?)>`: Hyperedge connecting multiple
|
|
216
|
+
nodes
|
|
217
|
+
- `<!ELEMENT endpoint (data*,port?)>`: Connection point in hyperedge
|
|
218
|
+
- `<!ELEMENT port (data*,graph?)>`: Port on a node
|
|
219
|
+
- `<!ELEMENT data (#PCDATA|desc|default)*>`: Property value
|
|
220
|
+
- `<!ELEMENT desc (#PCDATA)>`: Description element
|
|
221
|
+
- `<!ELEMENT default (#PCDATA)>`: Default value element
|
|
222
|
+
|
|
223
|
+
**Attribute Definitions:**
|
|
224
|
+
|
|
225
|
+
- `key`: `id` (required, ID), `for` (optional, `all|graph|node|edge`, default:
|
|
226
|
+
`all`), `attr.name`, `attr.type` (optional,
|
|
227
|
+
`string|int|long|float|double|boolean`, default: `string`), `attr.list`
|
|
228
|
+
(optional, `true|false`, default: `false`), `attr.domain` (optional)
|
|
229
|
+
- `graph`: `id` (optional, ID), `edgedefault` (required, `directed|undirected`),
|
|
230
|
+
parsing attributes (optional)
|
|
231
|
+
- `node`: `id` (required, ID)
|
|
232
|
+
- `edge`: `id` (optional, ID), `source` (required, IDREF), `target` (required,
|
|
233
|
+
IDREF), `directed` (optional, `true|false`, defaults to graph `edgedefault`)
|
|
234
|
+
- `data`: `key` (required, IDREF)
|
|
235
|
+
- `endpoint`: `id` (optional, ID), `node` (required, IDREF), `port` (optional,
|
|
236
|
+
NMTOKEN)
|
|
237
|
+
- `port`: `name` (required, NMTOKEN)
|
|
238
|
+
|
|
239
|
+
## XSD Specification
|
|
240
|
+
|
|
241
|
+
XML Schema Definition (XSD) provides schema validation. More expressive than DTD
|
|
242
|
+
(data types, constraints), defines element/attribute types, supports namespace
|
|
243
|
+
validation.
|
|
244
|
+
|
|
245
|
+
**Complex Types:**
|
|
246
|
+
|
|
247
|
+
- `graphml.type`: Root element type (sequence of `key.type` and `graph.type`,
|
|
248
|
+
keys before graphs)
|
|
249
|
+
- `key.type`: Key element type (optional `desc` and `default`, attributes: `id`
|
|
250
|
+
(required, ID), `for` (optional, `key.for.type`, default: `all`), `attr.name`,
|
|
251
|
+
`attr.type` (optional, `key.attr.type.type`, default: `string`), `attr.list`
|
|
252
|
+
(optional, boolean, default: `false`), `attr.domain`)
|
|
253
|
+
- `graph.type`: Graph element type (sequence of `data.type`, `node.type`,
|
|
254
|
+
`edge.type`, `hyperedge.type`, attributes: `id` (optional, ID), `edgedefault`
|
|
255
|
+
(required, `graph.edgedefault.type`), parsing attributes)
|
|
256
|
+
- `node.type`: Node element type (sequence of `data.type`, `port.type`, optional
|
|
257
|
+
`graph.type`, attributes: `id` (required, ID))
|
|
258
|
+
- `edge.type`: Edge element type (sequence of `data.type`, optional
|
|
259
|
+
`graph.type`, attributes: `id` (optional, ID), `source` (required, IDREF),
|
|
260
|
+
`target` (required, IDREF), `directed` (optional, `edge.directed.type`))
|
|
261
|
+
- `hyperedge.type`: Hyperedge element type (sequence of `data.type`,
|
|
262
|
+
`endpoint.type`, optional `graph.type`, attributes: `id` (optional, ID))
|
|
263
|
+
- `endpoint.type`: Endpoint element type (sequence of `data.type`, optional
|
|
264
|
+
`port.type`, attributes: `id` (optional, ID), `node` (required, IDREF), `port`
|
|
265
|
+
(optional, NMTOKEN))
|
|
266
|
+
- `port.type`: Port element type (sequence of `data.type`, optional
|
|
267
|
+
`graph.type`, attributes: `name` (required, NMTOKEN))
|
|
268
|
+
- `data.type`: Data element type (mixed content: text, `desc`, `default`,
|
|
269
|
+
attributes: `key` (required, IDREF))
|
|
270
|
+
- `desc.type`: Description element type (text content)
|
|
271
|
+
- `default.type`: Default value element type (text content)
|
|
272
|
+
|
|
273
|
+
**Simple Types:**
|
|
274
|
+
|
|
275
|
+
- `key.for.type`: Enumeration (`all`, `graph`, `node`, `edge`, default: `all`)
|
|
276
|
+
- `key.attr.type.type`: Enumeration (`string`, `int`, `long`, `float`, `double`,
|
|
277
|
+
`boolean`, default: `string`)
|
|
278
|
+
- `graph.edgedefault.type`: Enumeration (`directed`, `undirected`, required)
|
|
279
|
+
- `edge.directed.type`: Boolean (`true`/`false`, optional, overrides graph
|
|
280
|
+
`edgedefault`)
|
|
281
|
+
|
|
282
|
+
**Attribute Groups:**
|
|
283
|
+
|
|
284
|
+
- `graph.extra.attrib`, `node.extra.attrib`, `edge.extra.attrib`: Extension
|
|
285
|
+
attributes for extension namespaces
|
|
286
|
+
|
|
287
|
+
## Validation Rules
|
|
288
|
+
|
|
289
|
+
**Document-Level:** Key IDs must be unique, keys must be defined before use,
|
|
290
|
+
multiple graphs allowed.
|
|
291
|
+
|
|
292
|
+
**Graph-Level:** Graph `id` must be unique if specified, `edgedefault` required,
|
|
293
|
+
node/edge/hyperedge IDs must be unique within graph, port names must be unique
|
|
294
|
+
within each node.
|
|
295
|
+
|
|
296
|
+
**Node Rules:** Node `id` required and unique within graph, must be valid XML
|
|
297
|
+
ID.
|
|
298
|
+
|
|
299
|
+
**Edge Rules:** `source` and `target` required, must reference existing node IDs
|
|
300
|
+
(IDREF constraint), `directed` overrides graph `edgedefault` if specified.
|
|
301
|
+
|
|
302
|
+
**Hyperedge Rules:** `id` must be unique if specified, must contain at least one
|
|
303
|
+
`<endpoint>`, endpoint `node` required and must reference existing node ID,
|
|
304
|
+
endpoint `port` must reference existing port name if node has ports.
|
|
305
|
+
|
|
306
|
+
**Port Rules:** `name` required and unique within node, must be valid XML
|
|
307
|
+
NMTOKEN.
|
|
308
|
+
|
|
309
|
+
**Data Rules:** `key` required, must reference defined key ID (IDREF
|
|
310
|
+
constraint), value type must match key's `attr.type` if specified.
|
|
311
|
+
|
|
312
|
+
**Type Validation:** String values (any text), integer/long (valid integer
|
|
313
|
+
format), float/double (valid floating-point format), boolean (`true` or `false`,
|
|
314
|
+
case-sensitive), list values (multiple values separated by whitespace when
|
|
315
|
+
`attr.list="true"`).
|
|
316
|
+
|
|
317
|
+
## Namespace Support
|
|
318
|
+
|
|
319
|
+
**Default namespace:** `http://graphml.graphdrawing.org/xmlns`
|
|
320
|
+
|
|
321
|
+
**XML Schema namespace:** `http://www.w3.org/2001/XMLSchema`
|
|
322
|
+
|
|
323
|
+
**XML Schema Instance namespace:** `http://www.w3.org/2001/XMLSchema-instance`
|
|
324
|
+
|
|
325
|
+
**Extension Namespaces:** Supports extension namespaces for custom
|
|
326
|
+
elements/attributes. Custom attributes in extension namespaces allowed on all
|
|
327
|
+
elements. Custom elements in extension namespaces allowed (must not conflict
|
|
328
|
+
with core elements). Maintains compatibility with core specification when
|
|
329
|
+
extensions used.
|
|
330
|
+
|
|
331
|
+
## Extension Points
|
|
332
|
+
|
|
333
|
+
GraphML allows custom extensions via namespaces: additional elements in
|
|
334
|
+
extension namespaces, custom attributes on standard elements, extension elements
|
|
335
|
+
can appear in standard element content where appropriate. Maintains backward
|
|
336
|
+
compatibility: core parsers ignore unknown extension elements/attributes.
|
|
337
|
+
Extension elements should follow GraphML structure patterns for consistency.
|
package/docs/GRAPHSON.md
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# GraphSON Format Specification
|
|
2
|
+
|
|
3
|
+
> **Version**: 1.0.0
|
|
4
|
+
|
|
5
|
+
JSON-based format for graph serialization used by Apache TinkerPop.
|
|
6
|
+
|
|
7
|
+
**Related Docs:** [GRAPHENGINE.md](GRAPHENGINE.md),
|
|
8
|
+
[TINKERPOP.md](TINKERPOP.md), [GRAPHML.md](GRAPHML.md), [GRYO.md](GRYO.md),
|
|
9
|
+
[GRAPHBINARY.md](GRAPHBINARY.md), [CODEANALYZER.md](CODEANALYZER.md)
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
GraphSON: JSON-based format for graph serialization. Multiple versions (v1, v2,
|
|
14
|
+
v3) with different schemas. Compact and efficient for network transfer. Primary
|
|
15
|
+
format for Gremlin Server communication. Supports typed and untyped property
|
|
16
|
+
values. Human-readable JSON format. Suitable for API communication and web
|
|
17
|
+
applications.
|
|
18
|
+
|
|
19
|
+
## GraphSON Versions
|
|
20
|
+
|
|
21
|
+
**GraphSON v1:** Original format, untyped properties, simple structure, basic
|
|
22
|
+
JSON representation of graph elements. Use cases: legacy systems, simple graph
|
|
23
|
+
representations, when type information is not required.
|
|
24
|
+
|
|
25
|
+
**GraphSON v2:** Typed properties, includes meta-properties (vertex properties
|
|
26
|
+
on vertex properties), more structured format, better type preservation. Use
|
|
27
|
+
cases: when type information is important, complex property structures,
|
|
28
|
+
meta-property support required.
|
|
29
|
+
|
|
30
|
+
**GraphSON v3:** Compact format, optimized for network transfer, typed
|
|
31
|
+
properties, improved efficiency over v2. Use cases: Gremlin Server
|
|
32
|
+
communication, network transfer scenarios, high-performance requirements, modern
|
|
33
|
+
applications.
|
|
34
|
+
|
|
35
|
+
## TinkerPop GraphSON Support
|
|
36
|
+
|
|
37
|
+
**Builder Pattern:**
|
|
38
|
+
|
|
39
|
+
```java
|
|
40
|
+
GraphSONReader reader = GraphSONReader.build()
|
|
41
|
+
.version(GraphSONVersion.V3_0)
|
|
42
|
+
.mapper(new ObjectMapper())
|
|
43
|
+
.create();
|
|
44
|
+
|
|
45
|
+
GraphSONWriter writer = GraphSONWriter.build()
|
|
46
|
+
.version(GraphSONVersion.V3_0)
|
|
47
|
+
.embedTypes(true)
|
|
48
|
+
.includeNullProperties(false)
|
|
49
|
+
.normalize(false)
|
|
50
|
+
.mapper(new ObjectMapper())
|
|
51
|
+
.create();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Reader Methods:** `readGraph(InputStream|File|URL, Graph)`
|
|
55
|
+
|
|
56
|
+
**Writer Methods:** `writeGraph(OutputStream|File|URL, Graph)`
|
|
57
|
+
|
|
58
|
+
**Configuration:**
|
|
59
|
+
|
|
60
|
+
- `version(GraphSONVersion)`: GraphSON version (v1, v2, v3) - must match writer
|
|
61
|
+
version
|
|
62
|
+
- `mapper(ObjectMapper)`: Custom JSON mapper for parsing/generation (Jackson
|
|
63
|
+
ObjectMapper)
|
|
64
|
+
- `embedTypes(boolean)`: Include type information in serialization (default:
|
|
65
|
+
`false` for v1, `true` for v2/v3)
|
|
66
|
+
- `includeNullProperties(boolean)`: Include null property values (default:
|
|
67
|
+
`false`)
|
|
68
|
+
- `normalize(boolean)`: Normalize property keys (default: `false`)
|
|
69
|
+
|
|
70
|
+
**Usage:**
|
|
71
|
+
|
|
72
|
+
```java
|
|
73
|
+
Graph graph = TinkerGraph.open();
|
|
74
|
+
GraphSONReader reader = GraphSONReader.build()
|
|
75
|
+
.version(GraphSONVersion.V3_0)
|
|
76
|
+
.mapper(new ObjectMapper())
|
|
77
|
+
.create();
|
|
78
|
+
reader.readGraph(new File("graph.json"), graph);
|
|
79
|
+
|
|
80
|
+
GraphSONWriter writer = GraphSONWriter.build()
|
|
81
|
+
.version(GraphSONVersion.V3_0)
|
|
82
|
+
.embedTypes(true)
|
|
83
|
+
.includeNullProperties(false)
|
|
84
|
+
.create();
|
|
85
|
+
writer.writeGraph(new File("graph.json"), graph);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Version Compatibility
|
|
89
|
+
|
|
90
|
+
**Important:** GraphSON reader and writer must use the same version for proper
|
|
91
|
+
serialization/deserialization.
|
|
92
|
+
|
|
93
|
+
**Compatibility Rules:** v1 reader can only read v1 files, v2 reader can only
|
|
94
|
+
read v2 files, v3 reader can only read v3 files, version mismatch causes
|
|
95
|
+
deserialization errors.
|
|
96
|
+
|
|
97
|
+
**Best Practice:** Always specify the version explicitly when creating readers
|
|
98
|
+
and writers.
|
|
99
|
+
|
|
100
|
+
## GraphSON Structure
|
|
101
|
+
|
|
102
|
+
GraphSON represents graph elements as JSON objects.
|
|
103
|
+
|
|
104
|
+
### Vertex Representation
|
|
105
|
+
|
|
106
|
+
**GraphSON v1:**
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"id": 1,
|
|
111
|
+
"label": "person",
|
|
112
|
+
"properties": {
|
|
113
|
+
"name": ["John"],
|
|
114
|
+
"age": [30]
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**GraphSON v2/v3 (with types):**
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"id": { "@type": "g:Int32", "@value": 1 },
|
|
124
|
+
"label": "person",
|
|
125
|
+
"properties": {
|
|
126
|
+
"name": [{ "@type": "g:String", "@value": "John" }],
|
|
127
|
+
"age": [{ "@type": "g:Int32", "@value": 30 }]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Edge Representation
|
|
133
|
+
|
|
134
|
+
**GraphSON v1:**
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"id": 7,
|
|
139
|
+
"label": "knows",
|
|
140
|
+
"inV": 2,
|
|
141
|
+
"outV": 1,
|
|
142
|
+
"properties": {
|
|
143
|
+
"weight": 0.5
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**GraphSON v2/v3 (with types):**
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"id": { "@type": "g:Int64", "@value": 7 },
|
|
153
|
+
"label": "knows",
|
|
154
|
+
"inV": { "@type": "g:Int32", "@value": 2 },
|
|
155
|
+
"outV": { "@type": "g:Int32", "@value": 1 },
|
|
156
|
+
"properties": {
|
|
157
|
+
"weight": { "@type": "g:Double", "@value": 0.5 }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Property Representation
|
|
163
|
+
|
|
164
|
+
**GraphSON v1:** Properties are simple JSON values, no type information
|
|
165
|
+
embedded.
|
|
166
|
+
|
|
167
|
+
**GraphSON v2/v3:** Properties can include type information. Format:
|
|
168
|
+
`{"@type": "typeName", "@value": value}`. Type names follow TinkerPop type
|
|
169
|
+
system (e.g., `g:String`, `g:Int32`, `g:Double`).
|
|
170
|
+
|
|
171
|
+
### Meta-Properties (v2/v3 only)
|
|
172
|
+
|
|
173
|
+
Meta-properties (properties on vertex properties) are supported. Represented as
|
|
174
|
+
nested property structures:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"properties": {
|
|
179
|
+
"name": [
|
|
180
|
+
{
|
|
181
|
+
"@type": "g:VertexProperty",
|
|
182
|
+
"@value": {
|
|
183
|
+
"id": { "@type": "g:Int64", "@value": 0 },
|
|
184
|
+
"value": { "@type": "g:String", "@value": "John" },
|
|
185
|
+
"properties": {
|
|
186
|
+
"created": { "@type": "g:Date", "@value": 1234567890 }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Type System
|
|
196
|
+
|
|
197
|
+
GraphSON supports TinkerPop's type system through type embedding.
|
|
198
|
+
|
|
199
|
+
**Supported Types:** Primitive Types (String, Integer, Long, Float, Double,
|
|
200
|
+
Boolean), Date/Time Types (Date, Timestamp), Graph Elements (Vertex, Edge,
|
|
201
|
+
VertexProperty, Property), Collection Types (List, Set, Map), Path Types (Path),
|
|
202
|
+
Special Types (UUID, BigDecimal, BigInteger).
|
|
203
|
+
|
|
204
|
+
**Type Embedding:** When `embedTypes` is `true`, types are embedded in JSON
|
|
205
|
+
using `@type` and `@value` structure. Type names follow TinkerPop conventions
|
|
206
|
+
(e.g., `g:String`, `g:Int32`). Enables proper type preservation during
|
|
207
|
+
serialization/deserialization.
|
|
208
|
+
|
|
209
|
+
## Configuration Best Practices
|
|
210
|
+
|
|
211
|
+
**Reading:** Max Compatibility: `version(GraphSONVersion.V3_0)`, Custom JSON
|
|
212
|
+
Parsing: `mapper(customMapper)` with custom ObjectMapper configuration.
|
|
213
|
+
|
|
214
|
+
**Writing:** Network Transfer (Gremlin Server): `version(GraphSONVersion.V3_0)`,
|
|
215
|
+
`embedTypes(true)`, `includeNullProperties(false)`. Human-Readable Output:
|
|
216
|
+
`version(GraphSONVersion.V2_0)`, `embedTypes(true)`,
|
|
217
|
+
`includeNullProperties(true)`, `normalize(true)`.
|
|
218
|
+
|
|
219
|
+
**General Configuration:** See
|
|
220
|
+
[TINKERPOP.md](TINKERPOP.md#general-configuration-best-practices) for general
|
|
221
|
+
configuration best practices across all formats.
|
|
222
|
+
|
|
223
|
+
## Error Handling
|
|
224
|
+
|
|
225
|
+
**Format-Specific Issues:** Version mismatch (reader and writer versions must
|
|
226
|
+
match), type mismatch (when `embedTypes` is inconsistent between reader/writer),
|
|
227
|
+
invalid JSON (malformed JSON causes parsing errors), missing properties
|
|
228
|
+
(properties may be omitted if `includeNullProperties` is false).
|
|
229
|
+
|
|
230
|
+
**Format-Specific Best Practices:** Always specify version explicitly, use
|
|
231
|
+
consistent configuration between reader and writer, validate JSON before
|
|
232
|
+
parsing, handle missing properties gracefully.
|
|
233
|
+
|
|
234
|
+
**General Error Handling:** See
|
|
235
|
+
[TINKERPOP.md](TINKERPOP.md#general-error-handling-patterns) for common error
|
|
236
|
+
handling patterns across all formats.
|
|
237
|
+
|
|
238
|
+
## Performance Considerations
|
|
239
|
+
|
|
240
|
+
**Format-Specific Optimization Tips:** Use GraphSON v3 for best performance, set
|
|
241
|
+
`includeNullProperties(false)` to reduce output size, use `embedTypes(true)`
|
|
242
|
+
only when type preservation is required, consider compression for large graphs,
|
|
243
|
+
use streaming for very large graphs.
|
|
244
|
+
|
|
245
|
+
**File Size:** More compact than GraphML. Typed format (v2/v3) is slightly
|
|
246
|
+
larger than untyped (v1). Null properties increase file size if included.
|
|
247
|
+
Compression can significantly reduce file size.
|
|
248
|
+
|
|
249
|
+
**General Performance Considerations:** See
|
|
250
|
+
[TINKERPOP.md](TINKERPOP.md#general-performance-considerations) for format
|
|
251
|
+
comparison and general optimization tips.
|
|
252
|
+
|
|
253
|
+
## Examples
|
|
254
|
+
|
|
255
|
+
**Complete GraphSON Example (v3):**
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"vertices": [
|
|
260
|
+
{
|
|
261
|
+
"id": { "@type": "g:Int32", "@value": 1 },
|
|
262
|
+
"label": "person",
|
|
263
|
+
"properties": {
|
|
264
|
+
"name": [{ "@type": "g:String", "@value": "Alice" }],
|
|
265
|
+
"age": [{ "@type": "g:Int32", "@value": 30 }]
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
],
|
|
269
|
+
"edges": [
|
|
270
|
+
{
|
|
271
|
+
"id": { "@type": "g:Int64", "@value": 7 },
|
|
272
|
+
"label": "knows",
|
|
273
|
+
"inV": { "@type": "g:Int32", "@value": 2 },
|
|
274
|
+
"outV": { "@type": "g:Int32", "@value": 1 },
|
|
275
|
+
"properties": {
|
|
276
|
+
"weight": { "@type": "g:Double", "@value": 0.5 }
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Reading and Writing:**
|
|
284
|
+
|
|
285
|
+
```java
|
|
286
|
+
Graph graph = TinkerGraph.open();
|
|
287
|
+
Vertex alice = graph.addVertex(T.label, "person", "name", "Alice", "age", 30);
|
|
288
|
+
Vertex bob = graph.addVertex(T.label, "person", "name", "Bob", "age", 25);
|
|
289
|
+
alice.addEdge("knows", bob, "weight", 0.5);
|
|
290
|
+
|
|
291
|
+
GraphSONWriter writer = GraphSONWriter.build()
|
|
292
|
+
.version(GraphSONVersion.V3_0)
|
|
293
|
+
.embedTypes(true)
|
|
294
|
+
.create();
|
|
295
|
+
writer.writeGraph(new File("graph.json"), graph);
|
|
296
|
+
|
|
297
|
+
Graph readGraph = TinkerGraph.open();
|
|
298
|
+
GraphSONReader reader = GraphSONReader.build()
|
|
299
|
+
.version(GraphSONVersion.V3_0)
|
|
300
|
+
.create();
|
|
301
|
+
reader.readGraph(new File("graph.json"), readGraph);
|
|
302
|
+
```
|