Skip to content

@graphty/graphty-element / index / LoadFromSourceOptions

Interface: LoadFromSourceOptions ​

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

The options of loadFromSource() and the other source functions. Experimental.

Extends ​

Properties ​

addMissingNodes? ​

optional addMissingNodes?: boolean

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

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

Inherited from ​

CommonImportOptions.addMissingNodes


allowInsecure? ​

readonly optional allowInsecure?: boolean

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

Send a credential without TLS to a host that is not loopback.

Default Value ​

ts
false

builder? ​

readonly optional builder?: BuilderSeed

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

Settings for the builder (loadFromSource and expandFromSource).


credential? ​

readonly optional credential?: Credential

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

The credential, sent only to the endpoint's origin or the credential's own origins.


cursor? ​

readonly optional cursor?: Readonly<Record<string, string | number | boolean | null>> | null

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

Where to resume a capped load: the earlier report.source.next.


defaultDirected? ​

optional defaultDirected?: boolean

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

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

Inherited from ​

CommonImportOptions.defaultDirected


duplicateEdges? ​

optional duplicateEdges?: DuplicatePolicy

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

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"

Inherited from ​

CommonImportOptions.duplicateEdges


encoding? ​

optional encoding?: string

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

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).

Inherited from ​

CommonImportOptions.encoding


endpoint? ​

readonly optional endpoint?: string | URL

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

The service's address; required unless the source has a default.


errorLimit? ​

optional errorLimit?: number

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

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

Inherited from ​

CommonImportOptions.errorLimit


fetch? ​

readonly optional fetch?: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

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

The fetch to use instead of the global one (tests, recorded responses, Node agents).

Call Signature ​

(input, init?): Promise<Response>

MDN Reference

Parameters ​
input ​

URL | RequestInfo

init? ​

RequestInit

Returns ​

Promise<Response>

Call Signature ​

(input, init?): Promise<Response>

MDN Reference

Parameters ​
input ​

string | URL | Request

init? ​

RequestInit

Returns ​

Promise<Response>


freeze? ​

readonly optional freeze?: FreezeOptions

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

Settings for the freeze (loadFromSource and expandFromSource).


hyperedges? ​

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

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

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"

Inherited from ​

CommonImportOptions.hyperedges


idPrefix? ​

readonly optional idPrefix?: string

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

Prepended to every node id, to keep two loads' ids apart.


ids? ​

optional ids?: IdCoercion

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

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

Inherited from ​

CommonImportOptions.ids


limits? ​

readonly optional limits?: SourceLimitOptions

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

The caps.


long? ​

optional long?: "string" | "f64"

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

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"

Inherited from ​

CommonImportOptions.long


nodeIdFrom? ​

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

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

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"

Inherited from ​

CommonImportOptions.nodeIdFrom


onMixedDirection? ​

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

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

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"

Inherited from ​

CommonImportOptions.onMixedDirection


onProgress? ​

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

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

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. A load from a network source passes a third argument, "bytes" or "items", saying what is counted.

Parameters ​

bytesDone ​

number

bytesTotal? ​

number

unit? ​

"items" | "bytes"

Returns ​

void

Inherited from ​

CommonImportOptions.onProgress


restoreMangledIds? ​

optional restoreMangledIds?: boolean

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

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

Inherited from ​

CommonImportOptions.restoreMangledIds


retry? ​

readonly optional retry?: false | RetryOptions

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

How to retry, or false never to.


selfLoops? ​

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

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

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"

Inherited from ​

CommonImportOptions.selfLoops


signal? ​

optional signal?: AbortSignal

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

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

Inherited from ​

CommonImportOptions.signal


userAgent? ​

readonly optional userAgent?: string

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

Sent as User-Agent in Node. No default string.


weightDtype? ​

optional weightDtype?: "f32" | "f64"

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

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"

Inherited from ​

CommonImportOptions.weightDtype


weightFrom? ​

optional weightFrom?: string | null

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

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

Inherited from ​

CommonImportOptions.weightFrom