graphology-gexf
Advanced tools
Comparing version 0.12.1 to 0.13.0
@@ -250,2 +250,3 @@ /* eslint no-self-compare: 0 */ | ||
var allowUndeclaredAttributes = options.allowUndeclaredAttributes === true; | ||
var respectInputGraphType = options.respectInputGraphType === true; | ||
var mergeResult; | ||
@@ -311,6 +312,6 @@ | ||
// Instantiating our graph | ||
var graph = new Graph({ | ||
type: graphType | ||
}); | ||
var graphOptions = respectInputGraphType ? {} : {type: graphType}; | ||
var graph = new Graph(graphOptions); | ||
// Collecting meta | ||
@@ -358,2 +359,9 @@ var meta = collectMeta(META_ELEMENTS); | ||
if (type !== graph.type && graph.type !== 'mixed') { | ||
if (respectInputGraphType) | ||
throw new Error( | ||
"graphology-gexf/parser: one of the file's edges does not respect the input graph type: " + | ||
graph.type + | ||
'.' | ||
); | ||
graph = graph.copy({type: 'mixed'}); | ||
@@ -368,2 +376,7 @@ } | ||
) { | ||
if (respectInputGraphType) | ||
throw new Error( | ||
'graphology-gexf/parser: the file contains parallel edges that the input graph type does not allow.' | ||
); | ||
graph = graph.copy({multi: true}); | ||
@@ -370,0 +383,0 @@ } |
@@ -6,2 +6,3 @@ import {Attributes} from 'graphology-types'; | ||
allowUndeclaredAttributes?: boolean; | ||
respectInputGraphType?: boolean; | ||
}; | ||
@@ -8,0 +9,0 @@ |
{ | ||
"name": "graphology-gexf", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "GEXF parser & writer for graphology.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,2 +50,3 @@ [![Build Status](https://github.com/graphology/graphology-gexf/workflows/Tests/badge.svg)](https://github.com/graphology/graphology-gexf/actions) | ||
- **allowUndeclaredAttributes** _?boolean_ [`false`]: whether to allow undeclared attributes for both nodes & edges, which will be considered as strings. | ||
- **respectInputGraphType** _?boolean_ [`false`]: whether to make sure the output graph type is the same as the passed constructor. By default the parser will try to optimize the graph representation to avoid wasting time and memory. But if `respectInputGraphType` is `true` the output graph is guaranteed to be an instance of the typed constructor you gave as first argument. This also means the parser will throw when reading a graph that cannot be represented with the given typed constructor. | ||
@@ -52,0 +53,0 @@ ### Writer |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40678
1128
116