Skip to content

@graphty/graphty-element / extend / CommonImportOptions

Interface: CommonImportOptions ​

Defined in: graph-io/dist/src/types.d.ts:27

The options every importer accepts next to its format-specific ones. The builder-policy fields (addMissingNodes, duplicateEdges, selfLoops, weightDtype) seed the registry's builder; on a caller's sink they are read back from sink.options and every option the sink cannot honor is reported.

Properties ​

addMissingNodes? ​

optional addMissingNodes?: boolean

Defined in: graph-io/dist/src/types.d.ts:56

Whether an edge may name a node the file never declares; that node is then created. When false, such an edge is skipped as an error. The default is false for GEXF, XGMML, CX, CX2 and Cytoscape sessions, whose files must declare every node, and true for the other formats.

Default Value ​

ts
per format

defaultDirected? ​

optional defaultDirected?: boolean

Defined in: graph-io/dist/src/types.d.ts:88

Whether the graph is directed when the file does not say. The default is undirected for GraphML, GEXF, GML, JSON and XGMML, and directed for CSV, Pajek and Cytoscape sessions. DOT, Neo4j, CX, CX2 and OBO files always settle the direction themselves (DOT by graph or digraph; the others are always directed), so those formats do not read this option and report it as W_OPTION_IGNORED.

Default Value ​

ts
per format

duplicateEdges? ​

optional duplicateEdges?: DuplicatePolicy

Defined in: graph-io/dist/src/types.d.ts:63

What to do with a second edge between the same two nodes: "keep" keeps both, "first" / "last" keep one, "sum" / "min" / "max" keep one with the weights combined, and "error" stops the import. Merged edges are reported once as W_EDGES_MERGED.

Default Value ​

ts
"keep"

encoding? ​

optional encoding?: string

Defined in: graph-io/dist/src/types.d.ts:164

