@graphty/graph-io / @graphty/graph-io/gml / GmlImportOptions
Interface: GmlImportOptions ​
Defined in: formats/gml/importer.ts:93
The format-specific options of the GML importer.
Extends ​
Properties ​
addMissingNodes? ​
optionaladdMissingNodes?:boolean
Defined in: types.ts:66
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 ​
per formatInherited from ​
CommonImportOptions.addMissingNodes
defaultDirected? ​
optionaldefaultDirected?:boolean
Defined in: types.ts:98
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 ​
per formatInherited from ​
CommonImportOptions.defaultDirected
dictionaries? ​
optionaldictionaries?:boolean
Defined in: formats/gml/importer.ts:107
Store a text attribute whose values repeat a lot (fewer distinct values than half the rows) as a dictionary column, which uses less memory and reads the same. Such a column reports meta.dtype "dict" instead of "string". A column with a role, such as the label column, always stays "string".
Default Value ​
trueduplicateEdges? ​
optionalduplicateEdges?:DuplicatePolicy
Defined in: types.ts:73
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 ​
"keep"Inherited from ​
CommonImportOptions.duplicateEdges
encoding? ​
optionalencoding?:string
Defined in: types.ts:174
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 ​
errorLimit? ​
optionalerrorLimit?:number
Defined in: types.ts:153
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 ​
100Inherited from ​
CommonImportOptions.errorLimit
graphIndex? ​
optionalgraphIndex?:number
Defined in: types.ts:189
The 0-based position of the graph to read from a file that holds several (listGraphs() gives each graph's index). A position past the last graph stops the import with an ImportError whose issue.code is E_GRAPH_NOT_FOUND; its message lists the file's graphs.
Default Value ​
0Inherited from ​
graphName? ​
optionalgraphName?:string
Defined in: types.ts:196
The name of the graph to read from a file that holds several (listGraphs() gives each graph's name). A name no graph has stops the import with an ImportError whose issue.code is E_GRAPH_NOT_FOUND, and a name two graphs share with one whose issue.code is E_AMBIGUOUS_GRAPH_NAME.
Inherited from ​
hyperedges? ​
optionalhyperedges?:"error"|"skip"|"star"|"clique"
Defined in: types.ts:146
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 ​
"skip"Inherited from ​
CommonImportOptions.hyperedges
ids? ​
optionalids?:IdCoercion
Defined in: types.ts:47
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 ​
per formatInherited from ​
long? ​
optionallong?:"string"|"f64"
Defined in: types.ts:124
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 ​
"f64"Inherited from ​
nodeIdFrom? ​
optionalnodeIdFrom?:"id"|"label"|"index"
Defined in: types.ts:59
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 ​
"id"Inherited from ​
CommonImportOptions.nodeIdFrom
onMixedDirection? ​
optionalonMixedDirection?:"directed"|"error"|"expand"|"undirected"
Defined in: types.ts:89
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 ​
"expand"Inherited from ​
CommonImportOptions.onMixedDirection
onProgress? ​
optionalonProgress?: (bytesDone,bytesTotal?) =>void
Defined in: types.ts:165
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
Inherited from ​
CommonImportOptions.onProgress
positions? ​
optionalpositions?:boolean
Defined in: formats/gml/importer.ts:99
Read a node's graphics [ x y z ] record as its position; false keeps the whole record as a JSON attribute named graphics.
Default Value ​
truerestoreMangledIds? ​
optionalrestoreMangledIds?:boolean
Defined in: types.ts:134
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 ​
trueInherited from ​
CommonImportOptions.restoreMangledIds
selfLoops? ​
optionalselfLoops?:"keep"|"error"|"drop"
Defined in: types.ts:79
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 ​
"keep"Inherited from ​
signal? ​
optionalsignal?:AbortSignal
Defined in: types.ts:158
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 ​
weightDtype? ​
optionalweightDtype?:"f32"|"f64"
Defined in: types.ts:117
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 ​
"f64"Inherited from ​
CommonImportOptions.weightDtype
weightFrom? ​
optionalweightFrom?:string|null
Defined in: types.ts:108
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 ​
per format