@graphty/graph-format 0.0.0 → 0.2.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.
Files changed (224) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -43
  3. package/dist/graph-format.d.ts +1 -0
  4. package/dist/graph-format.d.ts.map +1 -0
  5. package/dist/graph-format.js +15798 -0
  6. package/dist/graph-format.js.map +1 -0
  7. package/dist/src/builder/arena.d.ts +85 -0
  8. package/dist/src/builder/arena.d.ts.map +1 -0
  9. package/dist/src/builder/arena.js +154 -0
  10. package/dist/src/builder/arena.js.map +1 -0
  11. package/dist/src/builder/compact.d.ts +515 -0
  12. package/dist/src/builder/compact.d.ts.map +1 -0
  13. package/dist/src/builder/compact.js +1553 -0
  14. package/dist/src/builder/compact.js.map +1 -0
  15. package/dist/src/builder/counting-sort.d.ts +96 -0
  16. package/dist/src/builder/counting-sort.d.ts.map +1 -0
  17. package/dist/src/builder/counting-sort.js +430 -0
  18. package/dist/src/builder/counting-sort.js.map +1 -0
  19. package/dist/src/builder/freeze.d.ts +72 -0
  20. package/dist/src/builder/freeze.d.ts.map +1 -0
  21. package/dist/src/builder/freeze.js +548 -0
  22. package/dist/src/builder/freeze.js.map +1 -0
  23. package/dist/src/builder/graph-builder.d.ts +602 -0
  24. package/dist/src/builder/graph-builder.d.ts.map +1 -0
  25. package/dist/src/builder/graph-builder.js +1940 -0
  26. package/dist/src/builder/graph-builder.js.map +1 -0
  27. package/dist/src/builder/options.d.ts +16 -0
  28. package/dist/src/builder/options.d.ts.map +1 -0
  29. package/dist/src/builder/options.js +21 -0
  30. package/dist/src/builder/options.js.map +1 -0
  31. package/dist/src/columns/bitmap.d.ts +96 -0
  32. package/dist/src/columns/bitmap.d.ts.map +1 -0
  33. package/dist/src/columns/bitmap.js +184 -0
  34. package/dist/src/columns/bitmap.js.map +1 -0
  35. package/dist/src/columns/column.d.ts +220 -0
  36. package/dist/src/columns/column.d.ts.map +1 -0
  37. package/dist/src/columns/column.js +2109 -0
  38. package/dist/src/columns/column.js.map +1 -0
  39. package/dist/src/columns/dictionary.d.ts +60 -0
  40. package/dist/src/columns/dictionary.d.ts.map +1 -0
  41. package/dist/src/columns/dictionary.js +102 -0
  42. package/dist/src/columns/dictionary.js.map +1 -0
  43. package/dist/src/columns/growable.d.ts +198 -0
  44. package/dist/src/columns/growable.d.ts.map +1 -0
  45. package/dist/src/columns/growable.js +296 -0
  46. package/dist/src/columns/growable.js.map +1 -0
  47. package/dist/src/columns/infer.d.ts +121 -0
  48. package/dist/src/columns/infer.d.ts.map +1 -0
  49. package/dist/src/columns/infer.js +268 -0
  50. package/dist/src/columns/infer.js.map +1 -0
  51. package/dist/src/columns/remap.d.ts +143 -0
  52. package/dist/src/columns/remap.d.ts.map +1 -0
  53. package/dist/src/columns/remap.js +588 -0
  54. package/dist/src/columns/remap.js.map +1 -0
  55. package/dist/src/columns/table.d.ts +184 -0
  56. package/dist/src/columns/table.d.ts.map +1 -0
  57. package/dist/src/columns/table.js +485 -0
  58. package/dist/src/columns/table.js.map +1 -0
  59. package/dist/src/constants.d.ts +34 -0
  60. package/dist/src/constants.d.ts.map +1 -0
  61. package/dist/src/constants.js +79 -0
  62. package/dist/src/constants.js.map +1 -0
  63. package/dist/src/errors.d.ts +76 -0
  64. package/dist/src/errors.d.ts.map +1 -0
  65. package/dist/src/errors.js +32 -0
  66. package/dist/src/errors.js.map +1 -0
  67. package/dist/src/ids/edge-id-index.d.ts +77 -0
  68. package/dist/src/ids/edge-id-index.d.ts.map +1 -0
  69. package/dist/src/ids/edge-id-index.js +155 -0
  70. package/dist/src/ids/edge-id-index.js.map +1 -0
  71. package/dist/src/ids/node-id-map.d.ts +280 -0
  72. package/dist/src/ids/node-id-map.d.ts.map +1 -0
  73. package/dist/src/ids/node-id-map.js +1139 -0
  74. package/dist/src/ids/node-id-map.js.map +1 -0
  75. package/dist/src/ids/string-store.d.ts +219 -0
  76. package/dist/src/ids/string-store.d.ts.map +1 -0
  77. package/dist/src/ids/string-store.js +526 -0
  78. package/dist/src/ids/string-store.js.map +1 -0
  79. package/dist/src/index.d.ts +30 -0
  80. package/dist/src/index.d.ts.map +1 -0
  81. package/dist/src/index.js +29 -0
  82. package/dist/src/index.js.map +1 -0
  83. package/dist/src/populate/from-csr.d.ts +61 -0
  84. package/dist/src/populate/from-csr.d.ts.map +1 -0
  85. package/dist/src/populate/from-csr.js +706 -0
  86. package/dist/src/populate/from-csr.js.map +1 -0
  87. package/dist/src/populate/from-edge-arrays.d.ts +51 -0
  88. package/dist/src/populate/from-edge-arrays.d.ts.map +1 -0
  89. package/dist/src/populate/from-edge-arrays.js +217 -0
  90. package/dist/src/populate/from-edge-arrays.js.map +1 -0
  91. package/dist/src/populate/from-records.d.ts +51 -0
  92. package/dist/src/populate/from-records.d.ts.map +1 -0
  93. package/dist/src/populate/from-records.js +447 -0
  94. package/dist/src/populate/from-records.js.map +1 -0
  95. package/dist/src/snapshot/derived.d.ts +211 -0
  96. package/dist/src/snapshot/derived.d.ts.map +1 -0
  97. package/dist/src/snapshot/derived.js +1254 -0
  98. package/dist/src/snapshot/derived.js.map +1 -0
  99. package/dist/src/snapshot/graph-meta.d.ts +23 -0
  100. package/dist/src/snapshot/graph-meta.d.ts.map +1 -0
  101. package/dist/src/snapshot/graph-meta.js +159 -0
  102. package/dist/src/snapshot/graph-meta.js.map +1 -0
  103. package/dist/src/snapshot/graph-snapshot.d.ts +509 -0
  104. package/dist/src/snapshot/graph-snapshot.d.ts.map +1 -0
  105. package/dist/src/snapshot/graph-snapshot.js +1247 -0
  106. package/dist/src/snapshot/graph-snapshot.js.map +1 -0
  107. package/dist/src/snapshot/hash.d.ts +90 -0
  108. package/dist/src/snapshot/hash.d.ts.map +1 -0
  109. package/dist/src/snapshot/hash.js +228 -0
  110. package/dist/src/snapshot/hash.js.map +1 -0
  111. package/dist/src/snapshot/queries.d.ts +74 -0
  112. package/dist/src/snapshot/queries.d.ts.map +1 -0
  113. package/dist/src/snapshot/queries.js +131 -0
  114. package/dist/src/snapshot/queries.js.map +1 -0
  115. package/dist/src/snapshot/validate.d.ts +192 -0
  116. package/dist/src/snapshot/validate.d.ts.map +1 -0
  117. package/dist/src/snapshot/validate.js +990 -0
  118. package/dist/src/snapshot/validate.js.map +1 -0
  119. package/dist/src/snapshot/views.d.ts +274 -0
  120. package/dist/src/snapshot/views.d.ts.map +1 -0
  121. package/dist/src/snapshot/views.js +856 -0
  122. package/dist/src/snapshot/views.js.map +1 -0
  123. package/dist/src/types/builder.d.ts +456 -0
  124. package/dist/src/types/builder.d.ts.map +1 -0
  125. package/dist/src/types/builder.js +11 -0
  126. package/dist/src/types/builder.js.map +1 -0
  127. package/dist/src/types/columns.d.ts +615 -0
  128. package/dist/src/types/columns.d.ts.map +1 -0
  129. package/dist/src/types/columns.js +14 -0
  130. package/dist/src/types/columns.js.map +1 -0
  131. package/dist/src/types/index.d.ts +14 -0
  132. package/dist/src/types/index.d.ts.map +1 -0
  133. package/dist/src/types/index.js +11 -0
  134. package/dist/src/types/index.js.map +1 -0
  135. package/dist/src/types/internal.d.ts +172 -0
  136. package/dist/src/types/internal.d.ts.map +1 -0
  137. package/dist/src/types/internal.js +13 -0
  138. package/dist/src/types/internal.js.map +1 -0
  139. package/dist/src/types/snapshot.d.ts +801 -0
  140. package/dist/src/types/snapshot.d.ts.map +1 -0
  141. package/dist/src/types/snapshot.js +14 -0
  142. package/dist/src/types/snapshot.js.map +1 -0
  143. package/dist/src/types/wire.d.ts +196 -0
  144. package/dist/src/types/wire.d.ts.map +1 -0
  145. package/dist/src/types/wire.js +8 -0
  146. package/dist/src/types/wire.js.map +1 -0
  147. package/dist/src/util/mask.d.ts +55 -0
  148. package/dist/src/util/mask.d.ts.map +1 -0
  149. package/dist/src/util/mask.js +71 -0
  150. package/dist/src/util/mask.js.map +1 -0
  151. package/dist/src/util/options.d.ts +22 -0
  152. package/dist/src/util/options.d.ts.map +1 -0
  153. package/dist/src/util/options.js +49 -0
  154. package/dist/src/util/options.js.map +1 -0
  155. package/dist/src/util/shared-buffers.d.ts +42 -0
  156. package/dist/src/util/shared-buffers.d.ts.map +1 -0
  157. package/dist/src/util/shared-buffers.js +52 -0
  158. package/dist/src/util/shared-buffers.js.map +1 -0
  159. package/dist/src/util/typed-array.d.ts +205 -0
  160. package/dist/src/util/typed-array.d.ts.map +1 -0
  161. package/dist/src/util/typed-array.js +289 -0
  162. package/dist/src/util/typed-array.js.map +1 -0
  163. package/dist/src/wire/bytes.d.ts +69 -0
  164. package/dist/src/wire/bytes.d.ts.map +1 -0
  165. package/dist/src/wire/bytes.js +361 -0
  166. package/dist/src/wire/bytes.js.map +1 -0
  167. package/dist/src/wire/carried-views.d.ts +111 -0
  168. package/dist/src/wire/carried-views.d.ts.map +1 -0
  169. package/dist/src/wire/carried-views.js +286 -0
  170. package/dist/src/wire/carried-views.js.map +1 -0
  171. package/dist/src/wire/from-wire.d.ts +144 -0
  172. package/dist/src/wire/from-wire.d.ts.map +1 -0
  173. package/dist/src/wire/from-wire.js +1425 -0
  174. package/dist/src/wire/from-wire.js.map +1 -0
  175. package/dist/src/wire/to-wire.d.ts +171 -0
  176. package/dist/src/wire/to-wire.d.ts.map +1 -0
  177. package/dist/src/wire/to-wire.js +652 -0
  178. package/dist/src/wire/to-wire.js.map +1 -0
  179. package/dist/tsconfig.build.tsbuildinfo +1 -0
  180. package/package.json +72 -7
  181. package/src/builder/arena.ts +192 -0
  182. package/src/builder/compact.ts +1811 -0
  183. package/src/builder/counting-sort.ts +506 -0
  184. package/src/builder/freeze.ts +689 -0
  185. package/src/builder/graph-builder.ts +2264 -0
  186. package/src/builder/options.ts +29 -0
  187. package/src/columns/bitmap.ts +196 -0
  188. package/src/columns/column.ts +2574 -0
  189. package/src/columns/dictionary.ts +114 -0
  190. package/src/columns/growable.ts +350 -0
  191. package/src/columns/infer.ts +285 -0
  192. package/src/columns/remap.ts +663 -0
  193. package/src/columns/table.ts +568 -0
  194. package/src/constants.ts +89 -0
  195. package/src/errors.ts +115 -0
  196. package/src/ids/edge-id-index.ts +179 -0
  197. package/src/ids/node-id-map.ts +1340 -0
  198. package/src/ids/string-store.ts +589 -0
  199. package/src/index.ts +139 -0
  200. package/src/lib-resizable-array-buffer.d.ts +34 -0
  201. package/src/populate/from-csr.ts +802 -0
  202. package/src/populate/from-edge-arrays.ts +257 -0
  203. package/src/populate/from-records.ts +536 -0
  204. package/src/snapshot/derived.ts +1486 -0
  205. package/src/snapshot/graph-meta.ts +167 -0
  206. package/src/snapshot/graph-snapshot.ts +1503 -0
  207. package/src/snapshot/hash.ts +241 -0
  208. package/src/snapshot/queries.ts +136 -0
  209. package/src/snapshot/validate.ts +1108 -0
  210. package/src/snapshot/views.ts +943 -0
  211. package/src/types/builder.ts +480 -0
  212. package/src/types/columns.ts +727 -0
  213. package/src/types/index.ts +14 -0
  214. package/src/types/internal.ts +195 -0
  215. package/src/types/snapshot.ts +886 -0
  216. package/src/types/wire.ts +207 -0
  217. package/src/util/mask.ts +89 -0
  218. package/src/util/options.ts +57 -0
  219. package/src/util/shared-buffers.ts +56 -0
  220. package/src/util/typed-array.ts +371 -0
  221. package/src/wire/bytes.ts +440 -0
  222. package/src/wire/carried-views.ts +327 -0
  223. package/src/wire/from-wire.ts +1690 -0
  224. package/src/wire/to-wire.ts +755 -0
