@graphty/graph-io / positions / extractPositions
Function: extractPositions() ​
extractPositions(
importer,snapshot,report,options?):FilePositions|null
Defined in: positions/extract.ts:74
A file's stored node coordinates in the neutral convention: each node's center, y up, in the file's own unit. Call it with the importer that read the snapshot and the report it returned.
Parameters ​
importer ​
the importer that read the snapshot (its positions() hook, when it has one, says how the coordinates are spelled)
snapshot ​
GraphSnapshot
the imported graph
report ​
the import's report
options? ​
signal to abort
Returns ​
FilePositions | null
the positions, or null when the file stores none and has no position-like columns
Example ​
ts
const { snapshot, report } = await importGraph(text, { format: "gml" });
const positions = extractPositions(gmlImporter, snapshot, report);
if (positions?.usable) console.log(positions.coords.subarray(0, 3)); // node 0's x, y, z