@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.
- package/LICENSE +21 -0
- package/README.md +216 -43
- package/dist/graph-format.d.ts +1 -0
- package/dist/graph-format.d.ts.map +1 -0
- package/dist/graph-format.js +15798 -0
- package/dist/graph-format.js.map +1 -0
- package/dist/src/builder/arena.d.ts +85 -0
- package/dist/src/builder/arena.d.ts.map +1 -0
- package/dist/src/builder/arena.js +154 -0
- package/dist/src/builder/arena.js.map +1 -0
- package/dist/src/builder/compact.d.ts +515 -0
- package/dist/src/builder/compact.d.ts.map +1 -0
- package/dist/src/builder/compact.js +1553 -0
- package/dist/src/builder/compact.js.map +1 -0
- package/dist/src/builder/counting-sort.d.ts +96 -0
- package/dist/src/builder/counting-sort.d.ts.map +1 -0
- package/dist/src/builder/counting-sort.js +430 -0
- package/dist/src/builder/counting-sort.js.map +1 -0
- package/dist/src/builder/freeze.d.ts +72 -0
- package/dist/src/builder/freeze.d.ts.map +1 -0
- package/dist/src/builder/freeze.js +548 -0
- package/dist/src/builder/freeze.js.map +1 -0
- package/dist/src/builder/graph-builder.d.ts +602 -0
- package/dist/src/builder/graph-builder.d.ts.map +1 -0
- package/dist/src/builder/graph-builder.js +1940 -0
- package/dist/src/builder/graph-builder.js.map +1 -0
- package/dist/src/builder/options.d.ts +16 -0
- package/dist/src/builder/options.d.ts.map +1 -0
- package/dist/src/builder/options.js +21 -0
- package/dist/src/builder/options.js.map +1 -0
- package/dist/src/columns/bitmap.d.ts +96 -0
- package/dist/src/columns/bitmap.d.ts.map +1 -0
- package/dist/src/columns/bitmap.js +184 -0
- package/dist/src/columns/bitmap.js.map +1 -0
- package/dist/src/columns/column.d.ts +220 -0
- package/dist/src/columns/column.d.ts.map +1 -0
- package/dist/src/columns/column.js +2109 -0
- package/dist/src/columns/column.js.map +1 -0
- package/dist/src/columns/dictionary.d.ts +60 -0
- package/dist/src/columns/dictionary.d.ts.map +1 -0
- package/dist/src/columns/dictionary.js +102 -0
- package/dist/src/columns/dictionary.js.map +1 -0
- package/dist/src/columns/growable.d.ts +198 -0
- package/dist/src/columns/growable.d.ts.map +1 -0
- package/dist/src/columns/growable.js +296 -0
- package/dist/src/columns/growable.js.map +1 -0
- package/dist/src/columns/infer.d.ts +121 -0
- package/dist/src/columns/infer.d.ts.map +1 -0
- package/dist/src/columns/infer.js +268 -0
- package/dist/src/columns/infer.js.map +1 -0
- package/dist/src/columns/remap.d.ts +143 -0
- package/dist/src/columns/remap.d.ts.map +1 -0
- package/dist/src/columns/remap.js +588 -0
- package/dist/src/columns/remap.js.map +1 -0
- package/dist/src/columns/table.d.ts +184 -0
- package/dist/src/columns/table.d.ts.map +1 -0
- package/dist/src/columns/table.js +485 -0
- package/dist/src/columns/table.js.map +1 -0
- package/dist/src/constants.d.ts +34 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +79 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/errors.d.ts +76 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +32 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/ids/edge-id-index.d.ts +77 -0
- package/dist/src/ids/edge-id-index.d.ts.map +1 -0
- package/dist/src/ids/edge-id-index.js +155 -0
- package/dist/src/ids/edge-id-index.js.map +1 -0
- package/dist/src/ids/node-id-map.d.ts +280 -0
- package/dist/src/ids/node-id-map.d.ts.map +1 -0
- package/dist/src/ids/node-id-map.js +1139 -0
- package/dist/src/ids/node-id-map.js.map +1 -0
- package/dist/src/ids/string-store.d.ts +219 -0
- package/dist/src/ids/string-store.d.ts.map +1 -0
- package/dist/src/ids/string-store.js +526 -0
- package/dist/src/ids/string-store.js.map +1 -0
- package/dist/src/index.d.ts +30 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +29 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/populate/from-csr.d.ts +61 -0
- package/dist/src/populate/from-csr.d.ts.map +1 -0
- package/dist/src/populate/from-csr.js +706 -0
- package/dist/src/populate/from-csr.js.map +1 -0
- package/dist/src/populate/from-edge-arrays.d.ts +51 -0
- package/dist/src/populate/from-edge-arrays.d.ts.map +1 -0
- package/dist/src/populate/from-edge-arrays.js +217 -0
- package/dist/src/populate/from-edge-arrays.js.map +1 -0
- package/dist/src/populate/from-records.d.ts +51 -0
- package/dist/src/populate/from-records.d.ts.map +1 -0
- package/dist/src/populate/from-records.js +447 -0
- package/dist/src/populate/from-records.js.map +1 -0
- package/dist/src/snapshot/derived.d.ts +211 -0
- package/dist/src/snapshot/derived.d.ts.map +1 -0
- package/dist/src/snapshot/derived.js +1254 -0
- package/dist/src/snapshot/derived.js.map +1 -0
- package/dist/src/snapshot/graph-meta.d.ts +23 -0
- package/dist/src/snapshot/graph-meta.d.ts.map +1 -0
- package/dist/src/snapshot/graph-meta.js +159 -0
- package/dist/src/snapshot/graph-meta.js.map +1 -0
- package/dist/src/snapshot/graph-snapshot.d.ts +509 -0
- package/dist/src/snapshot/graph-snapshot.d.ts.map +1 -0
- package/dist/src/snapshot/graph-snapshot.js +1247 -0
- package/dist/src/snapshot/graph-snapshot.js.map +1 -0
- package/dist/src/snapshot/hash.d.ts +90 -0
- package/dist/src/snapshot/hash.d.ts.map +1 -0
- package/dist/src/snapshot/hash.js +228 -0
- package/dist/src/snapshot/hash.js.map +1 -0
- package/dist/src/snapshot/queries.d.ts +74 -0
- package/dist/src/snapshot/queries.d.ts.map +1 -0
- package/dist/src/snapshot/queries.js +131 -0
- package/dist/src/snapshot/queries.js.map +1 -0
- package/dist/src/snapshot/validate.d.ts +192 -0
- package/dist/src/snapshot/validate.d.ts.map +1 -0
- package/dist/src/snapshot/validate.js +990 -0
- package/dist/src/snapshot/validate.js.map +1 -0
- package/dist/src/snapshot/views.d.ts +274 -0
- package/dist/src/snapshot/views.d.ts.map +1 -0
- package/dist/src/snapshot/views.js +856 -0
- package/dist/src/snapshot/views.js.map +1 -0
- package/dist/src/types/builder.d.ts +456 -0
- package/dist/src/types/builder.d.ts.map +1 -0
- package/dist/src/types/builder.js +11 -0
- package/dist/src/types/builder.js.map +1 -0
- package/dist/src/types/columns.d.ts +615 -0
- package/dist/src/types/columns.d.ts.map +1 -0
- package/dist/src/types/columns.js +14 -0
- package/dist/src/types/columns.js.map +1 -0
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +11 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/internal.d.ts +172 -0
- package/dist/src/types/internal.d.ts.map +1 -0
- package/dist/src/types/internal.js +13 -0
- package/dist/src/types/internal.js.map +1 -0
- package/dist/src/types/snapshot.d.ts +801 -0
- package/dist/src/types/snapshot.d.ts.map +1 -0
- package/dist/src/types/snapshot.js +14 -0
- package/dist/src/types/snapshot.js.map +1 -0
- package/dist/src/types/wire.d.ts +196 -0
- package/dist/src/types/wire.d.ts.map +1 -0
- package/dist/src/types/wire.js +8 -0
- package/dist/src/types/wire.js.map +1 -0
- package/dist/src/util/mask.d.ts +55 -0
- package/dist/src/util/mask.d.ts.map +1 -0
- package/dist/src/util/mask.js +71 -0
- package/dist/src/util/mask.js.map +1 -0
- package/dist/src/util/options.d.ts +22 -0
- package/dist/src/util/options.d.ts.map +1 -0
- package/dist/src/util/options.js +49 -0
- package/dist/src/util/options.js.map +1 -0
- package/dist/src/util/shared-buffers.d.ts +42 -0
- package/dist/src/util/shared-buffers.d.ts.map +1 -0
- package/dist/src/util/shared-buffers.js +52 -0
- package/dist/src/util/shared-buffers.js.map +1 -0
- package/dist/src/util/typed-array.d.ts +205 -0
- package/dist/src/util/typed-array.d.ts.map +1 -0
- package/dist/src/util/typed-array.js +289 -0
- package/dist/src/util/typed-array.js.map +1 -0
- package/dist/src/wire/bytes.d.ts +69 -0
- package/dist/src/wire/bytes.d.ts.map +1 -0
- package/dist/src/wire/bytes.js +361 -0
- package/dist/src/wire/bytes.js.map +1 -0
- package/dist/src/wire/carried-views.d.ts +111 -0
- package/dist/src/wire/carried-views.d.ts.map +1 -0
- package/dist/src/wire/carried-views.js +286 -0
- package/dist/src/wire/carried-views.js.map +1 -0
- package/dist/src/wire/from-wire.d.ts +144 -0
- package/dist/src/wire/from-wire.d.ts.map +1 -0
- package/dist/src/wire/from-wire.js +1425 -0
- package/dist/src/wire/from-wire.js.map +1 -0
- package/dist/src/wire/to-wire.d.ts +171 -0
- package/dist/src/wire/to-wire.d.ts.map +1 -0
- package/dist/src/wire/to-wire.js +652 -0
- package/dist/src/wire/to-wire.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +72 -7
- package/src/builder/arena.ts +192 -0
- package/src/builder/compact.ts +1811 -0
- package/src/builder/counting-sort.ts +506 -0
- package/src/builder/freeze.ts +689 -0
- package/src/builder/graph-builder.ts +2264 -0
- package/src/builder/options.ts +29 -0
- package/src/columns/bitmap.ts +196 -0
- package/src/columns/column.ts +2574 -0
- package/src/columns/dictionary.ts +114 -0
- package/src/columns/growable.ts +350 -0
- package/src/columns/infer.ts +285 -0
- package/src/columns/remap.ts +663 -0
- package/src/columns/table.ts +568 -0
- package/src/constants.ts +89 -0
- package/src/errors.ts +115 -0
- package/src/ids/edge-id-index.ts +179 -0
- package/src/ids/node-id-map.ts +1340 -0
- package/src/ids/string-store.ts +589 -0
- package/src/index.ts +139 -0
- package/src/lib-resizable-array-buffer.d.ts +34 -0
- package/src/populate/from-csr.ts +802 -0
- package/src/populate/from-edge-arrays.ts +257 -0
- package/src/populate/from-records.ts +536 -0
- package/src/snapshot/derived.ts +1486 -0
- package/src/snapshot/graph-meta.ts +167 -0
- package/src/snapshot/graph-snapshot.ts +1503 -0
- package/src/snapshot/hash.ts +241 -0
- package/src/snapshot/queries.ts +136 -0
- package/src/snapshot/validate.ts +1108 -0
- package/src/snapshot/views.ts +943 -0
- package/src/types/builder.ts +480 -0
- package/src/types/columns.ts +727 -0
- package/src/types/index.ts +14 -0
- package/src/types/internal.ts +195 -0
- package/src/types/snapshot.ts +886 -0
- package/src/types/wire.ts +207 -0
- package/src/util/mask.ts +89 -0
- package/src/util/options.ts +57 -0
- package/src/util/shared-buffers.ts +56 -0
- package/src/util/typed-array.ts +371 -0
- package/src/wire/bytes.ts +440 -0
- package/src/wire/carried-views.ts +327 -0
- package/src/wire/from-wire.ts +1690 -0
- 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
|
+
{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