@@ -0,0 +1,280 @@
1
+ /**
2
+ * The immutable id-to-index bijection of a snapshot (design section 4): five storage kinds chosen by
3
+ * inspecting the ids once in O(n), SameValueZero equality, `INVALID_INDEX` on a miss, a dense-integer
4
+ * fast path with no Map at all, lazily materialised typed / decoded representations in either
5
+ * direction, and a reverse `Map` that is shared with the builder (guarded by `index < size`) or built
6
+ * lazily on the first lookup.
7
+ *
8
+ * The class exposes exactly the public surface of design section 12.2. Everything the sibling
9
+ * modules need beyond it (construction from ids, typed arrays or the wire; the typed form for the
10
+ * wire; gather and remap for derived graphs and compaction) is a module-level function that reaches
11
+ * the private storage through a module-private WeakMap, so nothing internal appears on the instance
12
+ * type.
13
+ */
14
+ import { type F64, type NodeId, type NodeIdMapContract, type NodeIdMapKind, type U8, type U32, type ValidationLevel } from "../types/index.js";
15
+ /**
16
+ * A short, plain-ASCII rendering of an id for error messages.
17
+ * @param id - the value
18
+ * @returns the number, a quoted (possibly truncated) string, or the type name
19
+ */
20
+ export declare function describeId(id: unknown): string;
21
+ /**
22
+ * Check a value as a node id and normalise it (design section 4.1): a finite number (`-0` becomes
23
+ * `0`) or a string without a lone surrogate. NaN, non-finite numbers, bigints, objects, null and
24
+ * undefined are E_INVALID_ID; a lone surrogate is E_INVALID_ID with details.reason "lone surrogate".
25
+ * @param id - the value to check
26
+ * @returns the id as stored
27
+ */
28
+ export declare function validateNodeId(id: unknown): NodeId;
29
+ /** The typed representation of an id map, one slot per wire member (design section 4.5). */
30
+ export interface NodeIdMapTypedParts {
31
+ /** The storage kind. */
32
+ readonly kind: NodeIdMapKind;
33
+ /** Number of ids. */
34
+ readonly size: number;
35
+ /** identity only: id === index + offset; 0 otherwise. */
36
+ readonly offset: number;
37
+ /** dense: u32 ids per index; numeric: f64 ids per index; null otherwise. */
38
+ readonly values: U32 | F64 | null;
39
+ /** mixed: u8 tag per index (0 number, 1 string); null otherwise. */
40
+ readonly tags: U8 | null;
41
+ /** mixed: f64 per index (0 where string); null otherwise. */
42
+ readonly numbers: F64 | null;
43
+ /** string / mixed: rows + 1 offsets of the Utf8 store; null otherwise. */
44
+ readonly offsets: U32 | null;
45
+ /** string / mixed: the UTF-8 bytes; null otherwise. */
46
+ readonly utf8: U8 | null;
47
+ }
48
+ /**
49
+ * Whether an id map's typed storage was transferred away (design section 9.1), for validate().
50
+ * @param map - the id map
51
+ * @returns true when detached
52
+ */
53
+ export declare function idMapDetached(map: NodeIdMap): boolean;
54
+ /**
55
+ * Bijection between node ids and node indices for one snapshot (design section 4, invariant I11):
56
+ * `indexOf(idOf(i)) === i` for every i, `size === nodeCount`, SameValueZero equality (so `1` and
57
+ * `"1"` are distinct, `-0` is `0`, `1.5` is legal and `NaN` never occurs). Immutable. Lookups by id
58
+ * are total and return `INVALID_INDEX` on a miss (decision C9); `requireIndex` is the checked form.
59
+ *
60
+ * Instances are created by the module-level factories (`nodeIdMapFromIds`, `nodeIdMapFromF64`,
61
+ * `identityNodeIdMap`, `nodeIdMapFromTyped`) and by `gatherNodeIdMap` / `remapNodeIdMap`; the
62
+ * constructor takes a prepared storage record and is not meant to be called by consumers.
63
+ */
64
+ export declare class NodeIdMap implements NodeIdMapContract {
65
+ /** The storage kind (design section 4.2). */
66
+ readonly kind: NodeIdMapKind;
67
+ /** Number of ids; equals nodeCount. */
68
+ readonly size: number;
69
+ /** identity only: id === index + offset (0 or 1 in practice); 0 for every other kind. */
70
+ readonly offset: number;
71
+ /** The private storage; also registered in INTERNALS for the module-level functions. */
72
+ private readonly storage;
73
+ /**
74
+ * The id of a node index.
75
+ * @param index - the node index
76
+ * @returns the id; E_INDEX_RANGE when index is not an integer in [0, size)
77
+ */
78
+ idOf(index: number): NodeId;
79
+ /**
80
+ * Total lookup by id: SameValueZero, never coerces, so `indexOf("1")` misses a map of numbers.
81
+ * @param id - the node id
82
+ * @returns the node index, or INVALID_INDEX when absent
83
+ */
84
+ indexOf(id: NodeId): number;
85
+ /**
86
+ * Whether an id is present.
87
+ * @param id - the node id
88
+ * @returns true when present
89
+ */
90
+ has(id: NodeId): boolean;
91
+ /**
92
+ * Checked lookup by id, for algorithms that today throw "node not found".
93
+ * @param id - the node id
94
+ * @returns the node index; E_UNKNOWN_NODE when absent
95
+ */
96
+ requireIndex(id: NodeId): number;
97
+ /**
98
+ * Bulk lookup.
99
+ * @param ids - the ids to resolve
100
+ * @param onMissing - "invalid" (default) writes INVALID_INDEX for a miss; "throw" raises E_UNKNOWN_NODE
101
+ * @returns a fresh U32 of indices in input order
102
+ */
103
+ indicesOf(ids: Iterable<NodeId>, onMissing?: "invalid" | "throw"): U32;
104
+ /**
105
+ * Bulk decode of a range of ids in one pass. Bounds follow Array.prototype.slice (negative values
106
+ * count from the end, out-of-range values are clamped).
107
+ * @param start - first index (default 0)
108
+ * @param end - one past the last index (default size)
109
+ * @returns a fresh array of the ids in index order
110
+ */
111
+ idsSlice(start?: number, end?: number): NodeId[];
112
+ /**
113
+ * Every id in index order.
114
+ * @returns a fresh array
115
+ */
116
+ toArray(): NodeId[];
117
+ /**
118
+ * Iterate the ids in index order.
119
+ * @yields each id, decoding lazily
120
+ */
121
+ [Symbol.iterator](): IterableIterator<NodeId>;
122
+ /**
123
+ * Key an index-aligned result vector by id (boundary helper, decision C11).
124
+ * @param values - one value per node index
125
+ * @returns a Map from id to value, in index order
126
+ */
127
+ toMap<T>(values: ArrayLike<T>): Map<NodeId, T>;
128
+ /**
129
+ * Key an index-aligned result vector by String(id), for legacy Map<string, T> result shapes. When
130
+ * two ids share a string form (1 and "1") the HIGHER index wins, exactly as the legacy
131
+ * algorithms' assignment in node order does (design section 14.2).
132
+ * @param values - one value per node index
133
+ * @returns a Map from String(id) to value
134
+ */
135
+ toStringMap<T>(values: ArrayLike<T>): Map<string, T>;
136
+ /**
137
+ * Key an index-aligned result vector by String(id), for legacy record result shapes only. The
138
+ * record has a null prototype so ids such as "__proto__" are ordinary keys; when two ids share a
139
+ * string form the HIGHER index wins (the legacy assignment order, design section 14.2).
140
+ * @param values - one value per node index
141
+ * @returns a record from String(id) to value
142
+ */
143
+ toRecord<T>(values: ArrayLike<T>): Record<string, T>;
144
+ /**
145
+ * Iterate [id, value] pairs of an index-aligned result vector.
146
+ * @param values - one value per node index
147
+ * @yields the pairs in index order
148
+ */
149
+ entries<T>(values: ArrayLike<T>): IterableIterator<[NodeId, T]>;
150
+ /**
151
+ * String(idOf(i)) -> i, built lazily once, for legacy string-typed id parameters. When two ids
152
+ * share a string form (always one number and one string, since ids are distinct) the STRING id
153
+ * wins: a legacy string parameter "1" addressed the node whose id is the string "1".
154
+ * @returns the read-only string index
155
+ */
156
+ stringIndex(): ReadonlyMap<string, number>;
157
+ /**
158
+ * Bytes of typed storage currently materialised; excludes the reverse Map and JS strings.
159
+ * @returns the byte count
160
+ */
161
+ byteLength(): number;
162
+ /**
163
+ * Unchecked id of an in-range index.
164
+ * @param index - a node index in [0, size)
165
+ * @returns the id
166
+ */
167
+ private idAt;
168
+ /**
169
+ * E_DETACHED when a typed array the map reads from was transferred away (design sections 9.1
170
+ * and 11.3): derived from the array state (a transferred buffer leaves zero-length views).
171
+ */
172
+ private assertAttached;
173
+ /**
174
+ * The reverse map of a numeric / string / mixed map, built on first use (one pass over the ids,
175
+ * after a bulk decode of a wire-decoded Utf8 store) when it was not shared by the builder.
176
+ * @returns the map from id to index
177
+ */
178
+ private reverseMap;
179
+ }
180
+ /**
181
+ * An identity map: id === index + offset, no storage at all (design section 4.2). What
182
+ * `fromEdgeArrays` without ids and `contract()` produce; offset 1 covers 1-based files.
183
+ * @param size - the node count
184
+ * @param offset - the integer added to every index; default 0
185
+ * @returns the map
186
+ */
187
+ export declare function identityNodeIdMap(size: number, offset?: number): NodeIdMap;
188
+ /** Options of nodeIdMapFromIds. */
189
+ interface FromIdsOptions {
190
+ /**
191
+ * The builder's reverse map, shared by reference and guarded by `index < size` (decision C17). When
192
+ * given, the ids are trusted (already validated and distinct) and `validate` is ignored.
193
+ */
194
+ readonly map?: Map<NodeId, number> | undefined;
195
+ /**
196
+ * Check every id (E_INVALID_ID) and their distinctness (E_DUPLICATE_ID), copying the array and
197
+ * normalising -0; default true. false trusts the caller (derived graphs) and shares the array.
198
+ */
199
+ readonly validate?: boolean | undefined;
200
+ }
201
+ /**
202
+ * Build a map from decoded ids in index order, choosing the kind in one O(n) pass (design section
203
+ * 4.2, freeze step 9). With `options.map` (the builder's Map) the array and the Map are shared by
204
+ * reference and nothing is validated; identity and dense maps drop the Map. Without it the ids are
205
+ * validated and copied unless `validate` is false.
206
+ * @param ids - the ids; only entries below `size` are read
207
+ * @param size - the node count; default ids.length
208
+ * @param options - the shared map and validation switch
209
+ * @returns the map
210
+ */
211
+ export declare function nodeIdMapFromIds(ids: readonly NodeId[], size?: number, options?: FromIdsOptions): NodeIdMap;
212
+ /** Options of nodeIdMapFromF64. */
213
+ interface FromF64Options {
214
+ /**
215
+ * Check that every value is finite (E_INVALID_ID) and that the values are distinct (E_DUPLICATE_ID);
216
+ * default true. The array is adopted by reference either way; -0 entries are rewritten to 0 in a
217
+ * copy when validating.
218
+ */
219
+ readonly validate?: boolean | undefined;
220
+ }
221
+ /**
222
+ * Build a map from numeric ids in a Float64Array (the `ids: F64` form of `fromEdgeArrays` /
223
+ * `fromCsr`), choosing identity, dense or numeric in one pass. A numeric map adopts the array as its
224
+ * typed representation.
225
+ * @param values - one id per index
226
+ * @param options - the validation switch
227
+ * @returns the map
228
+ */
229
+ export declare function nodeIdMapFromF64(values: F64, options?: FromF64Options): NodeIdMap;
230
+ /**
231
+ * The distinct backing buffers of an id map's materialised typed storage (dense values and inverse,
232
+ * numbers, tags, an encoded Utf8 store), for the owner count of design section 9.1.
233
+ * @param map - the id map
234
+ * @returns the buffers, each once
235
+ */
236
+ export declare function idMapBuffers(map: NodeIdMap): ArrayBuffer[];
237
+ /**
238
+ * Build a map from its typed (wire) representation (design sections 4.5 and 9.5), adopting the arrays
239
+ * by reference. "structure" checks lengths, tag values, the dense bound and the Utf8 layout
240
+ * (E_BAD_SERIALIZATION with details.ref); "full" additionally checks invariant I11: finite numbers,
241
+ * well-formed UTF-8 (a fatal decode) and distinct ids (E_INVALID_SNAPSHOT with details.invariant
242
+ * "I11"), building the reverse map eagerly. A dense duplicate is always detected because the inverse
243
+ * array is rebuilt on load. An unknown kind is E_UNSUPPORTED with details.kind.
244
+ * @param parts - the typed representation
245
+ * @param validate - the validation level; default "structure"
246
+ * @returns the map
247
+ */
248
+ export declare function nodeIdMapFromTyped(parts: NodeIdMapTypedParts, validate?: ValidationLevel): NodeIdMap;
249
+ /**
250
+ * The typed (wire) representation of a map (design section 4.5), materialising and caching whatever
251
+ * the map only held in decoded form: the F64 of a numeric map, the Utf8 store of a string map, the
252
+ * tags + numbers + Utf8 store of a mixed map. The dense inverse and the reverse Map are never part
253
+ * of it. Repeated calls return the same arrays.
254
+ * @param map - the id map
255
+ * @returns the typed parts; every slot the kind does not use is null
256
+ */
257
+ export declare function nodeIdMapToTyped(map: NodeIdMap): NodeIdMapTypedParts;
258
+ /**
259
+ * The map of a gathered node space: `out.idOf(i) === map.idOf(indexMap[i])` (design section 7.3:
260
+ * inducedSubgraph, relabel). The kind is re-detected from the gathered ids, so an identity map
261
+ * gathered through a prefix stays identity and otherwise becomes dense or numeric per the rules of
262
+ * design section 4.2. The caller guarantees indexMap has no repeats (a permutation or a selection),
263
+ * so the result is a bijection without re-validation.
264
+ * @param map - the source map
265
+ * @param indexMap - new index -> source index; E_INDEX_RANGE when an entry is out of range
266
+ * @returns the gathered map
267
+ */
268
+ export declare function gatherNodeIdMap(map: NodeIdMap, indexMap: U32): NodeIdMap;
269
+ /**
270
+ * The map of a compacted node space: `out.idOf(remap[old]) === map.idOf(old)` for every old index
271
+ * whose entry is not INVALID_INDEX (design sections 4.4 and 6.3 step 1). Every new index must be hit
272
+ * exactly once.
273
+ * @param map - the source map
274
+ * @param remap - old index -> new index or INVALID_INDEX; length === map.size
275
+ * @param newSize - the compacted node count
276
+ * @returns the remapped map; E_INDEX_RANGE when remap is not a surjection onto [0, newSize)
277
+ */
278
+ export declare function remapNodeIdMap(map: NodeIdMap, remap: U32, newSize: number): NodeIdMap;
279
+ export {};
280
+ //# sourceMappingURL=node-id-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-id-map.d.ts","sourceRoot":"","sources":["../../../src/ids/node-id-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EACH,KAAK,GAAG,EACR,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,EAAE,EACP,KAAK,GAAG,EACR,KAAK,eAAe,EACvB,MAAM,mBAAmB,CAAC;AAO3B;;;;GAIG;AACH,wBAAgB,UAAU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