The character encoding of byte input, as a label such as "utf-8", "windows-1252" or "utf-16le". Without it graph-io uses a byte order mark, then the encoding the file declares (an XML declaration, DOT's charset), then UTF-8, and reads bytes that are not UTF-8 as windows-1252 with a warning. A byte order mark wins over this option. A string input is already text: setting this option for one adds a W_OPTION_IGNORED warning, once per input (a CSV import with a nodes table has two inputs).


errorLimit? ​

optional errorLimit?: number

Defined in: graph-io/dist/src/types.d.ts:143

How many errors an import tolerates. Each error skips one node, edge or value and is listed in the report; one error more than this stops the import with an ImportError. Pass 0 to stop at the first error.

Default Value ​

ts
100

hyperedges? ​

optional hyperedges?: "error" | "star" | "skip" | "clique"

Defined in: graph-io/dist/src/types.d.ts:136

What to do with a GraphML or JGF hyperedge (an edge with more than two ends): "skip" leaves it out with a warning, "error" stops the import, and "star" and "clique" turn it into ordinary edges. "clique" joins every pair of ends. "star" works differently per format: GraphML adds a new hub node joined to every end, while JGF makes the hyperedge's first node the hub, so no node is added. A directed JGF hyperedge (source and target arrays) becomes one edge from every source to every target under both. In JGF every edge made from a hyperedge carries the hyperedge's id, label, relation and metadata; GraphML drops a hyperedge's <data> and its <desc>, with a warning.

Default Value ​

ts
"skip"

ids? ​

optional ids?: IdCoercion

Defined in: graph-io/dist/src/types.d.ts:37

How id text becomes a node id. "canonical": integer text such as "42" becomes the number 42 and everything else ("042", "4.2", "a") stays text. "string": every id stays text. "number": every id is read as a number, so "042" and "42" become one node (with a warning) and text that is not a number is an error. "keep": ids keep the type the file gives them. The default is "keep" for JSON, OBO, XGMML, CX, CX2 and Cytoscape sessions, and "canonical" for the other formats.

Default Value ​

ts
per format

long? ​

optional long?: "string" | "f64"

Defined in: graph-io/dist/src/types.d.ts:114

How a column the file declares as a 64-bit integer is stored: "f64" (a number, exact up to 2^53) or "string" (every digit kept, as text). GML declares no types, so there it applies to a key whose integer values go beyond 2^53.

Default Value ​

ts
"f64"

nodeIdFrom? ​

optional nodeIdFrom?: "id" | "label" | "index"

Defined in: graph-io/dist/src/types.d.ts:49

Which value becomes the node id: the file's own id ("id"), the node's label ("label"), or its position among the nodes, counting from 0 ("index"). Use it when a file's ids are meaningless numbers and the labels are the real names. In d3 JSON, "index" also reads edges whose ends are node positions. In GML and Pajek it only renames: every node still needs its id key or vertex number, because edges refer to nodes by it, and a GML node without an id key is skipped with E_MISSING_ID. CSV reads this option only when there is a node table, and it does not just rename: with "label" the node table's label column (label, or the labelColumn option) gives the ids, so the edge table must name its nodes by those labels.

Default Value ​

ts
"id"

onMixedDirection? ​

optional onMixedDirection?: "error" | "directed" | "undirected" | "expand"

Defined in: graph-io/dist/src/types.d.ts:79

How edge direction is read. "expand" (the default) keeps the file's direction, and for a file that has both directed and undirected edges makes a directed graph in which each undirected edge is two edges, marked so an export can write them back as one. "directed" / "undirected" read every edge of any file that way, including a file whose edges all have the other direction, with a W_DIRECTION_FORCED warning. "error" stops the import at the first edge whose direction differs from the file's.

Default Value ​

ts
"expand"

onProgress? ​

optional onProgress?: (bytesDone, bytesTotal?) => void

Defined in: graph-io/dist/src/types.d.ts:155

Called as the input is read, with the bytes read so far and the total. For a string or a Uint8Array the total is known from the first call. For a stream (which includes loadFromUrl() and loadFromFile()) it is undefined until the last call, which always has bytesDone === bytesTotal. Text counts its UTF-8 length.

Parameters ​

bytesDone ​

number

bytesTotal? ​

number

Returns ​

void


restoreMangledIds? ​

optional restoreMangledIds?: boolean

Defined in: graph-io/dist/src/types.d.ts:124

Whether to give back the original ids that an export with sanitizeIds: "mangle" had to rewrite. The export writes them to the file in an attribute whose name each format page gives. When false, the rewritten ids stay the ids and the originals are an ordinary node attribute, named after the format's spelling: graphty.originalId in GraphML, graphty_originalId in GML and Pajek, graphty:originalId in CX, CX2 and Cytoscape sessions, and a graphty:originalId entry of the property_value attribute in OBO.

Default Value ​

ts
true

selfLoops? ​

optional selfLoops?: "error" | "keep" | "drop"

Defined in: graph-io/dist/src/types.d.ts:69

What to do with an edge from a node to itself: "keep", "drop" (reported once as W_SELF_LOOPS_DROPPED with the number removed), or "error" to stop the import.

Default Value ​

ts
"keep"

signal? ​

optional signal?: AbortSignal

Defined in: graph-io/dist/src/types.d.ts:148

Cancels the import. When it aborts, the import stops and rejects with the signal's reason (an AbortError, or a TimeoutError from AbortSignal.timeout()).


weightDtype? ​

optional weightDtype?: "f32" | "f64"

Defined in: graph-io/dist/src/types.d.ts:107

Whether weights a 32-bit float cannot hold exactly are also kept exactly. "f64" keeps them in an edge column that snapshot.edges.byRole("weight") finds, so 0.1 and 16777217 stay exact. "f32" keeps no such column and uses less memory: the 32-bit weight arrays snapshot.weights and snapshot.edgeList().weights, which every import fills, are then the only weights.

Default Value ​

ts
"f64"

weightFrom? ​

optional weightFrom?: string | null

Defined in: graph-io/dist/src/types.d.ts:98

The edge attribute read as the edge weight. The default is "weight", except "value" for GML and Pajek and none for OBO. Pass null to read every attribute as a plain attribute and leave the graph unweighted. A name no edge has leaves the graph unweighted, with a W_WEIGHT_NOT_FOUND warning: one options object with weightFrom: "weight" shared across formats reads GML and Pajek files, which keep their weights in value, without weights. An edge whose weight cell is empty or missing gets the default weight 1, and an export writes no weight for it.

Default Value ​

ts
per format