Comparing version 1.6.1-alpha to 1.7.0-alpha
'use strict'; | ||
// //////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // Utility ///////////////////////////////////////////////////////////////////////////////////// | ||
// //////////////////////////////////////////////////////////////////////////////////////////////// | ||
class Callbacks { | ||
constructor() { | ||
this._callbacks = new Set(); | ||
} | ||
add(fn) { | ||
if (!this._callbacks.has(fn)) { | ||
this._callbacks.add(fn); | ||
} | ||
return () => { | ||
this._callbacks.delete(fn); | ||
}; | ||
} | ||
fire(...args) { | ||
for (let fn of this._callbacks) { | ||
fn(...args); | ||
} | ||
} | ||
} | ||
// //////////////////////////////////////////////////////////////////////////////////////////////// | ||
// // JsGraph class /////////////////////////////////////////////////////////////////////////////// | ||
// //////////////////////////////////////////////////////////////////////////////////////////////// | ||
/** | ||
* @public | ||
* @class JsGraph | ||
* @classdesc The main class of this library, to be used for representing a mathematical (di)graph. | ||
*/ | ||
export default class JsGraph { | ||
constructor() { | ||
this._vertices = new Map(); // key -> value | ||
this._edges = new Map(); // from -> to -> value | ||
this._reverseEdges = new Map(); // to -> Set<from> (_edges contains the values) | ||
this._vertices = new Map(); // Map.< string, * > | ||
this._edges = new Map(); // Map.< string, Map.<string, *> > | ||
this._reverseEdges = new Map(); // Map.< string, Set.<*> > | ||
this._vertexCount = 0; | ||
this._edgeCount = 0; | ||
this._addVertexCallbacks = new Callbacks(); | ||
this._removeVertexCallbacks = new Callbacks(); | ||
this._addEdgeCallbacks = new Callbacks(); | ||
this._removeEdgeCallbacks = new Callbacks(); | ||
} | ||
@@ -54,7 +27,10 @@ | ||
onAddVertex (fn) { return this._addVertexCallbacks .add(fn) } | ||
onRemoveVertex(fn) { return this._removeVertexCallbacks.add(fn) } | ||
////////// creating them ////////// | ||
//// creating them //// | ||
/** | ||
* Add a new vertex to this graph. | ||
* @throws {JsGraph.VertexExistsError} if a vertex with this key already exists | ||
* @param key {string} the key with which to refer to this new vertex | ||
* @param value {*} the value to store in this new vertex | ||
*/ | ||
addNewVertex(key, value) { | ||
@@ -68,5 +44,10 @@ if (this.hasVertex(key)) { | ||
this._vertexCount += 1; | ||
this._addVertexCallbacks.fire(key, value); | ||
} | ||
/** | ||
* Set the value of an existing vertex in this graph. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with this key does not exist | ||
* @param key {string} the key belonging to the vertex | ||
* @param value {*} the value to store in this vertex | ||
*/ | ||
setVertex(key, value) { | ||
@@ -79,2 +60,8 @@ if (!this.hasVertex(key)) { | ||
/** | ||
* Make sure a vertex with a specific key exists in this graph. If it already exists, nothing is done. | ||
* If it does not yet exist, a new vertex is added with the given value. | ||
* @param key {string} the key for the vertex | ||
* @param value {*} the value to store if a new vertex is added | ||
*/ | ||
ensureVertex(key, value) { | ||
@@ -86,2 +73,8 @@ if (!this.hasVertex(key)) { | ||
/** | ||
* Add a new vertex to this graph. If a vertex with this key already exists, | ||
* the value of that vertex is overwritten. | ||
* @param key {string} the key with which to refer to this new vertex | ||
* @param value {*} the value to store in this new vertex | ||
*/ | ||
addVertex(key, value) { | ||
@@ -95,4 +88,11 @@ if (this.hasVertex(key)) { | ||
//// removing them //// | ||
////////// removing them ////////// | ||
/** | ||
* Remove an existing vertex from this graph. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with this key does not exist | ||
* @throws {JsGraph.HasConnectedEdgesError} if there are still edges connected to this vertex | ||
* @param key {string} the key of the vertex to remove | ||
*/ | ||
removeExistingVertex(key) { | ||
@@ -102,14 +102,14 @@ if (!this.hasVertex(key)) { | ||
} | ||
if (this._edges.get(key).size > 0) { | ||
if (this._edges.get(key).size > 0 || this._reverseEdges.get(key).size > 0) { | ||
throw new JsGraph.HasConnectedEdgesError(key); | ||
} | ||
if (this._reverseEdges.get(key).size > 0) { | ||
throw new JsGraph.HasConnectedEdgesError(key); | ||
} | ||
var valueOfRemovedVertex = this._vertices.get(key); | ||
this._vertices.delete(key); | ||
this._vertexCount -= 1; | ||
this._removeVertexCallbacks.fire(key, valueOfRemovedVertex); | ||
} | ||
/** | ||
* Remove an existing vertex from this graph, as well as all edges connected to it. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with this key does not exist | ||
* @param key {string} the key of the vertex to remove | ||
*/ | ||
destroyExistingVertex(key) { | ||
@@ -119,11 +119,17 @@ if (!this.hasVertex(key)) { | ||
} | ||
this.eachVertexFrom(key, (to) => { | ||
for (let [to] of this.verticesFrom(key)) { | ||
this.removeEdge(key, to); | ||
}); | ||
this.eachVertexTo(key, (from) => { | ||
} | ||
for (let [from] of this.verticesTo(key)) { | ||
this.removeEdge(from, key); | ||
}); | ||
} | ||
this.removeExistingVertex(key); | ||
} | ||
/** | ||
* Remove an existing vertex from this graph. | ||
* If a vertex with this key does not exist, nothing happens. | ||
* @throws {JsGraph.HasConnectedEdgesError} if there are still edges connected to this vertex | ||
* @param key {string} the key of the vertex to remove | ||
*/ | ||
removeVertex(key) { | ||
@@ -135,2 +141,7 @@ if (this.hasVertex(key)) { | ||
/** | ||
* Remove a vertex from this graph, as well as all edges connected to it. | ||
* If a vertex with this key does not exist, nothing happens. | ||
* @param key {string} the key of the vertex to remove | ||
*/ | ||
destroyVertex(key) { | ||
@@ -142,6 +153,28 @@ if (this.hasVertex(key)) { | ||
//// querying them //// | ||
vertexCount() { return this._vertexCount } | ||
hasVertex(key) { return this._vertices.has(key) } | ||
////////// querying them ////////// | ||
/** | ||
* @returns {number} the number of vertices in the whole graph | ||
*/ | ||
vertexCount() { return this._vertexCount } | ||
/** | ||
* Ask whether a vertex with a given key exists. | ||
* @param key {string} the key to query | ||
* @returns {boolean} whether there is a vertex with the given key | ||
*/ | ||
hasVertex(key) { return this._vertices.has(key) } | ||
/** | ||
* Get the value associated with the vertex of a given key. | ||
* @param key {string} the key to query | ||
* @returns {*} the value associated with the vertex of the given key. | ||
* Note that a return value of `undefined` can mean | ||
* | ||
* 1. that there is no such vertex, or | ||
* 2. that the stored value is actually `undefined`. | ||
* | ||
* Use {@link JsGraph#hasVertex} to distinguish these cases. | ||
*/ | ||
vertexValue(key) { return this._vertices.get(key) } | ||
@@ -154,5 +187,12 @@ | ||
onAddEdge (fn) { return this._addEdgeCallbacks .add(fn) } | ||
onRemoveEdge(fn) { return this._removeEdgeCallbacks.add(fn) } | ||
////////// adding them ////////// | ||
/** | ||
* Add a new edge to this graph. | ||
* @throws {JsGraph.EdgeExistsError} if an edge between `from` and `to` already exists | ||
* @throws {JsGraph.VertexNotExistsError} if the `from` and/or `to` vertices do not yet exist in the graph | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store in this new edge | ||
*/ | ||
addNewEdge(from, to, value) { | ||
@@ -174,5 +214,12 @@ if (this.hasEdge(from, to)) { | ||
this._edgeCount += 1; | ||
this._addEdgeCallbacks.fire(from, to, value); | ||
} | ||
/** | ||
* Add a new edge to this graph. If the `from` and/or `to` vertices do not yet exist | ||
* in the graph, they are implicitly added with an `undefined` value. | ||
* @throws {JsGraph.EdgeExistsError} if an edge between `from` and `to` already exists | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store in this new edge | ||
*/ | ||
createNewEdge(from, to, value) { | ||
@@ -187,2 +234,9 @@ if (this.hasEdge(from, to)) { | ||
/** | ||
* Set the value of an existing edge in this graph. | ||
* @throws {JsGraph.EdgeNotExistsError} if an edge between `from` and `to` does not yet exist | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store in this edge | ||
*/ | ||
setEdge(from, to, value) { | ||
@@ -195,2 +249,11 @@ if (!this.hasEdge(from, to)) { | ||
/** | ||
* Make sure an edge between the `from` and `to` vertices in this graph. | ||
* If one already exists, nothing is done. | ||
* If one does not yet exist, a new edge is added with the given value. | ||
* @throws {JsGraph.VertexNotExistsError} if the `from` and/or `to` vertices do not yet exist in the graph | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store if a new edge is added | ||
*/ | ||
spanEdge(from, to, value) { | ||
@@ -211,2 +274,10 @@ if (!this.hasVertex(from)) { | ||
/** | ||
* Add a new edge to this graph. If an edge between `from` and `to` already exists, | ||
* the value of that edge is overwritten. | ||
* @throws {JsGraph.VertexNotExistsError} if the `from` and/or `to` vertices do not yet exist in the graph | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store in this new edge | ||
*/ | ||
addEdge(from, to, value) { | ||
@@ -220,2 +291,12 @@ if (this.hasEdge(from, to)) { | ||
/** | ||
* Make sure an edge between the `from` and `to` vertices exists in this graph. | ||
* If it already exists, nothing is done. | ||
* If it does not yet exist, a new edge is added with the given value. | ||
* If the `from` and/or `to` vertices do not yet exist | ||
* in the graph, they are implicitly added with an `undefined` value. | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store if a new edge is added | ||
*/ | ||
ensureEdge(from, to, value) { | ||
@@ -227,2 +308,11 @@ if (!this.hasEdge(from, to)) { | ||
/** | ||
* Add a new edge to this graph. If an edge between the `from` and `to` | ||
* vertices already exists, the value of that edge is overwritten. | ||
* If the `from` and/or `to` vertices do not yet exist | ||
* in the graph, they are implicitly added with an `undefined` value. | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @param value {*} the value to store if a new edge is added | ||
*/ | ||
createEdge(from, to, value) { | ||
@@ -236,4 +326,11 @@ if (this.hasEdge(from, to)) { | ||
//// removing them //// | ||
////////// removing them ////////// | ||
/** | ||
* Remove an existing edge from this graph. | ||
* @throws {JsGraph.EdgeNotExistsError} if an edge between the `from` and `to` vertices doesn't exist | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
*/ | ||
removeExistingEdge(from, to) { | ||
@@ -243,9 +340,13 @@ if (!this.hasEdge(from, to)) { | ||
} | ||
var valueOfRemovedEdge = this._edges.get(from).get(to); | ||
this._edges.get(from).delete(to); | ||
this._reverseEdges.get(to).delete(from); | ||
this._edgeCount -= 1; | ||
this._removeEdgeCallbacks.fire(from, to, valueOfRemovedEdge); | ||
} | ||
/** | ||
* Remove an edge from this graph. | ||
* If an edge between the `from` and `to` vertices doesn't exist, nothing happens. | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
*/ | ||
removeEdge(from, to) { | ||
@@ -257,6 +358,16 @@ if (this.hasEdge(from, to)) { | ||
//// querying them //// | ||
////////// querying them ////////// | ||
/** | ||
* @returns {number} the number of edges in the whole graph | ||
*/ | ||
edgeCount() { return this._edgeCount } | ||
/** | ||
* Ask whether an edge between given `from` and `to` vertices exist. | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @returns {boolean} whether there is an edge between the given `from` and `to` vertices | ||
*/ | ||
hasEdge(from, to) { | ||
@@ -269,2 +380,14 @@ return this.hasVertex(from) && | ||
/** | ||
* Get the value associated with the edge between given `from` and `to` vertices. | ||
* @param from {string} the key for the originating vertex | ||
* @param to {string} the key for the terminating vertex | ||
* @returns {*} the value associated with the edge between the given `from` and `to` vertices | ||
* Note that a return value of `undefined` can mean | ||
* | ||
* 1. that there is no such edge, or | ||
* 2. that the stored value is actually `undefined`. | ||
* | ||
* Use {@link JsGraph#hasEdge} to distinguish these cases. | ||
*/ | ||
edgeValue(from, to) { | ||
@@ -279,4 +402,18 @@ return this.hasEdge(from, to) ? this._edges.get(from).get(to) : undefined; | ||
[Symbol.iterator]() { return this.vertices() } | ||
/** | ||
* Iterate over all vertices of the graph, in no particular order. | ||
* @returns { Iterator.<string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.vertices(), keyVal = it.next(); !it.done;) { | ||
* var key = keyVal[0], | ||
* value = keyVal[1]; | ||
* // iterates over all vertices of the graph | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [key, value] of jsGraph.vertices()) { | ||
* // iterates over all vertices of the graph | ||
* } | ||
* @see {@link JsGraph#@@iterator} | ||
*/ | ||
*vertices() { | ||
@@ -292,2 +429,31 @@ var done = new Set(); | ||
/** | ||
* A {@link JsGraph} object is itself {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol|iterable}, | ||
* and serves as a short notation in ECMAScript 6 to iterate over all vertices in the graph, in no particular order. | ||
* @method JsGraph#@@iterator | ||
* @returns { Iterator.<string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (let [key, value] of jsGraph) { | ||
* // iterates over all vertices of the graph | ||
* } | ||
* @see {@link JsGraph#vertices} | ||
*/ | ||
[Symbol.iterator]() { return this.vertices() } | ||
/** | ||
* Iterate over all edges of the graph, in no particular order. | ||
* @returns { Iterator.<string, string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.edges(), fromToVal = it.next(); !it.done;) { | ||
* var from = fromToVal[0], | ||
* to = fromToVal[1], | ||
* value = fromToVal[2]; | ||
* // iterates over all edges of the graph | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [from, to, value] of jsGraph.edges()) { | ||
* // iterates over all vertices of the graph | ||
* } | ||
*/ | ||
*edges() { | ||
@@ -306,2 +472,20 @@ var done = new Map(); | ||
/** | ||
* Iterate over the outgoing edges of a given vertex in the graph, in no particular order. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with the given `from` key does not exist | ||
* @param from {string} the key of the vertex to take the outgoing edges from | ||
* @returns { Iterator.<string, *, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.verticesFrom(from), toVertexEdge = it.next(); !it.done;) { | ||
* var to = toVertexEdge[0], | ||
* vertexValue = toVertexEdge[1], | ||
* edgeValue = toVertexEdge[2]; | ||
* // iterates over all outgoing vertices of the `from` vertex | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [to, vertexValue, edgeValue] of jsGraph.verticesFrom(from)) { | ||
* // iterates over all outgoing edges of the `from` vertex | ||
* } | ||
*/ | ||
verticesFrom(from) { | ||
@@ -321,2 +505,21 @@ if (!this.hasVertex(from)) { throw new JsGraph.VertexNotExistsError(from) } | ||
/** | ||
* Iterate over the incoming edges of a given vertex in the graph, in no particular order. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with the given `to` key does not exist | ||
* @param to {string} the key of the vertex to take the incoming edges from | ||
* @returns { Iterator.<string, *, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.verticesTo(to), fromVertexEdge = it.next(); !it.done;) { | ||
* var from = fromVertexEdge[0], | ||
* vertexValue = fromVertexEdge[1], | ||
* edgeValue = fromVertexEdge[2]; | ||
* // iterates over all outgoing vertices of the `from` vertex | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [from, vertexValue, edgeValue] of jsGraph.verticesTo(to)) { | ||
* // iterates over all incoming edges of the `to` vertex | ||
* } | ||
*/ | ||
verticesTo(to) { | ||
@@ -336,2 +539,19 @@ if (!this.hasVertex(to)) { throw new JsGraph.VertexNotExistsError(to) } | ||
/** | ||
* Iterate over all vertices reachable from a given vertex in the graph, in no particular order. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with the given `from` key does not exist | ||
* @param from {string} the key of the vertex to take the reachable vertices from | ||
* @returns { Iterator.<string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.verticesWithPathFrom(from), keyValue = it.next(); !it.done;) { | ||
* var key = keyValue[0], | ||
* value = keyValue[1]; | ||
* // iterates over all vertices reachable from `from` | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [key, value] of jsGraph.verticesWithPathFrom(from)) { | ||
* // iterates over all vertices reachable from `from` | ||
* } | ||
*/ | ||
verticesWithPathFrom(from) { | ||
@@ -351,2 +571,19 @@ if (!this.hasVertex(from)) { throw new JsGraph.VertexNotExistsError(from) } | ||
/** | ||
* Iterate over all vertices from which a given vertex in the graph can be reached, in no particular order. | ||
* @throws {JsGraph.VertexNotExistsError} if a vertex with the given `to` key does not exist | ||
* @param to {string} the key of the vertex to take the reachable vertices from | ||
* @returns { Iterator.<string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.verticesWithPathTo(to), keyValue = it.next(); !it.done;) { | ||
* var key = keyValue[0], | ||
* value = keyValue[1]; | ||
* // iterates over all vertices from which `to` can be reached | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [key, value] of jsGraph.verticesWithPathTo(to)) { | ||
* // iterates over all vertices from which `to` can be reached | ||
* } | ||
*/ | ||
verticesWithPathTo(to) { | ||
@@ -366,2 +603,17 @@ if (!this.hasVertex(to)) { throw new JsGraph.VertexNotExistsError(to) } | ||
/** | ||
* Iterate over all vertices of the graph in topological order. | ||
* @returns { Iterator.<string, *> } an object conforming to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol|ES6 iterator protocol} | ||
* @example | ||
* for (var it = jsGraph.vertices_topologically(), keyVal = it.next(); !it.done;) { | ||
* var key = keyVal[0], | ||
* value = keyVal[1]; | ||
* // iterates over all vertices of the graph in topological order | ||
* } | ||
* @example | ||
* // in ECMAScript 6, you can use a for..of loop | ||
* for (let [key, value] of jsGraph.vertices_topologically()) { | ||
* // iterates over all vertices of the graph in topological order | ||
* } | ||
*/ | ||
*vertices_topologically() { | ||
@@ -398,49 +650,2 @@ var visited = []; // stack | ||
///////////////////////////////////////// | ||
////////// Old Style Iteration ////////// | ||
///////////////////////////////////////// | ||
eachVertex(handler) { | ||
for (let args of this.vertices()) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachEdge(handler) { | ||
for (let args of this.edges()) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachVertexFrom(from, handler) { | ||
for (let args of this.verticesFrom(from)) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachVertexTo(to, handler) { | ||
for (let args of this.verticesTo(to)) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachVertexWithPathFrom(from, handler) { | ||
for (let args of this.verticesWithPathFrom(from)) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachVertexWithPathTo(to, handler) { | ||
for (let args of this.verticesWithPathTo(to)) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
eachVertexTopologically(handler) { | ||
for (let args of this.vertices_topologically()) { | ||
if (handler(...args) === false) { break } | ||
} | ||
} | ||
////////////////////////////// | ||
@@ -450,8 +655,14 @@ ////////// Clearing ////////// | ||
/** | ||
* Remove all edges from the graph, but leave the vertices intact. | ||
*/ | ||
clearEdges() { | ||
this.eachEdge((from, to) => { this.removeEdge(from, to) }); | ||
for (let [from, to] of this.edges()) { this.removeEdge(from, to) } | ||
} | ||
/** | ||
* Remove all edges and vertices from the graph, putting it back in its initial state. | ||
*/ | ||
clear() { | ||
this.eachVertex((v) => { this.destroyVertex(v) }); | ||
for (let [v] of this.vertices()) { this.destroyVertex(v) } | ||
} | ||
@@ -464,3 +675,16 @@ | ||
equals(other, eq=(x,y,from,to)=>x===y) { | ||
/** | ||
* Ask whether this graph and another graph are equal. | ||
* Two graphs are equal if they have the same vertices and the same edges. | ||
* @param other {JsGraph} the other graph to compare this one to | ||
* @param [eq] {function(*, *, string, ?string): boolean} | ||
* a custom equality function for stored values; defaults to `===` | ||
* comparison; The first two arguments are the two values to compare. | ||
* If they are vertex values, the third argument is the vertex key. | ||
* If they are edge values, the third and fourth argument are the | ||
* `from` and `to` keys respectively. (So you can test the fourth | ||
* argument to distinguish the two cases.) | ||
* @returns {boolean} `true` if the two graphs are equal; `false` otherwise | ||
*/ | ||
equals(other=undefined, eq=(x,y,from,to)=>x===y) { | ||
if (!(other instanceof JsGraph)) { return false } | ||
@@ -480,36 +704,45 @@ if (this.vertexCount() !== other.vertexCount()) { return false } | ||
/** | ||
* Test whether the graph contains a directed cycle. | ||
* @returns {boolean} `false`, if there is no cycle; a truthy value if there *is* a cycle | ||
* (not necessarily `true`; future versions of the library might return | ||
* a description of the cycle) | ||
*/ | ||
hasCycle() { | ||
var visited = {}; | ||
var handled = {}; | ||
let visited = new Set(); | ||
let handled = new Set(); | ||
var cycleFound = false; | ||
var visit = (a) => { | ||
const visit = (a) => { | ||
/* if a cycle is found, record it and return */ | ||
if (visited[a]) { | ||
cycleFound = true; | ||
return; | ||
if (visited.has(a)) { | ||
return true; | ||
} | ||
/* if this vertex was already handled, no cycle can be found here */ | ||
if (handled[a]) { return } | ||
handled[a] = true; | ||
if (handled.has(a)) { return false } | ||
handled.add(a); | ||
/* recursively visit successors to check for cycles */ | ||
visited[a] = true; | ||
this.eachVertexFrom(a, (b) => { | ||
visit(b); | ||
if (cycleFound) { return false } | ||
}); | ||
visited[a] = false; | ||
visited.add(a); | ||
for (let [b] of this.verticesFrom(a)) { | ||
if (visit(b)) { return true } | ||
} | ||
visited.delete(a); | ||
}; | ||
this.eachVertex((a) => { | ||
visit(a); | ||
if (cycleFound) { return false } | ||
}); | ||
for (let [a] of this.vertices()) { | ||
if (visit(a)) { return true } | ||
} | ||
return cycleFound; | ||
return false; | ||
} | ||
/** | ||
* Test whether there is a directed path between a given pair of keys. | ||
* @param from {string} the originating vertex | ||
* @param to {string} the terminating vertex | ||
* @returns {boolean} `false`, if there is no such path; a truthy value if there *is* such a path | ||
* (not necessarily `true`; future versions of the library might return | ||
* a description of the path) | ||
*/ | ||
hasPath(from, to) { | ||
@@ -520,18 +753,17 @@ if (!this.hasVertex(from) || !this.hasVertex(to)) { | ||
var visited = {}; | ||
var visited = new Set(); | ||
/* Recursive auxiliary function: Is there a path from 'current' to 'to'? */ | ||
var hasPathAux = (current) => { | ||
const hasPathAux = (current) => { | ||
if (this.hasEdge(current, to)) { | ||
return true; | ||
} | ||
visited[current] = true; | ||
var found = false; | ||
this.eachVertexFrom(current, (next) => { | ||
if (!found && !visited[next] && hasPathAux(next)) { | ||
found = true; | ||
visited.add(current); | ||
for (let [next] of this.verticesFrom(current)) { | ||
if (!visited.has(next) && hasPathAux(next)) { | ||
return true; | ||
} | ||
}); | ||
delete visited[current]; | ||
return found; | ||
} | ||
visited.delete(current); | ||
return false; | ||
}; | ||
@@ -547,9 +779,20 @@ | ||
clone(transform=v=>v) { | ||
/** | ||
* Create a clone of this graph. | ||
* @param [tr] {function(*, string, ?string): *} | ||
* a custom transformation function for stored values; defaults to | ||
* the identity function; The first argument is the value to clone. | ||
* If it is a vertex value, the third argument is the vertex key. | ||
* If it is an edge value, the third and fourth argument are the | ||
* `from` and `to` keys respectively. (So you can test the fourth | ||
* argument to distinguish the two cases.) | ||
* @returns {JsGraph} a clone of this graph | ||
*/ | ||
clone(tr=v=>v) { | ||
var result = new JsGraph(); | ||
for (let [key, val] of this.vertices()) { | ||
result.addVertex(key, transform(val)); | ||
result.addVertex(key, tr(val, key)); | ||
} | ||
for (let [from, to, val] of this.edges()) { | ||
result.addEdge(from, to, transform(val)); | ||
result.addEdge(from, to, tr(val, from, to)); | ||
} | ||
@@ -559,4 +802,15 @@ return result; | ||
transitiveReduction() { | ||
var result = this.clone(); | ||
/** | ||
* Create a clone of this graph, but without any transitive edges. | ||
* @param [tr] {function(*, string, ?string): *} | ||
* a custom transformation function for stored values; defaults to | ||
* the identity function; The first argument is the value to clone. | ||
* If it is a vertex value, the third argument is the vertex key. | ||
* If it is an edge value, the third and fourth argument are the | ||
* `from` and `to` keys respectively. (So you can test the fourth | ||
* argument to distinguish the two cases.) | ||
* @returns {JsGraph} a clone of this graph | ||
*/ | ||
transitiveReduction(tr=v=>v) { | ||
var result = this.clone(tr); | ||
for (let [x] of this.vertices()) { | ||
@@ -583,9 +837,22 @@ for (let [y] of this.vertices()) { | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when specific vertices are expected not to exist, but do. | ||
* @extends Error | ||
*/ | ||
JsGraph.VertexExistsError = class VertexExistsError extends Error { | ||
constructor(key, value) { | ||
this.vertices = {}; | ||
/** | ||
* the set of relevant vertices | ||
* @public | ||
* @constant vertices | ||
* @memberof JsGraph.VertexExistsError | ||
* @instance | ||
* @type {Set.<{ key: string, value }>} | ||
*/ | ||
this.vertices = new Set(); | ||
this.v(key, value); | ||
} | ||
v(key, value) { | ||
this.vertices[key] = value; | ||
this.vertices.add({ key, value }); | ||
this._refreshMessage(); | ||
@@ -595,15 +862,29 @@ return this; | ||
_refreshMessage() { | ||
var aVertices = this.vertices === 1 ? "a vertex" : "vertices"; | ||
this.message = `This graph has ${aVertices} '${Object.keys(this.vertices).join("', '")}'`; | ||
var aVertices = this.vertices.size === 1 ? "a vertex" : "vertices"; | ||
this.message = `This graph has ${aVertices} '${ | ||
[...this.vertices].map((v) => v.key).join("', '") | ||
}'`; | ||
} | ||
}; | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when specific vertices are expected to exist, but don't. | ||
* @extends Error | ||
*/ | ||
JsGraph.VertexNotExistsError = class VertexNotExistError extends Error { | ||
constructor(key) { | ||
this.vertices = {}; | ||
/** | ||
* the set of relevant vertices | ||
* @public | ||
* @constant vertices | ||
* @memberof JsGraph.VertexNotExistsError | ||
* @instance | ||
* @type {Set.<{ key: string }>} | ||
*/ | ||
this.vertices = new Set(); | ||
this.v(key); | ||
} | ||
v(key) { | ||
this.vertices[key] = undefined; | ||
this.vertices.add({ key }); | ||
this._refreshMessage(); | ||
@@ -613,15 +894,29 @@ return this; | ||
_refreshMessage() { | ||
var aVertices = this.vertices === 1 ? "a vertex" : "vertices"; | ||
this.message = `This graph does not have ${aVertices} '${Object.keys(this.vertices).join("', '")}'`; | ||
var aVertices = this.vertices.size === 1 ? "a vertex" : "vertices"; | ||
this.message = `This graph does not have ${aVertices} '${ | ||
[...this.vertices].map((v) => v.key).join("', '") | ||
}'`; | ||
} | ||
}; | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when specific edges are expected not to exist, but do. | ||
* @extends Error | ||
*/ | ||
JsGraph.EdgeExistsError = class EdgeExistsError extends Error { | ||
constructor(from, to, value) { | ||
this.edges = {}; | ||
/** | ||
* the set of relevant edges | ||
* @public | ||
* @constant edges | ||
* @memberof JsGraph.EdgeExistsError | ||
* @instance | ||
* @type {Set.<{ from: string, to: string, value }>} | ||
*/ | ||
this.edges = new Set(); | ||
this.e(from, to, value); | ||
} | ||
e(from, to, value) { | ||
this.edges[from] = { [to]: value }; | ||
this.edges.add({ from, to, value }); | ||
this._refreshMessage(); | ||
@@ -632,7 +927,5 @@ return this; | ||
var edges = []; | ||
Object.keys(this.edges).forEach((from) => { | ||
Object.keys(this.edges[from]).forEach((to) => { | ||
edges.push("('" + from + "', '" + to + "')"); | ||
}); | ||
}); | ||
for (let {from, to} of this.edges) { | ||
edges.push("('" + from + "', '" + to + "')"); | ||
} | ||
var anEdges = edges.length === 1 ? "an edge" : "edges"; | ||
@@ -643,9 +936,22 @@ this.message = `This graph has ${anEdges} ${edges.join(", ")}`; | ||
JsGraph.EdgeNotExistsError = class EdgeNotExistError extends Error { | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when specific edges are expected to exist, but don't. | ||
* @extends Error | ||
*/ | ||
JsGraph.EdgeNotExistsError = class EdgeNotExistsError extends Error { | ||
constructor(from, to) { | ||
this.edges = {}; | ||
/** | ||
* the set of relevant edges | ||
* @public | ||
* @constant edges | ||
* @memberof JsGraph.EdgeNotExistsError | ||
* @instance | ||
* @type {Set.<{ from: string, to: string }>} | ||
*/ | ||
this.edges = new Set(); | ||
this.e(from, to); | ||
} | ||
e(from, to) { | ||
this.edges[from] = { [to]: undefined }; | ||
this.edges.add({ from, to }); | ||
this._refreshMessage(); | ||
@@ -656,7 +962,5 @@ return this; | ||
var edges = []; | ||
Object.keys(this.edges).forEach((from) => { | ||
Object.keys(this.edges[from]).forEach((to) => { | ||
edges.push("('" + from + "', '" + to + "')"); | ||
}); | ||
}); | ||
for (let {from, to} of this.edges) { | ||
edges.push("('" + from + "', '" + to + "')"); | ||
} | ||
var anEdges = edges.length === 1 ? "an edge" : "edges"; | ||
@@ -667,14 +971,40 @@ this.message = `This graph does not have ${anEdges} ${edges.join(", ")}`; | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when a vertex is expected not to have connected edges, but does. | ||
* @extends Error | ||
*/ | ||
JsGraph.HasConnectedEdgesError = class HasConnectedEdgesError extends Error { | ||
constructor(key) { | ||
/** | ||
* the key of the relevant vertex | ||
* @public | ||
* @constant key | ||
* @memberof JsGraph.HasConnectedEdgesError | ||
* @instance | ||
* @type {string} | ||
*/ | ||
this.key = key; | ||
this.message = `The '${key}' vertex has connected edges`; | ||
this.key = key; | ||
} | ||
}; | ||
/** | ||
* @class | ||
* @classdesc This type of error is thrown when a graph is expected not to have a directed cycle, but does. | ||
* @extends Error | ||
*/ | ||
JsGraph.CycleError = class CycleError extends Error { | ||
constructor(cycle) { | ||
/** | ||
* the vertices involved in the cycle | ||
* @public | ||
* @constant cycle | ||
* @memberof JsGraph.CycleError | ||
* @instance | ||
* @type {Array.<string>} | ||
*/ | ||
this.cycle = cycle; | ||
this.message = `This graph contains a cycle: ${cycle}`; | ||
this.cycle = cycle; | ||
} | ||
}; |
@@ -1,4 +0,4 @@ | ||
(function e(t,r){if(typeof exports==="object"&&typeof module==="object")module.exports=r();else if(typeof define==="function"&&define.amd)define(r);else if(typeof exports==="object")exports["JsGraph"]=r();else t["JsGraph"]=r()})(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:false};e[n].call(i.exports,i,i.exports,r);i.loaded=true;return i.exports}r.m=e;r.c=t;r.p="";return r(0)}([function(e,t,r){r(1);e.exports=r(2)},function(e,t,r){e.exports=r(3)},function(e,t,r){"use strict";var n=function(e,t){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var r=[];for(var n=e[Symbol.iterator](),i;!(i=n.next()).done;){r.push(i.value);if(t&&r.length===t)break}return r}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var i=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}else{return Array.from(e)}};var a=function(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})};var u=function(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof t)}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(t)e.__proto__=t};var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.configurable=true;if(n.value)n.writable=true;Object.defineProperty(e,n.key,n)}}return function(t,r,n){if(r)e(t.prototype,r);if(n)e(t,n);return t}}();var o=function(){function e(e,t){for(var r in t){var n=t[r];n.configurable=true;if(n.value)n.writable=true}Object.defineProperties(e,t)}return function(t,r,n){if(r)e(t.prototype,r);if(n)e(t,n);return t}}();var f=function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}};var c=function(){function e(){f(this,e);this._callbacks=new Set}o(e,{add:{value:function t(e){var t=this;if(!this._callbacks.has(e)){this._callbacks.add(e)}return function(){t._callbacks["delete"](e)}}},fire:{value:function r(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++){t[r]=arguments[r]}var n=true;var i=false;var a=undefined;try{for(var u=this._callbacks[Symbol.iterator](),s;!(n=(s=u.next()).done);n=true){var o=s.value;o.apply(undefined,t)}}catch(f){i=true;a=f}finally{try{if(!n&&u["return"]){u["return"]()}}finally{if(i){throw a}}}}}});return e}();var l=function(){function e(){f(this,e);this._vertices=new Map;this._edges=new Map;this._reverseEdges=new Map;this._vertexCount=0;this._edgeCount=0;this._addVertexCallbacks=new c;this._removeVertexCallbacks=new c;this._addEdgeCallbacks=new c;this._removeEdgeCallbacks=new c}s(e,[{key:"onAddVertex",value:function t(e){return this._addVertexCallbacks.add(e)}},{key:"onRemoveVertex",value:function r(e){return this._removeVertexCallbacks.add(e)}},{key:"addNewVertex",value:function a(t,r){if(this.hasVertex(t)){throw new e.VertexExistsError(t,this._vertices.get(t))}this._vertices.set(t,r);this._edges.set(t,new Map);this._reverseEdges.set(t,new Set);this._vertexCount+=1;this._addVertexCallbacks.fire(t,r)}},{key:"setVertex",value:function u(t,r){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._vertices.set(t,r)}},{key:"ensureVertex",value:function o(e,t){if(!this.hasVertex(e)){this.addNewVertex(e,t)}}},{key:"addVertex",value:function l(e,t){if(this.hasVertex(e)){this.setVertex(e,t)}else{this.addNewVertex(e,t)}}},{key:"removeExistingVertex",value:function h(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(this._edges.get(t).size>0){throw new e.HasConnectedEdgesError(t)}if(this._reverseEdges.get(t).size>0){throw new e.HasConnectedEdgesError(t)}var r=this._vertices.get(t);this._vertices["delete"](t);this._vertexCount-=1;this._removeVertexCallbacks.fire(t,r)}},{key:"destroyExistingVertex",value:function v(t){var r=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this.eachVertexFrom(t,function(e){r.removeEdge(t,e)});this.eachVertexTo(t,function(e){r.removeEdge(e,t)});this.removeExistingVertex(t)}},{key:"removeVertex",value:function d(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function g(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function p(){return this._vertexCount}},{key:"hasVertex",value:function y(e){return this._vertices.has(e)}},{key:"vertexValue",value:function x(e){return this._vertices.get(e)}},{key:"onAddEdge",value:function w(e){return this._addEdgeCallbacks.add(e)}},{key:"onRemoveEdge",value:function m(e){return this._removeEdgeCallbacks.add(e)}},{key:"addNewEdge",value:function E(t,r,n){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._edges.get(t).set(r,n);this._reverseEdges.get(r).add(t);this._edgeCount+=1;this._addEdgeCallbacks.fire(t,r,n)}},{key:"createNewEdge",value:function b(t,r,n){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}this.ensureVertex(t);this.ensureVertex(r);this.addNewEdge(t,r,n)}},{key:"setEdge",value:function k(t,r,n){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}this._edges.get(t).set(r,n)}},{key:"spanEdge",value:function _(t,r,n){if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(!this.hasEdge(t,r)){this.addNewEdge(t,r,n)}}},{key:"addEdge",value:function V(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.addNewEdge(e,t,r)}}},{key:"ensureEdge",value:function S(e,t,r){if(!this.hasEdge(e,t)){this.createNewEdge(e,t,r)}}},{key:"createEdge",value:function N(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.createNewEdge(e,t,r)}}},{key:"removeExistingEdge",value:function P(t,r){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}var n=this._edges.get(t).get(r);this._edges.get(t)["delete"](r);this._reverseEdges.get(r)["delete"](t);this._edgeCount-=1;this._removeEdgeCallbacks.fire(t,r,n)}},{key:"removeEdge",value:function C(e,t){if(this.hasEdge(e,t)){this.removeExistingEdge(e,t)}}},{key:"edgeCount",value:function O(){return this._edgeCount}},{key:"hasEdge",value:function j(e,t){return this.hasVertex(e)&&this.hasVertex(t)&&this._edges.has(e)&&this._edges.get(e).has(t)}},{key:"edgeValue",value:function L(e,t){return this.hasEdge(e,t)?this._edges.get(e).get(t):undefined}},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"vertices",value:regeneratorRuntime.mark(function F(){var e=this;var t,r,i,a,u,s,o,f,c;return regeneratorRuntime.wrap(function l(h){while(1)switch(h.prev=h.next){case 0:t=new Set;r=true;i=false;a=undefined;h.prev=4;u=e._vertices[Symbol.iterator]();case 6:if(r=(s=u.next()).done){h.next=17;break}o=n(s.value,2);f=o[0];c=o[1];if(!(e.hasVertex(f)&&!t.has(f))){h.next=14;break}t.add(f);h.next=14;return[f,c];case 14:r=true;h.next=6;break;case 17:h.next=23;break;case 19:h.prev=19;h.t0=h["catch"](4);i=true;a=h.t0;case 23:h.prev=23;h.prev=24;if(!r&&u["return"]){u["return"]()}case 26:h.prev=26;if(!i){h.next=29;break}throw a;case 29:return h.finish(26);case 30:return h.finish(23);case 31:case"end":return h.stop()}},F,this,[[4,19,23,31],[24,,26,30]])})},{key:"edges",value:regeneratorRuntime.mark(function T(){var e=this;var t,r,n,i,a,u,s,o,f,c,l,h,v;return regeneratorRuntime.wrap(function d(g){while(1)switch(g.prev=g.next){case 0:t=new Map;r=true;n=false;i=undefined;g.prev=4;a=e._edges.keys()[Symbol.iterator]();case 6:if(r=(u=a.next()).done){g.next=40;break}s=u.value;if(!t.has(s)){t.set(s,new Set)}o=true;f=false;c=undefined;g.prev=12;l=e._edges.get(s).keys()[Symbol.iterator]();case 14:if(o=(h=l.next()).done){g.next=23;break}v=h.value;if(!(e.hasEdge(s,v)&&!t.get(s).has(v))){g.next=20;break}t.get(s).add(v);g.next=20;return[s,v,e._edges.get(s).get(v)];case 20:o=true;g.next=14;break;case 23:g.next=29;break;case 25:g.prev=25;g.t1=g["catch"](12);f=true;c=g.t1;case 29:g.prev=29;g.prev=30;if(!o&&l["return"]){l["return"]()}case 32:g.prev=32;if(!f){g.next=35;break}throw c;case 35:return g.finish(32);case 36:return g.finish(29);case 37:r=true;g.next=6;break;case 40:g.next=46;break;case 42:g.prev=42;g.t2=g["catch"](4);n=true;i=g.t2;case 46:g.prev=46;g.prev=47;if(!r&&a["return"]){a["return"]()}case 49:g.prev=49;if(!n){g.next=52;break}throw i;case 52:return g.finish(49);case 53:return g.finish(46);case 54:case"end":return g.stop()}},T,this,[[4,42,46,54],[12,25,29,37],[30,,32,36],[47,,49,53]])})},{key:"verticesFrom",value:function I(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesFrom(t)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function R(e){var t=this;var r,n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:r=new Set;n=true;i=false;a=undefined;c.prev=4;u=t._edges.get(e).keys()[Symbol.iterator]();case 6:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(t.hasEdge(e,o)&&!r.has(o))){c.next=12;break}r.add(o);c.next=12;return[o,t._vertices.get(o),t._edges.get(e).get(o)];case 12:n=true;c.next=6;break;case 15:c.next=21;break;case 17:c.prev=17;c.t3=c["catch"](4);i=true;a=c.t3;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},R,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesTo",value:function A(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesTo(t)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function M(e){var t=this;var r,n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:r=new Set;n=true;i=false;a=undefined;c.prev=4;u=t._reverseEdges.get(e)[Symbol.iterator]();case 6:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(t.hasEdge(o,e)&&!r.has(o))){c.next=12;break}r.add(o);c.next=12;return[o,t._vertices.get(o),t._edges.get(o).get(e)];case 12:n=true;c.next=6;break;case 15:c.next=21;break;case 17:c.prev=17;c.t4=c["catch"](4);i=true;a=c.t4;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},M,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesWithPathFrom",value:function W(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesWithPathFrom(t,new Set)}},{key:"_verticesWithPathFrom",value:regeneratorRuntime.mark(function G(e,t){var r=this;var n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:n=true;i=false;a=undefined;c.prev=3;u=r._edges.get(e).keys()[Symbol.iterator]();case 5:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(r.hasEdge(e,o)&&!t.has(o))){c.next=12;break}t.add(o);c.next=11;return[o,r._vertices.get(o)];case 11:return c.delegateYield(r._verticesWithPathFrom(o,t),"t5",12);case 12:n=true;c.next=5;break;case 15:c.next=21;break;case 17:c.prev=17;c.t6=c["catch"](3);i=true;a=c.t6;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},G,this,[[3,17,21,29],[22,,24,28]])})},{key:"verticesWithPathTo",value:function z(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesWithPathTo(t,new Set)}},{key:"_verticesWithPathTo",value:regeneratorRuntime.mark(function Y(e,t){var r=this;var n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:n=true;i=false;a=undefined;c.prev=3;u=r._reverseEdges.get(e)[Symbol.iterator]();case 5:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(r.hasEdge(o,e)&&!t.has(o))){c.next=12;break}t.add(o);c.next=11;return[o,r._vertices.get(o)];case 11:return c.delegateYield(r._verticesWithPathTo(o,t),"t7",12);case 12:n=true;c.next=5;break;case 15:c.next=21;break;case 17:c.prev=17;c.t8=c["catch"](3);i=true;a=c.t8;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},Y,this,[[3,17,21,29],[22,,24,28]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function D(){var t=this;var r=regeneratorRuntime.mark(function d(t){var r,s,o,f,c,l,h,v,g;return regeneratorRuntime.wrap(function p(y){while(1)switch(y.prev=y.next){case 0:i.push(t);r=i.indexOf(t);if(!(r!==i.length-1)){y.next=5;break}s=i.slice(r+1).reverse();throw new e.CycleError(s);case 5:if(a.has(t)){y.next=36;break}o=true;f=false;c=undefined;y.prev=9;l=u.verticesTo(t)[Symbol.iterator]();case 11:if(o=(h=l.next()).done){y.next=18;break}v=n(h.value,1);g=v[0];return y.delegateYield(d(g),"t9",15);case 15:o=true;y.next=11;break;case 18:y.next=24;break;case 20:y.prev=20;y.t10=y["catch"](9);f=true;c=y.t10;case 24:y.prev=24;y.prev=25;if(!o&&l["return"]){l["return"]()}case 27:y.prev=27;if(!f){y.next=30;break}throw c;case 30:return y.finish(27);case 31:return y.finish(24);case 32:if(!u.hasVertex(t)){y.next=35;break}y.next=35;return[t,u._vertices.get(t)];case 35:a.add(t);case 36:i.pop();case 37:case"end":return y.stop()}},d,this,[[9,20,24,32],[25,,27,31]])});var i,a,u,s,o,f,c,l,h,v;return regeneratorRuntime.wrap(function g(e){while(1)switch(e.prev=e.next){case 0:i=[];a=new Set;u=t;s=true;o=false;f=undefined;e.prev=6;c=t.vertices()[Symbol.iterator]();case 8:if(s=(l=c.next()).done){e.next=16;break}h=n(l.value,1);v=h[0];if(a.has(v)){e.next=13;break}return e.delegateYield(r(v),"t11",13);case 13:s=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t12=e["catch"](6);o=true;f=e.t12;case 22:e.prev=22;e.prev=23;if(!s&&c["return"]){c["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw f;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},D,this,[[6,18,22,30],[23,,25,29]])})},{key:"eachVertex",value:function J(e){var t=true;var r=false;var n=undefined;try{for(var a=this.vertices()[Symbol.iterator](),u;!(t=(u=a.next()).done);t=true){var s=u.value;if(e.apply(undefined,i(s))===false){break}}}catch(o){r=true;n=o}finally{try{if(!t&&a["return"]){a["return"]()}}finally{if(r){throw n}}}}},{key:"eachEdge",value:function $(e){var t=true;var r=false;var n=undefined;try{for(var a=this.edges()[Symbol.iterator](),u;!(t=(u=a.next()).done);t=true){var s=u.value;if(e.apply(undefined,i(s))===false){break}}}catch(o){r=true;n=o}finally{try{if(!t&&a["return"]){a["return"]()}}finally{if(r){throw n}}}}},{key:"eachVertexFrom",value:function U(e,t){var r=true;var n=false;var a=undefined;try{for(var u=this.verticesFrom(e)[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=s.value;if(t.apply(undefined,i(o))===false){break}}}catch(f){n=true;a=f}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(n){throw a}}}}},{key:"eachVertexTo",value:function H(e,t){var r=true;var n=false;var a=undefined;try{for(var u=this.verticesTo(e)[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=s.value;if(t.apply(undefined,i(o))===false){break}}}catch(f){n=true;a=f}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(n){throw a}}}}},{key:"eachVertexWithPathFrom",value:function q(e,t){var r=true;var n=false;var a=undefined;try{for(var u=this.verticesWithPathFrom(e)[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=s.value;if(t.apply(undefined,i(o))===false){break}}}catch(f){n=true;a=f}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(n){throw a}}}}},{key:"eachVertexWithPathTo",value:function X(e,t){var r=true;var n=false;var a=undefined;try{for(var u=this.verticesWithPathTo(e)[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=s.value;if(t.apply(undefined,i(o))===false){break}}}catch(f){n=true;a=f}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(n){throw a}}}}},{key:"eachVertexTopologically",value:function K(e){var t=true;var r=false;var n=undefined;try{for(var a=this.vertices_topologically()[Symbol.iterator](),u;!(t=(u=a.next()).done);t=true){var s=u.value;if(e.apply(undefined,i(s))===false){break}}}catch(o){r=true;n=o}finally{try{if(!t&&a["return"]){a["return"]()}}finally{if(r){throw n}}}}},{key:"clearEdges",value:function B(){var e=this;this.eachEdge(function(t,r){e.removeEdge(t,r)})}},{key:"clear",value:function Q(){var e=this;this.eachVertex(function(t){e.destroyVertex(t)})}},{key:"equals",value:function Z(t){var r=arguments[1]===undefined?function(e,t,r,n){return e===t}:arguments[1];if(!(t instanceof e)){return false}if(this.vertexCount()!==t.vertexCount()){return false}if(this.edgeCount()!==t.edgeCount()){return false}var i=true;var a=false;var u=undefined;try{for(var s=this.vertices()[Symbol.iterator](),o;!(i=(o=s.next()).done);i=true){var f=n(o.value,2);var c=f[0];var l=f[1];if(!t.hasVertex(c)){return false}if(!r(l,t.vertexValue(c),c)){return false}}}catch(h){a=true;u=h}finally{try{if(!i&&s["return"]){s["return"]()}}finally{if(a){throw u}}}var v=true;var d=false;var g=undefined;try{for(var p=this.edges()[Symbol.iterator](),y;!(v=(y=p.next()).done);v=true){var x=n(y.value,3);var w=x[0];var m=x[1];var l=x[2];if(!t.hasEdge(w,m)){return false}if(!r(l,t.edgeValue(w,m),w,m)){return false}}}catch(h){d=true;g=h}finally{try{if(!v&&p["return"]){p["return"]()}}finally{if(d){throw g}}}return true}},{key:"hasCycle",value:function ee(){var e=this;var t={};var r={};var n=false;var i=function(a){if(t[a]){n=true;return}if(r[a]){return}r[a]=true;t[a]=true;e.eachVertexFrom(a,function(e){i(e);if(n){return false}});t[a]=false};this.eachVertex(function(e){i(e);if(n){return false}});return n}},{key:"hasPath",value:function te(e,t){var r=this;if(!this.hasVertex(e)||!this.hasVertex(t)){return false}var n={};var i=function(e){if(r.hasEdge(e,t)){return true}n[e]=true;var a=false;r.eachVertexFrom(e,function(e){if(!a&&!n[e]&&i(e)){a=true}});delete n[e];return a};return i(e)}},{key:"clone",value:function re(){var t=arguments[0]===undefined?function(e){return e}:arguments[0];var r=new e;var i=true;var a=false;var u=undefined;try{for(var s=this.vertices()[Symbol.iterator](),o;!(i=(o=s.next()).done);i=true){var f=n(o.value,2);var c=f[0];var l=f[1];r.addVertex(c,t(l))}}catch(h){a=true;u=h}finally{try{if(!i&&s["return"]){s["return"]()}}finally{if(a){throw u}}}var v=true;var d=false;var g=undefined;try{for(var p=this.edges()[Symbol.iterator](),y;!(v=(y=p.next()).done);v=true){var x=n(y.value,3);var w=x[0];var m=x[1];var l=x[2];r.addEdge(w,m,t(l))}}catch(h){d=true;g=h}finally{try{if(!v&&p["return"]){p["return"]()}}finally{if(d){throw g}}}return r}},{key:"transitiveReduction",value:function ne(){var e=this.clone();var t=true;var r=false;var i=undefined;try{for(var a=this.vertices()[Symbol.iterator](),u;!(t=(u=a.next()).done);t=true){var s=n(u.value,1);var o=s[0];var f=true;var c=false;var l=undefined;try{for(var h=this.vertices()[Symbol.iterator](),v;!(f=(v=h.next()).done);f=true){var d=n(v.value,1);var g=d[0];if(e.hasEdge(o,g)){var p=true;var y=false;var x=undefined;try{for(var w=this.vertices()[Symbol.iterator](),m;!(p=(m=w.next()).done);p=true){var E=n(m.value,1);var b=E[0];if(e.hasPath(g,b)){e.removeEdge(o,b)}}}catch(k){y=true;x=k}finally{try{if(!p&&w["return"]){w["return"]()}}finally{if(y){throw x}}}}}}catch(k){c=true;l=k}finally{try{if(!f&&h["return"]){h["return"]()}}finally{if(c){throw l}}}}}catch(k){r=true;i=k}finally{try{if(!t&&a["return"]){a["return"]()}}finally{if(r){throw i}}}return e}}]);return e}();e.exports=l;l.VertexExistsError=function(e){function t(e,r){f(this,t);this.vertices={};this.v(e,r)}u(t,e);o(t,{v:{value:function r(e,t){this.vertices[e]=t;this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);l.VertexNotExistsError=function(e){function t(e){f(this,t);this.vertices={};this.v(e)}u(t,e);o(t,{v:{value:function r(e){this.vertices[e]=undefined;this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);l.EdgeExistsError=function(e){function t(e,r,n){f(this,t);this.edges={};this.e(e,r,n)}u(t,e);o(t,{e:{value:function r(e,t,n){this.edges[e]=a({},t,n);this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph has "+r+" "+t.join(", ")}}});return t}(Error);l.EdgeNotExistsError=function(e){function t(e,r){f(this,t);this.edges={};this.e(e,r)}u(t,e);o(t,{e:{value:function r(e,t){this.edges[e]=a({},t,undefined);this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph does not have "+r+" "+t.join(", ")}}});return t}(Error);l.HasConnectedEdgesError=function(e){function t(e){f(this,t);this.message="The '"+e+"' vertex has connected edges";this.key=e}u(t,e);return t}(Error);l.CycleError=function(e){function t(e){f(this,t);this.message="This graph contains a cycle: "+e;this.cycle=e}u(t,e);return t}(Error)},function(e,t,r){(function(e){"use strict";if(e._babelPolyfill){throw new Error("only one instance of babel/polyfill is allowed")}e._babelPolyfill=true;r(4);r(5)}).call(t,function(){return this}())},function(e,t,r){!function(t,r,n){"use strict";var i="Object",a="Function",u="Array",s="String",o="Number",f="RegExp",c="Date",l="Map",h="Set",v="WeakMap",d="WeakSet",g="Symbol",p="Promise",y="Math",x="Arguments",w="prototype",m="constructor",E="toString",b=E+"Tag",k="toLocaleString",_="hasOwnProperty",V="forEach",S="iterator",N="@@"+S,P="process",C="createElement",O=t[a],j=t[i],L=t[u],F=t[s],T=t[o],I=t[f],R=t[c],A=t[l],M=t[h],W=t[v],G=t[d],z=t[g],Y=t[y],D=t.TypeError,J=t.RangeError,$=t.setTimeout,U=t.setImmediate,H=t.clearImmediate,q=t.parseInt,X=t.isFinite,K=t[P],B=K&&K.nextTick,Q=t.document,Z=Q&&Q.documentElement,ee=t.navigator,te=t.define,re=t.console||{},ne=L[w],ie=j[w],ae=O[w],ue=1/0,se=".";function oe(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function fe(e){return typeof e=="function"}var ce=we(/./.test,/\[native code\]\s*\}\s*$/,1);var le=ie[E];function he(e,t,r){if(e&&!je(e=r?e:e[w],Lt))St(e,Lt,t)}function ve(e){return le.call(e).slice(8,-1)}function de(e){var t,r;return e==n?e===n?"Undefined":"Null":typeof(r=(t=j(e))[Lt])=="string"?r:ve(t)}var ge=ae.call,pe=ae.apply,ye;function xe(){var e=pt(this),t=arguments.length,r=L(t),n=0,i=Mt._,a=false;while(t>n)if((r[n]=arguments[n++])===i)a=true;return function(){var n=this,u=arguments.length,s=0,o=0,f;if(!a&&!u)return me(e,r,n);f=r.slice();if(a)for(;t>s;s++)if(f[s]===i)f[s]=arguments[o++];while(u>o)f.push(arguments[o++]);return me(e,f,n)}}function we(e,t,r){pt(e);if(~r&&t===n)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}function me(e,t,r){var i=r===n;switch(t.length|0){case 0:return i?e():e.call(r);case 1:return i?e(t[0]):e.call(r,t[0]);case 2:return i?e(t[0],t[1]):e.call(r,t[0],t[1]);case 3:return i?e(t[0],t[1],t[2]):e.call(r,t[0],t[1],t[2]);case 4:return i?e(t[0],t[1],t[2],t[3]):e.call(r,t[0],t[1],t[2],t[3]);case 5:return i?e(t[0],t[1],t[2],t[3],t[4]):e.call(r,t[0],t[1],t[2],t[3],t[4])}return e.apply(r,t)}var Ee=j.create,be=j.getPrototypeOf,ke=j.setPrototypeOf,_e=j.defineProperty,Ve=j.defineProperties,Se=j.getOwnPropertyDescriptor,Ne=j.keys,Pe=j.getOwnPropertyNames,Ce=j.getOwnPropertySymbols,Oe=j.isFrozen,je=we(ge,ie[_],2),Le=j,Fe;function Te(e){return Le(gt(e))}function Ie(e){return e}function Re(){return this}function Ae(e,t){if(je(e,t))return e[t]}function Me(e){yt(e);return Ce?Pe(e).concat(Ce(e)):Pe(e)}var We=j.assign||function(e,t){var r=j(gt(e)),n=arguments.length,i=1;while(n>i){var a=Le(arguments[i++]),u=Ne(a),s=u.length,o=0,f;while(s>o)r[f=u[o++]]=a[f]}return r};function Ge(e,t){var r=Te(e),n=Ne(r),i=n.length,a=0,u;while(i>a)if(r[u=n[a++]]===t)return u}function ze(e){return F(e).split(",")}var Ye=ne.push,De=ne.unshift,Je=ne.slice,$e=ne.splice,Ue=ne.indexOf,He=ne[V];function qe(e){var t=e==1,r=e==2,i=e==3,a=e==4,u=e==6,s=e==5||u;return function(o){var f=j(gt(this)),c=arguments[1],l=Le(f),h=we(o,c,3),v=ot(l.length),d=0,g=t?L(v):r?[]:n,p,y;for(;v>d;d++)if(s||d in l){p=l[d];y=h(p,d,f);if(e){if(t)g[d]=y;else if(y)switch(e){case 3:return true;case 5:return p;case 6:return d;case 2:g.push(p)}else if(a)return false}}return u?-1:i||a?a:g}}function Xe(e){return function(t){var r=Te(this),n=ot(r.length),i=ft(arguments[1],n);if(e&&t!=t){for(;n>i;i++)if(ut(r[i]))return e||i}else for(;n>i;i++)if(e||i in r){if(r[i]===t)return e||i}return!e&&-1}}function Ke(e,t){return typeof e=="function"?e:t}var Be=9007199254740991,Qe=Y.pow,Ze=Y.abs,et=Y.ceil,tt=Y.floor,rt=Y.max,nt=Y.min,it=Y.random,at=Y.trunc||function(e){return(e>0?tt:et)(e)};function ut(e){return e!=e}function st(e){return isNaN(e)?0:at(e)}function ot(e){return e>0?nt(st(e),Be):0}function ft(e,t){var e=st(e);return e<0?rt(e+t,0):nt(e,t)}function ct(e){return e>9?e:"0"+e}function lt(e,t,r){var n=oe(t)?function(e){return t[e]}:t;return function(t){return F(r?t:this).replace(e,n)}}function ht(e){return function(t){var r=F(gt(this)),i=st(t),a=r.length,u,s;if(i<0||i>=a)return e?"":n;u=r.charCodeAt(i);return u<55296||u>56319||i+1===a||(s=r.charCodeAt(i+1))<56320||s>57343?e?r.charAt(i):u:e?r.slice(i,i+2):(u-55296<<10)+(s-56320)+65536}}var vt="Reduce of empty object with no initial value";function dt(e,t,r){if(!e)throw D(r?t+r:t)}function gt(e){if(e==n)throw D("Function called on null or undefined");return e}function pt(e){dt(fe(e),e," is not a function!");return e}function yt(e){dt(oe(e),e," is not an object!");return e}function xt(e,t,r){dt(e instanceof t,r,": use the 'new' operator!")}function wt(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}function mt(e,t,r){e[t]=r;return e}function Et(e){return _t?function(t,r,n){return _e(t,r,wt(e,n))}:mt}function bt(e){return g+"("+e+")_"+(++Vt+it())[E](36)}function kt(e,t){return z&&z[e]||(t?z:Pt)(g+se+e)}var _t=!!function(){try{return _e({},"a",{get:function(){return 2}}).a==2}catch(e){}}(),Vt=0,St=Et(1),Nt=z?mt:St,Pt=z||bt;function Ct(e,t){for(var r in t)St(e,r,t[r]);return e}var Ot=kt("unscopables"),jt=ne[Ot]||{},Lt=kt(b),Ft=kt("species"),Tt;function It(e){if(_t&&(r||!ce(e)))_e(e,Ft,{configurable:true,get:Re})}var Rt=ve(K)==P,At={},Mt=r?t:At,Wt=t.core,Gt,zt=1,Yt=2,Dt=4,Jt=8,$t=16,Ut=32;function Ht(e,n,i){var a,u,s,o,f=e&Yt,c=f?t:e&Dt?t[n]:(t[n]||ie)[w],l=f?At:At[n]||(At[n]={});if(f)i=n;for(a in i){u=!(e&zt)&&c&&a in c&&(!fe(c[a])||ce(c[a]));s=(u?c:i)[a];if(!r&&f&&!fe(c[a]))o=i[a];else if(e&$t&&u)o=we(s,t);else if(e&Ut&&!r&&c[a]==s){o=function(e){return this instanceof s?new s(e):s(e)};o[w]=s[w]}else o=e&Jt&&fe(s)?we(ge,s):s;if(r&&c&&!u){if(f)c[a]=s;else delete c[a]&&St(c,a,s)}if(l[a]!=s)St(l,a,o)}}if(typeof e!="undefined"&&e.exports)e.exports=At;else if(fe(te)&&te.amd)te(function(){return At});else Gt=true;if(Gt||r){At.noConflict=function(){t.core=Wt;return At};t.core=At}Tt=kt(S);var qt=Pt("iter"),Xt=1,Kt=2,Bt={},Qt={},Zt="keys"in ne&&!("next"in[].keys());er(Qt,Re);function er(e,t){St(e,Tt,t);N in ne&&St(e,N,t)}function tr(e,t,r,n){e[w]=Ee(n||Qt,{next:wt(1,r)});he(e,t+" Iterator")}function rr(e,t,n,i){var a=e[w],u=Ae(a,Tt)||Ae(a,N)||i&&Ae(a,i)||n;if(r){er(a,u);if(u!==n){var s=be(u.call(new e));he(s,t+" Iterator",true);je(a,N)&&er(s,Re)}}Bt[t]=u;Bt[t+" Iterator"]=Re;return u}function nr(e,t,r,n,i,a){function u(e){return function(){return new r(this,e)}}tr(r,t,n);var s=u(Xt+Kt),o=u(Kt);if(i==Kt)o=rr(e,t,o,"values");else s=rr(e,t,s,"entries");if(i){Ht(Jt+zt*Zt,t,{entries:s,keys:a?o:u(Xt),values:o})}}function ir(e,t){return{value:t,done:!!e}}function ar(e){var r=j(e),n=t[g],i=(n&&n[S]||N)in r;return i||Tt in r||je(Bt,de(r))}function ur(e){var r=t[g],n=e[r&&r[S]||N],i=n||e[Tt]||Bt[de(e)];return yt(i.call(e))}function sr(e,t,r){return r?me(e,t):e(t)}function or(e){var t=true;var r={next:function(){throw 1},"return":function(){t=false}};r[Tt]=Re;try{e(r)}catch(n){}return t}function fr(e){var t=e["return"];if(t!==n)t.call(e)}function cr(e,t){try{e(t)}catch(r){fr(t);throw r}}function lr(e,t,r,n){cr(function(e){var i=we(r,n,t?2:1),a;while(!(a=e.next()).done)if(sr(i,a.value,t)===false){return fr(e)}},ur(e))}!function(e,r,n,a){if(!ce(z)){z=function(t){dt(!(this instanceof z),g+" is not a "+m);var r=bt(t),i=Nt(Ee(z[w]),e,r);n[r]=i;_t&&a&&_e(ie,r,{configurable:true,set:function(e){St(this,r,e)}});return i};St(z[w],E,function(){return this[e]})}Ht(Yt+Ut,{Symbol:z});var u={"for":function(e){return je(r,e+="")?r[e]:r[e]=z(e)},iterator:Tt||kt(S),keyFor:xe.call(Ge,r),species:Ft,toStringTag:Lt=kt(b,true),unscopables:Ot,pure:Pt,set:Nt,useSetter:function(){a=true},useSimple:function(){a=false}};He.call(ze("hasInstance,isConcatSpreadable,match,replace,search,split,toPrimitive"),function(e){u[e]=kt(e)});Ht(Dt,g,u);he(z,g);Ht(Dt+zt*!ce(z),i,{getOwnPropertyNames:function(e){var t=Pe(Te(e)),r=[],i,a=0;while(t.length>a)je(n,i=t[a++])||r.push(i);return r},getOwnPropertySymbols:function(e){var t=Pe(Te(e)),r=[],i,a=0;while(t.length>a)je(n,i=t[a++])&&r.push(n[i]);return r}});he(Y,y,true);he(t.JSON,"JSON",true)}(Pt("tag"),{},{},true);!function(){var e={assign:We,is:function(e,t){return e===t?e!==0||1/e===1/t:e!=e&&t!=t}};"__proto__"in ie&&function(t,r){try{r=we(ge,Se(ie,"__proto__").set,2);r({},ne)}catch(n){t=true}e.setPrototypeOf=ke=ke||function(e,n){yt(e);dt(n===null||oe(n),n,": can't set as prototype!");if(t)e.__proto__=n;else r(e,n);return e}}();Ht(Dt,i,e)}();!function(e){e[Lt]=se;if(ve(e)!=se)St(ie,E,function(){return"[object "+de(this)+"]"})}({});!function(){function e(e,t){var r=j[e],n=At[i][e],a=0,u={};if(!n||ce(n)){u[e]=t==1?function(e){return oe(e)?r(e):e}:t==2?function(e){return oe(e)?r(e):true}:t==3?function(e){return oe(e)?r(e):false}:t==4?function(e,t){return r(Te(e),t)}:function(e){return r(Te(e))};try{r(se)}catch(s){a=1}Ht(Dt+zt*a,i,u)}}e("freeze",1);e("seal",1);e("preventExtensions",1);e("isFrozen",2);e("isSealed",2);e("isExtensible",3);e("getOwnPropertyDescriptor",4);e("getPrototypeOf");e("keys");e("getOwnPropertyNames")}();!function(e){e in ae||_t&&_e(ae,e,{configurable:true,get:function(){var t=F(this).match(/^\s*function ([^ (]*)/),r=t?t[1]:"";je(this,e)||_e(this,e,wt(5,r));return r},set:function(t){je(this,e)||_e(this,e,wt(0,t))}})}("name");T("0o1")&&T("0b1")||function(e,r){function n(e){if(oe(e))e=i(e);if(typeof e=="string"&&e.length>2&&e.charCodeAt(0)==48){var t=false;switch(e.charCodeAt(1)){case 66:case 98:t=true;case 79:case 111:return q(e.slice(2),t?2:8)}}return+e}function i(e){var t,r;if(fe(t=e.valueOf)&&!oe(r=t.call(e)))return r;if(fe(t=e[E])&&!oe(r=t.call(e)))return r;throw D("Can't convert object to number")}T=function a(t){return this instanceof a?new e(n(t)):n(t)};He.call(_t?Pe(e):ze("MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY"),function(t){t in T||_e(T,t,Se(e,t))});T[w]=r;r[m]=T;St(t,o,T)}(T,T[w]);!function(e){Ht(Dt,o,{EPSILON:Qe(2,-52),isFinite:function(e){return typeof e=="number"&&X(e)},isInteger:e,isNaN:ut,isSafeInteger:function(t){return e(t)&&Ze(t)<=Be},MAX_SAFE_INTEGER:Be,MIN_SAFE_INTEGER:-Be,parseFloat:parseFloat,parseInt:q})}(T.isInteger||function(e){return!oe(e)&&X(e)&&tt(e)===e; | ||
(function e(t,r){if(typeof exports==="object"&&typeof module==="object")module.exports=r();else if(typeof define==="function"&&define.amd)define(r);else if(typeof exports==="object")exports["JsGraph"]=r();else t["JsGraph"]=r()})(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:false};e[n].call(i.exports,i,i.exports,r);i.loaded=true;return i.exports}r.m=e;r.c=t;r.p="";return r(0)}([function(e,t,r){r(1);e.exports=r(2)},function(e,t,r){e.exports=r(3)},function(e,t,r){"use strict";var n=function(e,t){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var r=[];for(var n=e[Symbol.iterator](),i;!(i=n.next()).done;){r.push(i.value);if(t&&r.length===t)break}return r}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var i=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}else{return Array.from(e)}};var a=function(){function e(e,t){for(var r in t){var n=t[r];n.configurable=true;if(n.value)n.writable=true}Object.defineProperties(e,t)}return function(t,r,n){if(r)e(t.prototype,r);if(n)e(t,n);return t}}();var u=function(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof t)}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(t)e.__proto__=t};var s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.configurable=true;if(n.value)n.writable=true;Object.defineProperty(e,n.key,n)}}return function(t,r,n){if(r)e(t.prototype,r);if(n)e(t,n);return t}}();var o=function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}};var f=function(){function e(){o(this,e);this._vertices=new Map;this._edges=new Map;this._reverseEdges=new Map;this._vertexCount=0;this._edgeCount=0}s(e,[{key:"addNewVertex",value:function t(r,n){if(this.hasVertex(r)){throw new e.VertexExistsError(r,this._vertices.get(r))}this._vertices.set(r,n);this._edges.set(r,new Map);this._reverseEdges.set(r,new Set);this._vertexCount+=1}},{key:"setVertex",value:function r(t,n){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._vertices.set(t,n)}},{key:"ensureVertex",value:function i(e,t){if(!this.hasVertex(e)){this.addNewVertex(e,t)}}},{key:"addVertex",value:function a(e,t){if(this.hasVertex(e)){this.setVertex(e,t)}else{this.addNewVertex(e,t)}}},{key:"removeExistingVertex",value:function u(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(this._edges.get(t).size>0||this._reverseEdges.get(t).size>0){throw new e.HasConnectedEdgesError(t)}this._vertices["delete"](t);this._vertexCount-=1}},{key:"destroyExistingVertex",value:function f(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}var r=true;var i=false;var a=undefined;try{for(var u=this.verticesFrom(t)[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=n(s.value,1);var f=o[0];this.removeEdge(t,f)}}catch(c){i=true;a=c}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(i){throw a}}}var l=true;var h=false;var v=undefined;try{for(var d=this.verticesTo(t)[Symbol.iterator](),g;!(l=(g=d.next()).done);l=true){var p=n(g.value,1);var y=p[0];this.removeEdge(y,t)}}catch(c){h=true;v=c}finally{try{if(!l&&d["return"]){d["return"]()}}finally{if(h){throw v}}}this.removeExistingVertex(t)}},{key:"removeVertex",value:function c(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function l(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function h(){return this._vertexCount}},{key:"hasVertex",value:function v(e){return this._vertices.has(e)}},{key:"vertexValue",value:function d(e){return this._vertices.get(e)}},{key:"addNewEdge",value:function g(t,r,n){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._edges.get(t).set(r,n);this._reverseEdges.get(r).add(t);this._edgeCount+=1}},{key:"createNewEdge",value:function p(t,r,n){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}this.ensureVertex(t);this.ensureVertex(r);this.addNewEdge(t,r,n)}},{key:"setEdge",value:function y(t,r,n){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}this._edges.get(t).set(r,n)}},{key:"spanEdge",value:function x(t,r,n){if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(!this.hasEdge(t,r)){this.addNewEdge(t,r,n)}}},{key:"addEdge",value:function w(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.addNewEdge(e,t,r)}}},{key:"ensureEdge",value:function m(e,t,r){if(!this.hasEdge(e,t)){this.createNewEdge(e,t,r)}}},{key:"createEdge",value:function E(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.createNewEdge(e,t,r)}}},{key:"removeExistingEdge",value:function b(t,r){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}this._edges.get(t)["delete"](r);this._reverseEdges.get(r)["delete"](t);this._edgeCount-=1}},{key:"removeEdge",value:function k(e,t){if(this.hasEdge(e,t)){this.removeExistingEdge(e,t)}}},{key:"edgeCount",value:function _(){return this._edgeCount}},{key:"hasEdge",value:function S(e,t){return this.hasVertex(e)&&this.hasVertex(t)&&this._edges.has(e)&&this._edges.get(e).has(t)}},{key:"edgeValue",value:function V(e,t){return this.hasEdge(e,t)?this._edges.get(e).get(t):undefined}},{key:"vertices",value:regeneratorRuntime.mark(function N(){var e=this;var t,r,i,a,u,s,o,f,c;return regeneratorRuntime.wrap(function l(h){while(1)switch(h.prev=h.next){case 0:t=new Set;r=true;i=false;a=undefined;h.prev=4;u=e._vertices[Symbol.iterator]();case 6:if(r=(s=u.next()).done){h.next=17;break}o=n(s.value,2);f=o[0];c=o[1];if(!(e.hasVertex(f)&&!t.has(f))){h.next=14;break}t.add(f);h.next=14;return[f,c];case 14:r=true;h.next=6;break;case 17:h.next=23;break;case 19:h.prev=19;h.t0=h["catch"](4);i=true;a=h.t0;case 23:h.prev=23;h.prev=24;if(!r&&u["return"]){u["return"]()}case 26:h.prev=26;if(!i){h.next=29;break}throw a;case 29:return h.finish(26);case 30:return h.finish(23);case 31:case"end":return h.stop()}},N,this,[[4,19,23,31],[24,,26,30]])})},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"edges",value:regeneratorRuntime.mark(function P(){var e=this;var t,r,n,i,a,u,s,o,f,c,l,h,v;return regeneratorRuntime.wrap(function d(g){while(1)switch(g.prev=g.next){case 0:t=new Map;r=true;n=false;i=undefined;g.prev=4;a=e._edges.keys()[Symbol.iterator]();case 6:if(r=(u=a.next()).done){g.next=40;break}s=u.value;if(!t.has(s)){t.set(s,new Set)}o=true;f=false;c=undefined;g.prev=12;l=e._edges.get(s).keys()[Symbol.iterator]();case 14:if(o=(h=l.next()).done){g.next=23;break}v=h.value;if(!(e.hasEdge(s,v)&&!t.get(s).has(v))){g.next=20;break}t.get(s).add(v);g.next=20;return[s,v,e._edges.get(s).get(v)];case 20:o=true;g.next=14;break;case 23:g.next=29;break;case 25:g.prev=25;g.t1=g["catch"](12);f=true;c=g.t1;case 29:g.prev=29;g.prev=30;if(!o&&l["return"]){l["return"]()}case 32:g.prev=32;if(!f){g.next=35;break}throw c;case 35:return g.finish(32);case 36:return g.finish(29);case 37:r=true;g.next=6;break;case 40:g.next=46;break;case 42:g.prev=42;g.t2=g["catch"](4);n=true;i=g.t2;case 46:g.prev=46;g.prev=47;if(!r&&a["return"]){a["return"]()}case 49:g.prev=49;if(!n){g.next=52;break}throw i;case 52:return g.finish(49);case 53:return g.finish(46);case 54:case"end":return g.stop()}},P,this,[[4,42,46,54],[12,25,29,37],[30,,32,36],[47,,49,53]])})},{key:"verticesFrom",value:function O(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesFrom(t)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function L(e){var t=this;var r,n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:r=new Set;n=true;i=false;a=undefined;c.prev=4;u=t._edges.get(e).keys()[Symbol.iterator]();case 6:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(t.hasEdge(e,o)&&!r.has(o))){c.next=12;break}r.add(o);c.next=12;return[o,t._vertices.get(o),t._edges.get(e).get(o)];case 12:n=true;c.next=6;break;case 15:c.next=21;break;case 17:c.prev=17;c.t3=c["catch"](4);i=true;a=c.t3;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},L,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesTo",value:function j(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesTo(t)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function C(e){var t=this;var r,n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:r=new Set;n=true;i=false;a=undefined;c.prev=4;u=t._reverseEdges.get(e)[Symbol.iterator]();case 6:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(t.hasEdge(o,e)&&!r.has(o))){c.next=12;break}r.add(o);c.next=12;return[o,t._vertices.get(o),t._edges.get(o).get(e)];case 12:n=true;c.next=6;break;case 15:c.next=21;break;case 17:c.prev=17;c.t4=c["catch"](4);i=true;a=c.t4;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},C,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesWithPathFrom",value:function I(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesWithPathFrom(t,new Set)}},{key:"_verticesWithPathFrom",value:regeneratorRuntime.mark(function F(e,t){var r=this;var n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:n=true;i=false;a=undefined;c.prev=3;u=r._edges.get(e).keys()[Symbol.iterator]();case 5:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(r.hasEdge(e,o)&&!t.has(o))){c.next=12;break}t.add(o);c.next=11;return[o,r._vertices.get(o)];case 11:return c.delegateYield(r._verticesWithPathFrom(o,t),"t5",12);case 12:n=true;c.next=5;break;case 15:c.next=21;break;case 17:c.prev=17;c.t6=c["catch"](3);i=true;a=c.t6;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},F,this,[[3,17,21,29],[22,,24,28]])})},{key:"verticesWithPathTo",value:function T(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesWithPathTo(t,new Set)}},{key:"_verticesWithPathTo",value:regeneratorRuntime.mark(function R(e,t){var r=this;var n,i,a,u,s,o;return regeneratorRuntime.wrap(function f(c){while(1)switch(c.prev=c.next){case 0:n=true;i=false;a=undefined;c.prev=3;u=r._reverseEdges.get(e)[Symbol.iterator]();case 5:if(n=(s=u.next()).done){c.next=15;break}o=s.value;if(!(r.hasEdge(o,e)&&!t.has(o))){c.next=12;break}t.add(o);c.next=11;return[o,r._vertices.get(o)];case 11:return c.delegateYield(r._verticesWithPathTo(o,t),"t7",12);case 12:n=true;c.next=5;break;case 15:c.next=21;break;case 17:c.prev=17;c.t8=c["catch"](3);i=true;a=c.t8;case 21:c.prev=21;c.prev=22;if(!n&&u["return"]){u["return"]()}case 24:c.prev=24;if(!i){c.next=27;break}throw a;case 27:return c.finish(24);case 28:return c.finish(21);case 29:case"end":return c.stop()}},R,this,[[3,17,21,29],[22,,24,28]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function M(){var t=this;var r=regeneratorRuntime.mark(function d(t){var r,s,o,f,c,l,h,v,g;return regeneratorRuntime.wrap(function p(y){while(1)switch(y.prev=y.next){case 0:i.push(t);r=i.indexOf(t);if(!(r!==i.length-1)){y.next=5;break}s=i.slice(r+1).reverse();throw new e.CycleError(s);case 5:if(a.has(t)){y.next=36;break}o=true;f=false;c=undefined;y.prev=9;l=u.verticesTo(t)[Symbol.iterator]();case 11:if(o=(h=l.next()).done){y.next=18;break}v=n(h.value,1);g=v[0];return y.delegateYield(d(g),"t9",15);case 15:o=true;y.next=11;break;case 18:y.next=24;break;case 20:y.prev=20;y.t10=y["catch"](9);f=true;c=y.t10;case 24:y.prev=24;y.prev=25;if(!o&&l["return"]){l["return"]()}case 27:y.prev=27;if(!f){y.next=30;break}throw c;case 30:return y.finish(27);case 31:return y.finish(24);case 32:if(!u.hasVertex(t)){y.next=35;break}y.next=35;return[t,u._vertices.get(t)];case 35:a.add(t);case 36:i.pop();case 37:case"end":return y.stop()}},d,this,[[9,20,24,32],[25,,27,31]])});var i,a,u,s,o,f,c,l,h,v;return regeneratorRuntime.wrap(function g(e){while(1)switch(e.prev=e.next){case 0:i=[];a=new Set;u=t;s=true;o=false;f=undefined;e.prev=6;c=t.vertices()[Symbol.iterator]();case 8:if(s=(l=c.next()).done){e.next=16;break}h=n(l.value,1);v=h[0];if(a.has(v)){e.next=13;break}return e.delegateYield(r(v),"t11",13);case 13:s=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t12=e["catch"](6);o=true;f=e.t12;case 22:e.prev=22;e.prev=23;if(!s&&c["return"]){c["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw f;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},M,this,[[6,18,22,30],[23,,25,29]])})},{key:"clearEdges",value:function A(){var e=true;var t=false;var r=undefined;try{for(var i=this.edges()[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var u=n(a.value,2);var s=u[0];var o=u[1];this.removeEdge(s,o)}}catch(f){t=true;r=f}finally{try{if(!e&&i["return"]){i["return"]()}}finally{if(t){throw r}}}}},{key:"clear",value:function W(){var e=true;var t=false;var r=undefined;try{for(var i=this.vertices()[Symbol.iterator](),a;!(e=(a=i.next()).done);e=true){var u=n(a.value,1);var s=u[0];this.destroyVertex(s)}}catch(o){t=true;r=o}finally{try{if(!e&&i["return"]){i["return"]()}}finally{if(t){throw r}}}}},{key:"equals",value:function z(){var t=arguments[0]===undefined?undefined:arguments[0];var r=arguments[1]===undefined?function(e,t,r,n){return e===t}:arguments[1];if(!(t instanceof e)){return false}if(this.vertexCount()!==t.vertexCount()){return false}if(this.edgeCount()!==t.edgeCount()){return false}var i=true;var a=false;var u=undefined;try{for(var s=this.vertices()[Symbol.iterator](),o;!(i=(o=s.next()).done);i=true){var f=n(o.value,2);var c=f[0];var l=f[1];if(!t.hasVertex(c)){return false}if(!r(l,t.vertexValue(c),c)){return false}}}catch(h){a=true;u=h}finally{try{if(!i&&s["return"]){s["return"]()}}finally{if(a){throw u}}}var v=true;var d=false;var g=undefined;try{for(var p=this.edges()[Symbol.iterator](),y;!(v=(y=p.next()).done);v=true){var x=n(y.value,3);var w=x[0];var m=x[1];var l=x[2];if(!t.hasEdge(w,m)){return false}if(!r(l,t.edgeValue(w,m),w,m)){return false}}}catch(h){d=true;g=h}finally{try{if(!v&&p["return"]){p["return"]()}}finally{if(d){throw g}}}return true}},{key:"hasCycle",value:function G(){var e=this;var t=new Set;var r=new Set;var i=function(a){if(t.has(a)){return true}if(r.has(a)){return false}r.add(a);t.add(a);var u=true;var s=false;var o=undefined;try{for(var f=e.verticesFrom(a)[Symbol.iterator](),c;!(u=(c=f.next()).done);u=true){var l=n(c.value,1);var h=l[0];if(i(h)){return true}}}catch(v){s=true;o=v}finally{try{if(!u&&f["return"]){f["return"]()}}finally{if(s){throw o}}}t["delete"](a)};var a=true;var u=false;var s=undefined;try{for(var o=this.vertices()[Symbol.iterator](),f;!(a=(f=o.next()).done);a=true){var c=n(f.value,1);var l=c[0];if(i(l)){return true}}}catch(h){u=true;s=h}finally{try{if(!a&&o["return"]){o["return"]()}}finally{if(u){throw s}}}return false}},{key:"hasPath",value:function Y(e,t){var r=this;if(!this.hasVertex(e)||!this.hasVertex(t)){return false}var i=new Set;var a=function(e){if(r.hasEdge(e,t)){return true}i.add(e);var u=true;var s=false;var o=undefined;try{for(var f=r.verticesFrom(e)[Symbol.iterator](),c;!(u=(c=f.next()).done);u=true){var l=n(c.value,1);var h=l[0];if(!i.has(h)&&a(h)){return true}}}catch(v){s=true;o=v}finally{try{if(!u&&f["return"]){f["return"]()}}finally{if(s){throw o}}}i["delete"](e);return false};return a(e)}},{key:"clone",value:function D(){var t=arguments[0]===undefined?function(e){return e}:arguments[0];var r=new e;var i=true;var a=false;var u=undefined;try{for(var s=this.vertices()[Symbol.iterator](),o;!(i=(o=s.next()).done);i=true){var f=n(o.value,2);var c=f[0];var l=f[1];r.addVertex(c,t(l,c))}}catch(h){a=true;u=h}finally{try{if(!i&&s["return"]){s["return"]()}}finally{if(a){throw u}}}var v=true;var d=false;var g=undefined;try{for(var p=this.edges()[Symbol.iterator](),y;!(v=(y=p.next()).done);v=true){var x=n(y.value,3);var w=x[0];var m=x[1];var l=x[2];r.addEdge(w,m,t(l,w,m))}}catch(h){d=true;g=h}finally{try{if(!v&&p["return"]){p["return"]()}}finally{if(d){throw g}}}return r}},{key:"transitiveReduction",value:function J(){var e=arguments[0]===undefined?function(e){return e}:arguments[0];var t=this.clone(e);var r=true;var i=false;var a=undefined;try{for(var u=this.vertices()[Symbol.iterator](),s;!(r=(s=u.next()).done);r=true){var o=n(s.value,1);var f=o[0];var c=true;var l=false;var h=undefined;try{for(var v=this.vertices()[Symbol.iterator](),d;!(c=(d=v.next()).done);c=true){var g=n(d.value,1);var p=g[0];if(t.hasEdge(f,p)){var y=true;var x=false;var w=undefined;try{for(var m=this.vertices()[Symbol.iterator](),E;!(y=(E=m.next()).done);y=true){var b=n(E.value,1);var k=b[0];if(t.hasPath(p,k)){t.removeEdge(f,k)}}}catch(_){x=true;w=_}finally{try{if(!y&&m["return"]){m["return"]()}}finally{if(x){throw w}}}}}}catch(_){l=true;h=_}finally{try{if(!c&&v["return"]){v["return"]()}}finally{if(l){throw h}}}}}catch(_){i=true;a=_}finally{try{if(!r&&u["return"]){u["return"]()}}finally{if(i){throw a}}}return t}}]);return e}();e.exports=f;f.VertexExistsError=function(e){function t(e,r){o(this,t);this.vertices=new Set;this.v(e,r)}u(t,e);a(t,{v:{value:function r(e,t){this.vertices.add({key:e,value:t});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices.size===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+[].concat(i(this.vertices)).map(function(e){return e.key}).join("', '")+"'"}}});return t}(Error);f.VertexNotExistsError=function(e){function t(e){o(this,t);this.vertices=new Set;this.v(e)}u(t,e);a(t,{v:{value:function r(e){this.vertices.add({key:e});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices.size===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+[].concat(i(this.vertices)).map(function(e){return e.key}).join("', '")+"'"}}});return t}(Error);f.EdgeExistsError=function(e){function t(e,r,n){o(this,t);this.edges=new Set;this.e(e,r,n)}u(t,e);a(t,{e:{value:function r(e,t,n){this.edges.add({from:e,to:t,value:n});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=[];var t=true;var r=false;var n=undefined;try{for(var i=this.edges[Symbol.iterator](),a;!(t=(a=i.next()).done);t=true){var u=a.value;var s=u.from;var o=u.to;e.push("('"+s+"', '"+o+"')")}}catch(f){r=true;n=f}finally{try{if(!t&&i["return"]){i["return"]()}}finally{if(r){throw n}}}var c=e.length===1?"an edge":"edges";this.message="This graph has "+c+" "+e.join(", ")}}});return t}(Error);f.EdgeNotExistsError=function(e){function t(e,r){o(this,t);this.edges=new Set;this.e(e,r)}u(t,e);a(t,{e:{value:function r(e,t){this.edges.add({from:e,to:t});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=[];var t=true;var r=false;var n=undefined;try{for(var i=this.edges[Symbol.iterator](),a;!(t=(a=i.next()).done);t=true){var u=a.value;var s=u.from;var o=u.to;e.push("('"+s+"', '"+o+"')")}}catch(f){r=true;n=f}finally{try{if(!t&&i["return"]){i["return"]()}}finally{if(r){throw n}}}var c=e.length===1?"an edge":"edges";this.message="This graph does not have "+c+" "+e.join(", ")}}});return t}(Error);f.HasConnectedEdgesError=function(e){function t(e){o(this,t);this.key=e;this.message="The '"+e+"' vertex has connected edges"}u(t,e);return t}(Error);f.CycleError=function(e){function t(e){o(this,t);this.cycle=e;this.message="This graph contains a cycle: "+e}u(t,e);return t}(Error)},function(e,t,r){(function(e){"use strict";if(e._babelPolyfill){throw new Error("only one instance of babel/polyfill is allowed")}e._babelPolyfill=true;r(4);r(5)}).call(t,function(){return this}())},function(e,t,r){!function(t,r,n){"use strict";var i="Object",a="Function",u="Array",s="String",o="Number",f="RegExp",c="Date",l="Map",h="Set",v="WeakMap",d="WeakSet",g="Symbol",p="Promise",y="Math",x="Arguments",w="prototype",m="constructor",E="toString",b=E+"Tag",k="toLocaleString",_="hasOwnProperty",S="forEach",V="iterator",N="@@"+V,P="process",O="createElement",L=t[a],j=t[i],C=t[u],I=t[s],F=t[o],T=t[f],R=t[c],M=t[l],A=t[h],W=t[v],z=t[d],G=t[g],Y=t[y],D=t.TypeError,J=t.RangeError,$=t.setTimeout,U=t.setImmediate,q=t.clearImmediate,H=t.parseInt,X=t.isFinite,K=t[P],B=K&&K.nextTick,Q=t.document,Z=Q&&Q.documentElement,ee=t.navigator,te=t.define,re=t.console||{},ne=C[w],ie=j[w],ae=L[w],ue=1/0,se=".";function oe(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function fe(e){return typeof e=="function"}var ce=we(/./.test,/\[native code\]\s*\}\s*$/,1);var le=ie[E];function he(e,t,r){if(e&&!je(e=r?e:e[w],Ct))Vt(e,Ct,t)}function ve(e){return le.call(e).slice(8,-1)}function de(e){var t,r;return e==n?e===n?"Undefined":"Null":typeof(r=(t=j(e))[Ct])=="string"?r:ve(t)}var ge=ae.call,pe=ae.apply,ye;function xe(){var e=pt(this),t=arguments.length,r=C(t),n=0,i=At._,a=false;while(t>n)if((r[n]=arguments[n++])===i)a=true;return function(){var n=this,u=arguments.length,s=0,o=0,f;if(!a&&!u)return me(e,r,n);f=r.slice();if(a)for(;t>s;s++)if(f[s]===i)f[s]=arguments[o++];while(u>o)f.push(arguments[o++]);return me(e,f,n)}}function we(e,t,r){pt(e);if(~r&&t===n)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}function me(e,t,r){var i=r===n;switch(t.length|0){case 0:return i?e():e.call(r);case 1:return i?e(t[0]):e.call(r,t[0]);case 2:return i?e(t[0],t[1]):e.call(r,t[0],t[1]);case 3:return i?e(t[0],t[1],t[2]):e.call(r,t[0],t[1],t[2]);case 4:return i?e(t[0],t[1],t[2],t[3]):e.call(r,t[0],t[1],t[2],t[3]);case 5:return i?e(t[0],t[1],t[2],t[3],t[4]):e.call(r,t[0],t[1],t[2],t[3],t[4])}return e.apply(r,t)}var Ee=j.create,be=j.getPrototypeOf,ke=j.setPrototypeOf,_e=j.defineProperty,Se=j.defineProperties,Ve=j.getOwnPropertyDescriptor,Ne=j.keys,Pe=j.getOwnPropertyNames,Oe=j.getOwnPropertySymbols,Le=j.isFrozen,je=we(ge,ie[_],2),Ce=j,Ie;function Fe(e){return Ce(gt(e))}function Te(e){return e}function Re(){return this}function Me(e,t){if(je(e,t))return e[t]}function Ae(e){yt(e);return Oe?Pe(e).concat(Oe(e)):Pe(e)}var We=j.assign||function(e,t){var r=j(gt(e)),n=arguments.length,i=1;while(n>i){var a=Ce(arguments[i++]),u=Ne(a),s=u.length,o=0,f;while(s>o)r[f=u[o++]]=a[f]}return r};function ze(e,t){var r=Fe(e),n=Ne(r),i=n.length,a=0,u;while(i>a)if(r[u=n[a++]]===t)return u}function Ge(e){return I(e).split(",")}var Ye=ne.push,De=ne.unshift,Je=ne.slice,$e=ne.splice,Ue=ne.indexOf,qe=ne[S];function He(e){var t=e==1,r=e==2,i=e==3,a=e==4,u=e==6,s=e==5||u;return function(o){var f=j(gt(this)),c=arguments[1],l=Ce(f),h=we(o,c,3),v=ot(l.length),d=0,g=t?C(v):r?[]:n,p,y;for(;v>d;d++)if(s||d in l){p=l[d];y=h(p,d,f);if(e){if(t)g[d]=y;else if(y)switch(e){case 3:return true;case 5:return p;case 6:return d;case 2:g.push(p)}else if(a)return false}}return u?-1:i||a?a:g}}function Xe(e){return function(t){var r=Fe(this),n=ot(r.length),i=ft(arguments[1],n);if(e&&t!=t){for(;n>i;i++)if(ut(r[i]))return e||i}else for(;n>i;i++)if(e||i in r){if(r[i]===t)return e||i}return!e&&-1}}function Ke(e,t){return typeof e=="function"?e:t}var Be=9007199254740991,Qe=Y.pow,Ze=Y.abs,et=Y.ceil,tt=Y.floor,rt=Y.max,nt=Y.min,it=Y.random,at=Y.trunc||function(e){return(e>0?tt:et)(e)};function ut(e){return e!=e}function st(e){return isNaN(e)?0:at(e)}function ot(e){return e>0?nt(st(e),Be):0}function ft(e,t){var e=st(e);return e<0?rt(e+t,0):nt(e,t)}function ct(e){return e>9?e:"0"+e}function lt(e,t,r){var n=oe(t)?function(e){return t[e]}:t;return function(t){return I(r?t:this).replace(e,n)}}function ht(e){return function(t){var r=I(gt(this)),i=st(t),a=r.length,u,s;if(i<0||i>=a)return e?"":n;u=r.charCodeAt(i);return u<55296||u>56319||i+1===a||(s=r.charCodeAt(i+1))<56320||s>57343?e?r.charAt(i):u:e?r.slice(i,i+2):(u-55296<<10)+(s-56320)+65536}}var vt="Reduce of empty object with no initial value";function dt(e,t,r){if(!e)throw D(r?t+r:t)}function gt(e){if(e==n)throw D("Function called on null or undefined");return e}function pt(e){dt(fe(e),e," is not a function!");return e}function yt(e){dt(oe(e),e," is not an object!");return e}function xt(e,t,r){dt(e instanceof t,r,": use the 'new' operator!")}function wt(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}function mt(e,t,r){e[t]=r;return e}function Et(e){return _t?function(t,r,n){return _e(t,r,wt(e,n))}:mt}function bt(e){return g+"("+e+")_"+(++St+it())[E](36)}function kt(e,t){return G&&G[e]||(t?G:Pt)(g+se+e)}var _t=!!function(){try{return _e({},"a",{get:function(){return 2}}).a==2}catch(e){}}(),St=0,Vt=Et(1),Nt=G?mt:Vt,Pt=G||bt;function Ot(e,t){for(var r in t)Vt(e,r,t[r]);return e}var Lt=kt("unscopables"),jt=ne[Lt]||{},Ct=kt(b),It=kt("species"),Ft;function Tt(e){if(_t&&(r||!ce(e)))_e(e,It,{configurable:true,get:Re})}var Rt=ve(K)==P,Mt={},At=r?t:Mt,Wt=t.core,zt,Gt=1,Yt=2,Dt=4,Jt=8,$t=16,Ut=32;function qt(e,n,i){var a,u,s,o,f=e&Yt,c=f?t:e&Dt?t[n]:(t[n]||ie)[w],l=f?Mt:Mt[n]||(Mt[n]={});if(f)i=n;for(a in i){u=!(e&Gt)&&c&&a in c&&(!fe(c[a])||ce(c[a]));s=(u?c:i)[a];if(!r&&f&&!fe(c[a]))o=i[a];else if(e&$t&&u)o=we(s,t);else if(e&Ut&&!r&&c[a]==s){o=function(e){return this instanceof s?new s(e):s(e)};o[w]=s[w]}else o=e&Jt&&fe(s)?we(ge,s):s;if(r&&c&&!u){if(f)c[a]=s;else delete c[a]&&Vt(c,a,s)}if(l[a]!=s)Vt(l,a,o)}}if(typeof e!="undefined"&&e.exports)e.exports=Mt;else if(fe(te)&&te.amd)te(function(){return Mt});else zt=true;if(zt||r){Mt.noConflict=function(){t.core=Wt;return Mt};t.core=Mt}Ft=kt(V);var Ht=Pt("iter"),Xt=1,Kt=2,Bt={},Qt={},Zt="keys"in ne&&!("next"in[].keys());er(Qt,Re);function er(e,t){Vt(e,Ft,t);N in ne&&Vt(e,N,t)}function tr(e,t,r,n){e[w]=Ee(n||Qt,{next:wt(1,r)});he(e,t+" Iterator")}function rr(e,t,n,i){var a=e[w],u=Me(a,Ft)||Me(a,N)||i&&Me(a,i)||n;if(r){er(a,u);if(u!==n){var s=be(u.call(new e));he(s,t+" Iterator",true);je(a,N)&&er(s,Re)}}Bt[t]=u;Bt[t+" Iterator"]=Re;return u}function nr(e,t,r,n,i,a){function u(e){return function(){return new r(this,e)}}tr(r,t,n);var s=u(Xt+Kt),o=u(Kt);if(i==Kt)o=rr(e,t,o,"values");else s=rr(e,t,s,"entries");if(i){qt(Jt+Gt*Zt,t,{entries:s,keys:a?o:u(Xt),values:o})}}function ir(e,t){return{value:t,done:!!e}}function ar(e){var r=j(e),n=t[g],i=(n&&n[V]||N)in r;return i||Ft in r||je(Bt,de(r))}function ur(e){var r=t[g],n=e[r&&r[V]||N],i=n||e[Ft]||Bt[de(e)];return yt(i.call(e))}function sr(e,t,r){return r?me(e,t):e(t)}function or(e){var t=true;var r={next:function(){throw 1},"return":function(){t=false}};r[Ft]=Re;try{e(r)}catch(n){}return t}function fr(e){var t=e["return"];if(t!==n)t.call(e)}function cr(e,t){try{e(t)}catch(r){fr(t);throw r}}function lr(e,t,r,n){cr(function(e){var i=we(r,n,t?2:1),a;while(!(a=e.next()).done)if(sr(i,a.value,t)===false){return fr(e)}},ur(e))}!function(e,r,n,a){if(!ce(G)){G=function(t){dt(!(this instanceof G),g+" is not a "+m);var r=bt(t),i=Nt(Ee(G[w]),e,r);n[r]=i;_t&&a&&_e(ie,r,{configurable:true,set:function(e){Vt(this,r,e)}});return i};Vt(G[w],E,function(){return this[e]})}qt(Yt+Ut,{Symbol:G});var u={"for":function(e){return je(r,e+="")?r[e]:r[e]=G(e)},iterator:Ft||kt(V),keyFor:xe.call(ze,r),species:It,toStringTag:Ct=kt(b,true),unscopables:Lt,pure:Pt,set:Nt,useSetter:function(){a=true},useSimple:function(){a=false}};qe.call(Ge("hasInstance,isConcatSpreadable,match,replace,search,split,toPrimitive"),function(e){u[e]=kt(e)});qt(Dt,g,u);he(G,g);qt(Dt+Gt*!ce(G),i,{getOwnPropertyNames:function(e){var t=Pe(Fe(e)),r=[],i,a=0;while(t.length>a)je(n,i=t[a++])||r.push(i);return r},getOwnPropertySymbols:function(e){var t=Pe(Fe(e)),r=[],i,a=0;while(t.length>a)je(n,i=t[a++])&&r.push(n[i]);return r}});he(Y,y,true);he(t.JSON,"JSON",true)}(Pt("tag"),{},{},true);!function(){var e={assign:We,is:function(e,t){return e===t?e!==0||1/e===1/t:e!=e&&t!=t}};"__proto__"in ie&&function(t,r){try{r=we(ge,Ve(ie,"__proto__").set,2);r({},ne)}catch(n){t=true}e.setPrototypeOf=ke=ke||function(e,n){yt(e);dt(n===null||oe(n),n,": can't set as prototype!");if(t)e.__proto__=n;else r(e,n);return e}}();qt(Dt,i,e)}();!function(e){e[Ct]=se;if(ve(e)!=se)Vt(ie,E,function(){return"[object "+de(this)+"]"})}({});!function(){function e(e,t){var r=j[e],n=Mt[i][e],a=0,u={};if(!n||ce(n)){u[e]=t==1?function(e){return oe(e)?r(e):e}:t==2?function(e){return oe(e)?r(e):true}:t==3?function(e){return oe(e)?r(e):false}:t==4?function(e,t){return r(Fe(e),t)}:function(e){return r(Fe(e))};try{r(se)}catch(s){a=1}qt(Dt+Gt*a,i,u)}}e("freeze",1);e("seal",1);e("preventExtensions",1);e("isFrozen",2);e("isSealed",2);e("isExtensible",3);e("getOwnPropertyDescriptor",4);e("getPrototypeOf");e("keys");e("getOwnPropertyNames")}();!function(e){e in ae||_t&&_e(ae,e,{configurable:true,get:function(){var t=I(this).match(/^\s*function ([^ (]*)/),r=t?t[1]:"";je(this,e)||_e(this,e,wt(5,r));return r},set:function(t){je(this,e)||_e(this,e,wt(0,t))}})}("name");F("0o1")&&F("0b1")||function(e,r){function n(e){if(oe(e))e=i(e);if(typeof e=="string"&&e.length>2&&e.charCodeAt(0)==48){var t=false;switch(e.charCodeAt(1)){case 66:case 98:t=true;case 79:case 111:return H(e.slice(2),t?2:8)}}return+e}function i(e){var t,r;if(fe(t=e.valueOf)&&!oe(r=t.call(e)))return r;if(fe(t=e[E])&&!oe(r=t.call(e)))return r;throw D("Can't convert object to number")}F=function a(t){return this instanceof a?new e(n(t)):n(t)};qe.call(_t?Pe(e):Ge("MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY"),function(t){t in F||_e(F,t,Ve(e,t))});F[w]=r;r[m]=F;Vt(t,o,F)}(F,F[w]);!function(e){qt(Dt,o,{EPSILON:Qe(2,-52),isFinite:function(e){return typeof e=="number"&&X(e)},isInteger:e,isNaN:ut,isSafeInteger:function(t){return e(t)&&Ze(t)<=Be},MAX_SAFE_INTEGER:Be,MIN_SAFE_INTEGER:-Be,parseFloat:parseFloat,parseInt:H})}(F.isInteger||function(e){return!oe(e)&&X(e)&&tt(e)===e});!function(){var e=Y.E,t=Y.exp,r=Y.log,n=Y.sqrt,i=Y.sign||function(e){return(e=+e)==0||e!=e?e:e<0?-1:1};function a(e){return!X(e=+e)||e==0?e:e<0?-a(-e):r(e+n(e*e+1))}function u(e){return(e=+e)==0?e:e>-1e-6&&e<1e-6?e+e*e/2:t(e)-1}qt(Dt,y,{acosh:function(t){return(t=+t)<1?NaN:X(t)?r(t/e+n(t+1)*n(t-1)/e)+1:t},asinh:a,atanh:function(e){return(e=+e)==0?e:r((1+e)/(1-e))/2},cbrt:function(e){return i(e=+e)*Qe(Ze(e),1/3)},clz32:function(e){return(e>>>=0)?32-e[E](2).length:32},cosh:function(e){return(t(e=+e)+t(-e))/2},expm1:u,fround:function(e){return new Float32Array([e])[0]},hypot:function(e,t){var r=0,i=arguments.length,a=i,u=C(i),s=-ue,o;while(i--){o=u[i]=+arguments[i];if(o==ue||o==-ue)return ue;if(o>s)s=o}s=o||1;while(a--)r+=Qe(u[a]/s,2);return s*n(r)},imul:function(e,t){var r=65535,n=+e,i=+t,a=r&n,u=r&i;return 0|a*u+((r&n>>>16)*u+a*(r&i>>>16)<<16>>>0)},log1p:function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:r(1+e)},log10:function(e){return r(e)/Y.LN10},log2:function(e){return r(e)/Y.LN2},sign:i,sinh:function(r){return Ze(r=+r)<1?(u(r)-u(-r))/2:(t(r-1)-t(-r-1))*(e/2)},tanh:function(e){var r=u(e=+e),n=u(-e);return r==ue?1:n==ue?-1:(r-n)/(t(e)+t(-e))},trunc:at})}();!function(e){function t(e){if(ve(e)==f)throw D()}qt(Dt,s,{fromCodePoint:function(t){var r=[],n=arguments.length,i=0,a;while(n>i){a=+arguments[i++];if(ft(a,1114111)!==a)throw J(a+" is not a valid code point");r.push(a<65536?e(a):e(((a-=65536)>>10)+55296,a%1024+56320))}return r.join("")},raw:function(e){var t=Fe(e.raw),r=ot(t.length),n=arguments.length,i=[],a=0;while(r>a){i.push(I(t[a++]));if(a<n)i.push(I(arguments[a]))}return i.join(""); | ||
});!function(){var e=Y.E,t=Y.exp,r=Y.log,n=Y.sqrt,i=Y.sign||function(e){return(e=+e)==0||e!=e?e:e<0?-1:1};function a(e){return!X(e=+e)||e==0?e:e<0?-a(-e):r(e+n(e*e+1))}function u(e){return(e=+e)==0?e:e>-1e-6&&e<1e-6?e+e*e/2:t(e)-1}Ht(Dt,y,{acosh:function(t){return(t=+t)<1?NaN:X(t)?r(t/e+n(t+1)*n(t-1)/e)+1:t},asinh:a,atanh:function(e){return(e=+e)==0?e:r((1+e)/(1-e))/2},cbrt:function(e){return i(e=+e)*Qe(Ze(e),1/3)},clz32:function(e){return(e>>>=0)?32-e[E](2).length:32},cosh:function(e){return(t(e=+e)+t(-e))/2},expm1:u,fround:function(e){return new Float32Array([e])[0]},hypot:function(e,t){var r=0,i=arguments.length,a=i,u=L(i),s=-ue,o;while(i--){o=u[i]=+arguments[i];if(o==ue||o==-ue)return ue;if(o>s)s=o}s=o||1;while(a--)r+=Qe(u[a]/s,2);return s*n(r)},imul:function(e,t){var r=65535,n=+e,i=+t,a=r&n,u=r&i;return 0|a*u+((r&n>>>16)*u+a*(r&i>>>16)<<16>>>0)},log1p:function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:r(1+e)},log10:function(e){return r(e)/Y.LN10},log2:function(e){return r(e)/Y.LN2},sign:i,sinh:function(r){return Ze(r=+r)<1?(u(r)-u(-r))/2:(t(r-1)-t(-r-1))*(e/2)},tanh:function(e){var r=u(e=+e),n=u(-e);return r==ue?1:n==ue?-1:(r-n)/(t(e)+t(-e))},trunc:at})}();!function(e){function t(e){if(ve(e)==f)throw D()}Ht(Dt,s,{fromCodePoint:function(t){var r=[],n=arguments.length,i=0,a;while(n>i){a=+arguments[i++];if(ft(a,1114111)!==a)throw J(a+" is not a valid code point");r.push(a<65536?e(a):e(((a-=65536)>>10)+55296,a%1024+56320))}return r.join("")},raw:function(e){var t=Te(e.raw),r=ot(t.length),n=arguments.length,i=[],a=0;while(r>a){i.push(F(t[a++]));if(a<n)i.push(F(arguments[a]))}return i.join("")}});Ht(Jt,s,{codePointAt:ht(false),endsWith:function(e){t(e);var r=F(gt(this)),i=arguments[1],a=ot(r.length),u=i===n?a:nt(ot(i),a);e+="";return r.slice(u-e.length,u)===e},includes:function(e){t(e);return!!~F(gt(this)).indexOf(e,arguments[1])},repeat:function(e){var t=F(gt(this)),r="",n=st(e);if(0>n||n==ue)throw J("Count can't be negative");for(;n>0;(n>>>=1)&&(t+=t))if(n&1)r+=t;return r},startsWith:function(e){t(e);var r=F(gt(this)),n=ot(nt(arguments[1],r.length));e+="";return r.slice(n,n+e.length)===e}})}(F.fromCharCode);!function(){Ht(Dt+zt*or(L.from),u,{from:function(e){var t=j(gt(e)),r=arguments[1],i=r!==n,a=i?we(r,arguments[2],2):n,u=0,s,o,f;if(ar(t)){o=new(Ke(this,L));cr(function(e){for(;!(f=e.next()).done;u++){o[u]=i?a(f.value,u):f.value}},ur(t))}else{o=new(Ke(this,L))(s=ot(t.length));for(;s>u;u++){o[u]=i?a(t[u],u):t[u]}}o.length=u;return o}});Ht(Dt,u,{of:function(){var e=0,t=arguments.length,r=new(Ke(this,L))(t);while(t>e)r[e]=arguments[e++];r.length=t;return r}});It(L)}();!function(){Ht(Jt,u,{copyWithin:function(e,t){var r=j(gt(this)),i=ot(r.length),a=ft(e,i),u=ft(t,i),s=arguments[2],o=s===n?i:ft(s,i),f=nt(o-u,i-a),c=1;if(u<a&&a<u+f){c=-1;u=u+f-1;a=a+f-1}while(f-->0){if(u in r)r[a]=r[u];else delete r[a];a+=c;u+=c}return r},fill:function(e){var t=j(gt(this)),r=ot(t.length),i=ft(arguments[1],r),a=arguments[2],u=a===n?r:ft(a,r);while(u>i)t[i++]=e;return t},find:qe(5),findIndex:qe(6)});if(r){He.call(ze("find,findIndex,fill,copyWithin,entries,keys,values"),function(e){jt[e]=true});Ot in ne||St(ne,Ot,jt)}}();!function(e){nr(L,u,function(e,t){Nt(this,qt,{o:Te(e),i:0,k:t})},function(){var e=this[qt],t=e.o,r=e.k,i=e.i++;if(!t||i>=t.length){e.o=n;return ir(1)}if(r==Xt)return ir(0,i);if(r==Kt)return ir(0,t[i]);return ir(0,[i,t[i]])},Kt);Bt[x]=Bt[u];nr(F,s,function(e){Nt(this,qt,{o:F(e),i:0})},function(){var t=this[qt],r=t.o,n=t.i,i;if(n>=r.length)return ir(1);i=e.call(r,n);t.i+=i.length;return ir(0,i)})}(ht(true));_t&&!function(e,r){if(!function(){try{return I(/a/g,"i")=="/a/i"}catch(e){}}()){I=function i(e,t){return new r(ve(e)==f&&t!==n?e.source:e,t)};He.call(Pe(r),function(e){e in I||_e(I,e,{configurable:true,get:function(){return r[e]},set:function(t){r[e]=t}})});e[m]=I;I[w]=e;St(t,f,I)}if(/./g.flags!="g")_e(e,"flags",{configurable:true,get:lt(/^.*\/(\w*)$/,"$1")});It(I)}(I[w],I);fe(U)&&fe(H)||function(e){var r=t.postMessage,n=t.addEventListener,i=t.MessageChannel,a=0,u={},s,o,f;U=function(e){var t=[],r=1;while(arguments.length>r)t.push(arguments[r++]);u[++a]=function(){me(fe(e)?e:O(e),t)};s(a);return a};H=function(e){delete u[e]};function c(e){if(je(u,e)){var t=u[e];delete u[e];t()}}function l(e){c(e.data)}if(Rt){s=function(e){B(xe.call(c,e))}}else if(n&&fe(r)&&!t.importScripts){s=function(e){r(e,"*")};n("message",l,false)}else if(fe(i)){o=new i;f=o.port2;o.port1.onmessage=l;s=we(f.postMessage,f,1)}else if(Q&&e in Q[C]("script")){s=function(t){Z.appendChild(Q[C]("script"))[e]=function(){Z.removeChild(this);c(t)}}}else{s=function(e){$(c,0,e)}}}("onreadystatechange");Ht(Yt+$t,{setImmediate:U,clearImmediate:H});!function(e,t){fe(e)&&fe(e.resolve)&&e.resolve(t=new e(function(){}))==t||function(t,r){function i(e){var t;if(oe(e))t=e.then;return fe(t)?t:false}function a(e){var t=e[r],n=t.c,i=0,u;if(t.h)return true;while(n.length>i){u=n[i++];if(u.fail||a(u.P))return true}}function u(e,r){var n=e.c;if(r||n.length)t(function(){var t=e.p,u=e.v,s=e.s==1,o=0;if(r&&!a(t)){$(function(){if(!a(t)){if(Rt){if(!K.emit("unhandledRejection",u,t)){}}else if(fe(re.error)){re.error("Unhandled promise rejection",u)}}},1e3)}else while(n.length>o)!function(t){var r=s?t.ok:t.fail,n,a;try{if(r){if(!s)e.h=true;n=r===true?u:r(u);if(n===t.P){t.rej(D(p+"-chain cycle"))}else if(a=i(n)){a.call(n,t.res,t.rej)}else t.res(n)}else t.rej(u)}catch(o){t.rej(o)}}(n[o++]);n.length=0})}function s(e){var t=this,r,n;if(t.d)return;t.d=true;t=t.r||t;try{if(r=i(e)){n={r:t,d:false};r.call(e,we(s,n,1),we(o,n,1))}else{t.v=e;t.s=1;u(t)}}catch(a){o.call(n||{r:t,d:false},a)}}function o(e){var t=this;if(t.d)return;t.d=true;t=t.r||t;t.v=e;t.s=2;u(t,true)}function f(e){var t=yt(e)[Ft];return t!=n?t:e}e=function(t){pt(t);xt(this,e,p);var i={p:this,c:[],s:0,d:false,v:n,h:false};St(this,r,i);try{t(we(s,i,1),we(o,i,1))}catch(a){o.call(i,a)}};Ct(e[w],{then:function(t,i){var a=yt(yt(this)[m])[Ft];var s={ok:fe(t)?t:true,fail:fe(i)?i:false},o=s.P=new(a!=n?a:e)(function(e,t){s.res=pt(e);s.rej=pt(t)}),f=this[r];f.c.push(s);f.s&&u(f);return o},"catch":function(e){return this.then(n,e)}});Ct(e,{all:function(e){var t=f(this),r=[];return new t(function(n,i){lr(e,false,Ye,r);var a=r.length,u=L(a);if(a)He.call(r,function(e,r){t.resolve(e).then(function(e){u[r]=e;--a||n(u)},i)});else n(u)})},race:function(e){var t=f(this);return new t(function(r,n){lr(e,false,function(e){t.resolve(e).then(r,n)})})},reject:function(e){return new(f(this))(function(t,r){r(e)})},resolve:function(e){return oe(e)&&r in e&&be(e)===this[w]?e:new(f(this))(function(t,r){t(e)})}})}(B||U,Pt("record"));he(e,p);It(e);Ht(Yt+zt*!ce(e),{Promise:e})}(t[p]);!function(){var e=Pt("uid"),t=Pt("O1"),i=Pt("weak"),a=Pt("leak"),u=Pt("last"),s=Pt("first"),o=_t?Pt("size"):"size",f=0,c={};function g(i,a,c,l,h,v){var d=h?"set":"add",g=i&&i[w],p={};function y(e,t){if(t!=n)lr(t,h,e[d],e);return e}function x(e,t){var n=g[e];if(r)g[e]=function(e,r){var i=n.call(this,e===0?0:e,r);return t?this:i}}if(!ce(i)||!(v||!Zt&&je(g,V)&&je(g,"entries"))){i=v?function(t){xt(this,i,a);Nt(this,e,f++);y(this,t)}:function(e){var r=this;xt(r,i,a);Nt(r,t,Ee(null));Nt(r,o,0);Nt(r,u,n);Nt(r,s,n);y(r,e)};Ct(Ct(i[w],c),l);v||!_t||_e(i[w],"size",{get:function(){return gt(this[o])}})}else{var E=i,b=new i,k=b[d](v?{}:-0,1),_;if(or(function(e){new i(e)})){i=function(e){xt(this,i,a);return y(new E,e)};i[w]=g;if(r)g[m]=i}v||b[V](function(e,t){_=1/t===-ue});if(_){x("delete");x("has");h&&x("get")}if(_||k!==b)x(d,true)}he(i,a);It(i);p[a]=i;Ht(Yt+Ut+zt*!ce(i),p);v||nr(i,a,function(e,t){Nt(this,qt,{o:e,k:t})},function(){var e=this[qt],t=e.k,r=e.l;while(r&&r.r)r=r.p;if(!e.o||!(e.l=r=r?r.n:e.o[s])){e.o=n;return ir(1)}if(t==Xt)return ir(0,r.k);if(t==Kt)return ir(0,r.v);return ir(0,[r.k,r.v])},h?Xt+Kt:Kt,!h);return i}function p(t,r){if(!oe(t))return(typeof t=="string"?"S":"P")+t;if(Oe(t))return"F";if(!je(t,e)){if(!r)return"E";St(t,e,++f)}return"O"+t[e]}function y(e,r){var n=p(r),i;if(n!="F")return e[t][n];for(i=e[s];i;i=i.n){if(i.k==r)return i}}function x(e,r,i){var a=y(e,r),f,c;if(a)a.v=i;else{e[u]=a={i:c=p(r,true),k:r,v:i,p:f=e[u],n:n,r:false};if(!e[s])e[s]=a;if(f)f.n=a;e[o]++;if(c!="F")e[t][c]=a}return e}var E={clear:function(){for(var e=this,r=e[t],i=e[s];i;i=i.n){i.r=true;if(i.p)i.p=i.p.n=n;delete r[i.i]}e[s]=e[u]=n;e[o]=0},"delete":function(e){var r=this,n=y(r,e);if(n){var i=n.n,a=n.p;delete r[t][n.i];n.r=true;if(a)a.n=i;if(i)i.p=a;if(r[s]==n)r[s]=i;if(r[u]==n)r[u]=a;r[o]--}return!!n},forEach:function(e){var t=we(e,arguments[1],3),r;while(r=r?r.n:this[s]){t(r.v,r.k,this);while(r&&r.r)r=r.p}},has:function(e){return!!y(this,e)}};A=g(A,l,{get:function(e){var t=y(this,e);return t&&t.v},set:function(e,t){return x(this,e===0?0:e,t)}},E,true);M=g(M,h,{add:function(e){return x(this,e=e===0?0:e,e)}},E);function b(t,r,n){if(Oe(yt(r)))k(t).set(r,n);else{je(r,i)||St(r,i,{});r[i][t[e]]=n}return t}function k(e){return e[a]||St(e,a,new A)[a]}var _={"delete":function(t){if(!oe(t))return false;if(Oe(t))return k(this)["delete"](t);return je(t,i)&&je(t[i],this[e])&&delete t[i][this[e]]},has:function(t){if(!oe(t))return false;if(Oe(t))return k(this).has(t);return je(t,i)&&je(t[i],this[e])}};W=g(W,v,{get:function(t){if(oe(t)){if(Oe(t))return k(this).get(t);if(je(t,i))return t[i][this[e]]}},set:function(e,t){return b(this,e,t)}},_,true,true);if(r&&(new W).set(j.freeze(c),7).get(c)!=7){He.call(ze("delete,has,get,set"),function(e){var t=W[w][e];W[w][e]=function(r,n){if(oe(r)&&Oe(r)){var i=k(this)[e](r,n);return e=="set"?this:i}return t.call(this,r,n)}})}G=g(G,d,{add:function(e){return b(this,e,true)}},_,false,true)}();!function(){function e(e){var t=[],r;for(r in e)t.push(r);Nt(this,qt,{o:e,a:t,i:0})}tr(e,i,function(){var e=this[qt],t=e.a,r;do{if(e.i>=t.length)return ir(1)}while(!((r=t[e.i++])in e.o));return ir(0,r)});function t(e){return function(t){yt(t);try{return e.apply(n,arguments),true}catch(r){return false}}}function r(e,t){var i=arguments.length<3?e:arguments[2],a=Se(yt(e),t),u;if(a)return je(a,"value")?a.value:a.get===n?n:a.get.call(i);return oe(u=be(e))?r(u,t,i):n}function a(e,t,r){var i=arguments.length<4?e:arguments[3],u=Se(yt(e),t),s,o;if(!u){if(oe(o=be(e))){return a(o,t,r,i)}u=wt(0)}if(je(u,"value")){if(u.writable===false||!oe(i))return false;s=Se(i,t)||wt(0);s.value=r;return _e(i,t,s),true}return u.set===n?false:(u.set.call(i,r),true)}var u=j.isExtensible||Ie;var s={apply:we(ge,pe,3),construct:function(e,t){var r=pt(arguments.length<3?e:arguments[2])[w],n=Ee(oe(r)?r:ie),i=pe.call(e,n,t);return oe(i)?i:n},defineProperty:t(_e),deleteProperty:function(e,t){var r=Se(yt(e),t);return r&&!r.configurable?false:delete e[t]},enumerate:function(t){return new e(yt(t))},get:r,getOwnPropertyDescriptor:function(e,t){return Se(yt(e),t)},getPrototypeOf:function(e){return be(yt(e))},has:function(e,t){return t in e},isExtensible:function(e){return!!u(yt(e))},ownKeys:Me,preventExtensions:t(j.preventExtensions||Ie),set:a};if(ke)s.setPrototypeOf=function(e,t){return ke(yt(e),t),true};Ht(Yt,{Reflect:{}});Ht(Dt,"Reflect",s)}();!function(){Ht(Jt,u,{includes:Xe(true)});Ht(Jt,s,{at:ht(true)});function e(e){return function(t){var r=Te(t),n=Ne(t),i=n.length,a=0,u=L(i),s;if(e)while(i>a)u[a]=[s=n[a++],r[s]];else while(i>a)u[a]=r[n[a++]];return u}}Ht(Dt,i,{getOwnPropertyDescriptors:function(e){var t=Te(e),r={};He.call(Me(t),function(e){_e(r,e,wt(0,Se(t,e)))});return r},values:e(false),entries:e(true)});Ht(Dt,f,{escape:lt(/([\\\-[\]{}()*+?.,^$|])/g,"\\$1",true)})}();!function(e){ye=kt(e+"Get",true);var t=kt(e+h,true),r=kt(e+"Delete",true);Ht(Dt,g,{referenceGet:ye,referenceSet:t,referenceDelete:r});St(ae,ye,Re);function n(e){if(e){var n=e[w];St(n,ye,n.get);St(n,t,n.set);St(n,r,n["delete"])}}n(A);n(W)}("reference");!function(e){function t(t,r){He.call(ze(t),function(t){if(t in ne)e[t]=we(ge,ne[t],r)})}t("pop,reverse,shift,keys,values,entries",1);t("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3);t("join,slice,concat,push,splice,unshift,sort,lastIndexOf,"+"reduce,reduceRight,copyWithin,fill,turn");Ht(Dt,u,e)}({});!function(e){if(r&&e&&!(Tt in e[w])){St(e[w],Tt,Bt[u])}Bt.NodeList=Bt[u]}(t.NodeList)}(typeof self!="undefined"&&self.Math===Math?self:Function("return this")(),true)},function(e,t,r){(function(t){!function(t){"use strict";var r=Object.prototype.hasOwnProperty;var n;var i=typeof Symbol==="function"&&Symbol.iterator||"@@iterator";var a=typeof e==="object";var u=t.regeneratorRuntime;if(u){if(a){e.exports=u}return}u=t.regeneratorRuntime=a?e.exports:{};function s(e,t,r,n){return new y(e,t,r||null,n||[])}u.wrap=s;function o(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}var f="suspendedStart";var c="suspendedYield";var l="executing";var h="completed";var v={};function d(){}function g(){}var p=g.prototype=y.prototype;d.prototype=p.constructor=g;g.constructor=d;d.displayName="GeneratorFunction";u.isGeneratorFunction=function(e){var t=typeof e==="function"&&e.constructor;return t?t===d||(t.displayName||t.name)==="GeneratorFunction":false};u.mark=function(e){e.__proto__=g;e.prototype=Object.create(p);return e};u.async=function(e,t,r,n){return new Promise(function(i,a){var u=s(e,t,r,n);var f=l.bind(u.next);var c=l.bind(u["throw"]);function l(e){var t=o(this,null,e);if(t.type==="throw"){a(t.arg);return}var r=t.arg;if(r.done){i(r.value)}else{Promise.resolve(r.value).then(f,c)}}f()})};function y(e,t,r,i){var a=t?Object.create(t.prototype):this;var u=new m(i);var s=f;function d(t,i){if(s===l){throw new Error("Generator is already running")}if(s===h){return b()}while(true){var a=u.delegate;if(a){var d=o(a.iterator[t],a.iterator,i);if(d.type==="throw"){u.delegate=null;t="throw";i=d.arg;continue}t="next";i=n;var g=d.arg;if(g.done){u[a.resultName]=g.value;u.next=a.nextLoc}else{s=c;return g}u.delegate=null}if(t==="next"){if(s===f&&typeof i!=="undefined"){throw new TypeError("attempt to send "+JSON.stringify(i)+" to newborn generator")}if(s===c){u.sent=i}else{delete u.sent}}else if(t==="throw"){if(s===f){s=h;throw i}if(u.dispatchException(i)){t="next";i=n}}else if(t==="return"){u.abrupt("return",i)}s=l;var d=o(e,r,u);if(d.type==="normal"){s=u.done?h:c;var g={value:d.arg,done:u.done};if(d.arg===v){if(u.delegate&&t==="next"){i=n}}else{return g}}else if(d.type==="throw"){s=h;if(t==="next"){u.dispatchException(d.arg)}else{i=d.arg}}}}a.next=d.bind(a,"next");a["throw"]=d.bind(a,"throw");a["return"]=d.bind(a,"return");return a}p[i]=function(){return this};p.toString=function(){return"[object Generator]"};function x(e){var t={tryLoc:e[0]};if(1 in e){t.catchLoc=e[1]}if(2 in e){t.finallyLoc=e[2];t.afterLoc=e[3]}this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal";delete t.arg;e.completion=t}function m(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(x,this);this.reset()}u.keys=function(e){var t=[];for(var r in e){t.push(r)}t.reverse();return function n(){while(t.length){var r=t.pop();if(r in e){n.value=r;n.done=false;return n}}n.done=true;return n}};function E(e){if(e){var t=e[i];if(t){return t.call(e)}if(typeof e.next==="function"){return e}if(!isNaN(e.length)){var a=-1,u=function s(){while(++a<e.length){if(r.call(e,a)){s.value=e[a];s.done=false;return s}}s.value=n;s.done=true;return s};return u.next=u}}return{next:b}}u.values=E;function b(){return{value:n,done:true}}m.prototype={constructor:m,reset:function(){this.prev=0;this.next=0;this.sent=n;this.done=false;this.delegate=null;this.tryEntries.forEach(w);for(var e=0,t;r.call(this,t="t"+e)||e<20;++e){this[t]=null}},stop:function(){this.done=true;var e=this.tryEntries[0];var t=e.completion;if(t.type==="throw"){throw t.arg}return this.rval},dispatchException:function(e){if(this.done){throw e}var t=this;function n(r,n){u.type="throw";u.arg=e;t.next=r;return!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];var u=a.completion;if(a.tryLoc==="root"){return n("end")}if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc");var o=r.call(a,"finallyLoc");if(s&&o){if(this.prev<a.catchLoc){return n(a.catchLoc,true)}else if(this.prev<a.finallyLoc){return n(a.finallyLoc)}}else if(s){if(this.prev<a.catchLoc){return n(a.catchLoc,true)}}else if(o){if(this.prev<a.finallyLoc){return n(a.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}if(a&&(e==="break"||e==="continue")&&a.tryLoc<=t&&t<a.finallyLoc){a=null}var u=a?a.completion:{};u.type=e;u.arg=t;if(a){this.next=a.finallyLoc}else{this.complete(u)}return v},complete:function(e,t){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=e.arg;this.next="end"}else if(e.type==="normal"&&t){this.next=t}return v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e){return this.complete(r.completion,r.afterLoc)}}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if(n.type==="throw"){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){this.delegate={iterator:E(e),resultName:t,nextLoc:r};return v}}}(typeof t==="object"?t:typeof window==="object"?window:this)}).call(t,function(){return this}())}])}); | ||
}});qt(Jt,s,{codePointAt:ht(false),endsWith:function(e){t(e);var r=I(gt(this)),i=arguments[1],a=ot(r.length),u=i===n?a:nt(ot(i),a);e+="";return r.slice(u-e.length,u)===e},includes:function(e){t(e);return!!~I(gt(this)).indexOf(e,arguments[1])},repeat:function(e){var t=I(gt(this)),r="",n=st(e);if(0>n||n==ue)throw J("Count can't be negative");for(;n>0;(n>>>=1)&&(t+=t))if(n&1)r+=t;return r},startsWith:function(e){t(e);var r=I(gt(this)),n=ot(nt(arguments[1],r.length));e+="";return r.slice(n,n+e.length)===e}})}(I.fromCharCode);!function(){qt(Dt+Gt*or(C.from),u,{from:function(e){var t=j(gt(e)),r=arguments[1],i=r!==n,a=i?we(r,arguments[2],2):n,u=0,s,o,f;if(ar(t)){o=new(Ke(this,C));cr(function(e){for(;!(f=e.next()).done;u++){o[u]=i?a(f.value,u):f.value}},ur(t))}else{o=new(Ke(this,C))(s=ot(t.length));for(;s>u;u++){o[u]=i?a(t[u],u):t[u]}}o.length=u;return o}});qt(Dt,u,{of:function(){var e=0,t=arguments.length,r=new(Ke(this,C))(t);while(t>e)r[e]=arguments[e++];r.length=t;return r}});Tt(C)}();!function(){qt(Jt,u,{copyWithin:function(e,t){var r=j(gt(this)),i=ot(r.length),a=ft(e,i),u=ft(t,i),s=arguments[2],o=s===n?i:ft(s,i),f=nt(o-u,i-a),c=1;if(u<a&&a<u+f){c=-1;u=u+f-1;a=a+f-1}while(f-->0){if(u in r)r[a]=r[u];else delete r[a];a+=c;u+=c}return r},fill:function(e){var t=j(gt(this)),r=ot(t.length),i=ft(arguments[1],r),a=arguments[2],u=a===n?r:ft(a,r);while(u>i)t[i++]=e;return t},find:He(5),findIndex:He(6)});if(r){qe.call(Ge("find,findIndex,fill,copyWithin,entries,keys,values"),function(e){jt[e]=true});Lt in ne||Vt(ne,Lt,jt)}}();!function(e){nr(C,u,function(e,t){Nt(this,Ht,{o:Fe(e),i:0,k:t})},function(){var e=this[Ht],t=e.o,r=e.k,i=e.i++;if(!t||i>=t.length){e.o=n;return ir(1)}if(r==Xt)return ir(0,i);if(r==Kt)return ir(0,t[i]);return ir(0,[i,t[i]])},Kt);Bt[x]=Bt[u];nr(I,s,function(e){Nt(this,Ht,{o:I(e),i:0})},function(){var t=this[Ht],r=t.o,n=t.i,i;if(n>=r.length)return ir(1);i=e.call(r,n);t.i+=i.length;return ir(0,i)})}(ht(true));_t&&!function(e,r){if(!function(){try{return T(/a/g,"i")=="/a/i"}catch(e){}}()){T=function i(e,t){return new r(ve(e)==f&&t!==n?e.source:e,t)};qe.call(Pe(r),function(e){e in T||_e(T,e,{configurable:true,get:function(){return r[e]},set:function(t){r[e]=t}})});e[m]=T;T[w]=e;Vt(t,f,T)}if(/./g.flags!="g")_e(e,"flags",{configurable:true,get:lt(/^.*\/(\w*)$/,"$1")});Tt(T)}(T[w],T);fe(U)&&fe(q)||function(e){var r=t.postMessage,n=t.addEventListener,i=t.MessageChannel,a=0,u={},s,o,f;U=function(e){var t=[],r=1;while(arguments.length>r)t.push(arguments[r++]);u[++a]=function(){me(fe(e)?e:L(e),t)};s(a);return a};q=function(e){delete u[e]};function c(e){if(je(u,e)){var t=u[e];delete u[e];t()}}function l(e){c(e.data)}if(Rt){s=function(e){B(xe.call(c,e))}}else if(n&&fe(r)&&!t.importScripts){s=function(e){r(e,"*")};n("message",l,false)}else if(fe(i)){o=new i;f=o.port2;o.port1.onmessage=l;s=we(f.postMessage,f,1)}else if(Q&&e in Q[O]("script")){s=function(t){Z.appendChild(Q[O]("script"))[e]=function(){Z.removeChild(this);c(t)}}}else{s=function(e){$(c,0,e)}}}("onreadystatechange");qt(Yt+$t,{setImmediate:U,clearImmediate:q});!function(e,t){fe(e)&&fe(e.resolve)&&e.resolve(t=new e(function(){}))==t||function(t,r){function i(e){var t;if(oe(e))t=e.then;return fe(t)?t:false}function a(e){var t=e[r],n=t.c,i=0,u;if(t.h)return true;while(n.length>i){u=n[i++];if(u.fail||a(u.P))return true}}function u(e,r){var n=e.c;if(r||n.length)t(function(){var t=e.p,u=e.v,s=e.s==1,o=0;if(r&&!a(t)){$(function(){if(!a(t)){if(Rt){if(!K.emit("unhandledRejection",u,t)){}}else if(fe(re.error)){re.error("Unhandled promise rejection",u)}}},1e3)}else while(n.length>o)!function(t){var r=s?t.ok:t.fail,n,a;try{if(r){if(!s)e.h=true;n=r===true?u:r(u);if(n===t.P){t.rej(D(p+"-chain cycle"))}else if(a=i(n)){a.call(n,t.res,t.rej)}else t.res(n)}else t.rej(u)}catch(o){t.rej(o)}}(n[o++]);n.length=0})}function s(e){var t=this,r,n;if(t.d)return;t.d=true;t=t.r||t;try{if(r=i(e)){n={r:t,d:false};r.call(e,we(s,n,1),we(o,n,1))}else{t.v=e;t.s=1;u(t)}}catch(a){o.call(n||{r:t,d:false},a)}}function o(e){var t=this;if(t.d)return;t.d=true;t=t.r||t;t.v=e;t.s=2;u(t,true)}function f(e){var t=yt(e)[It];return t!=n?t:e}e=function(t){pt(t);xt(this,e,p);var i={p:this,c:[],s:0,d:false,v:n,h:false};Vt(this,r,i);try{t(we(s,i,1),we(o,i,1))}catch(a){o.call(i,a)}};Ot(e[w],{then:function(t,i){var a=yt(yt(this)[m])[It];var s={ok:fe(t)?t:true,fail:fe(i)?i:false},o=s.P=new(a!=n?a:e)(function(e,t){s.res=pt(e);s.rej=pt(t)}),f=this[r];f.c.push(s);f.s&&u(f);return o},"catch":function(e){return this.then(n,e)}});Ot(e,{all:function(e){var t=f(this),r=[];return new t(function(n,i){lr(e,false,Ye,r);var a=r.length,u=C(a);if(a)qe.call(r,function(e,r){t.resolve(e).then(function(e){u[r]=e;--a||n(u)},i)});else n(u)})},race:function(e){var t=f(this);return new t(function(r,n){lr(e,false,function(e){t.resolve(e).then(r,n)})})},reject:function(e){return new(f(this))(function(t,r){r(e)})},resolve:function(e){return oe(e)&&r in e&&be(e)===this[w]?e:new(f(this))(function(t,r){t(e)})}})}(B||U,Pt("record"));he(e,p);Tt(e);qt(Yt+Gt*!ce(e),{Promise:e})}(t[p]);!function(){var e=Pt("uid"),t=Pt("O1"),i=Pt("weak"),a=Pt("leak"),u=Pt("last"),s=Pt("first"),o=_t?Pt("size"):"size",f=0,c={};function g(i,a,c,l,h,v){var d=h?"set":"add",g=i&&i[w],p={};function y(e,t){if(t!=n)lr(t,h,e[d],e);return e}function x(e,t){var n=g[e];if(r)g[e]=function(e,r){var i=n.call(this,e===0?0:e,r);return t?this:i}}if(!ce(i)||!(v||!Zt&&je(g,S)&&je(g,"entries"))){i=v?function(t){xt(this,i,a);Nt(this,e,f++);y(this,t)}:function(e){var r=this;xt(r,i,a);Nt(r,t,Ee(null));Nt(r,o,0);Nt(r,u,n);Nt(r,s,n);y(r,e)};Ot(Ot(i[w],c),l);v||!_t||_e(i[w],"size",{get:function(){return gt(this[o])}})}else{var E=i,b=new i,k=b[d](v?{}:-0,1),_;if(or(function(e){new i(e)})){i=function(e){xt(this,i,a);return y(new E,e)};i[w]=g;if(r)g[m]=i}v||b[S](function(e,t){_=1/t===-ue});if(_){x("delete");x("has");h&&x("get")}if(_||k!==b)x(d,true)}he(i,a);Tt(i);p[a]=i;qt(Yt+Ut+Gt*!ce(i),p);v||nr(i,a,function(e,t){Nt(this,Ht,{o:e,k:t})},function(){var e=this[Ht],t=e.k,r=e.l;while(r&&r.r)r=r.p;if(!e.o||!(e.l=r=r?r.n:e.o[s])){e.o=n;return ir(1)}if(t==Xt)return ir(0,r.k);if(t==Kt)return ir(0,r.v);return ir(0,[r.k,r.v])},h?Xt+Kt:Kt,!h);return i}function p(t,r){if(!oe(t))return(typeof t=="string"?"S":"P")+t;if(Le(t))return"F";if(!je(t,e)){if(!r)return"E";Vt(t,e,++f)}return"O"+t[e]}function y(e,r){var n=p(r),i;if(n!="F")return e[t][n];for(i=e[s];i;i=i.n){if(i.k==r)return i}}function x(e,r,i){var a=y(e,r),f,c;if(a)a.v=i;else{e[u]=a={i:c=p(r,true),k:r,v:i,p:f=e[u],n:n,r:false};if(!e[s])e[s]=a;if(f)f.n=a;e[o]++;if(c!="F")e[t][c]=a}return e}var E={clear:function(){for(var e=this,r=e[t],i=e[s];i;i=i.n){i.r=true;if(i.p)i.p=i.p.n=n;delete r[i.i]}e[s]=e[u]=n;e[o]=0},"delete":function(e){var r=this,n=y(r,e);if(n){var i=n.n,a=n.p;delete r[t][n.i];n.r=true;if(a)a.n=i;if(i)i.p=a;if(r[s]==n)r[s]=i;if(r[u]==n)r[u]=a;r[o]--}return!!n},forEach:function(e){var t=we(e,arguments[1],3),r;while(r=r?r.n:this[s]){t(r.v,r.k,this);while(r&&r.r)r=r.p}},has:function(e){return!!y(this,e)}};M=g(M,l,{get:function(e){var t=y(this,e);return t&&t.v},set:function(e,t){return x(this,e===0?0:e,t)}},E,true);A=g(A,h,{add:function(e){return x(this,e=e===0?0:e,e)}},E);function b(t,r,n){if(Le(yt(r)))k(t).set(r,n);else{je(r,i)||Vt(r,i,{});r[i][t[e]]=n}return t}function k(e){return e[a]||Vt(e,a,new M)[a]}var _={"delete":function(t){if(!oe(t))return false;if(Le(t))return k(this)["delete"](t);return je(t,i)&&je(t[i],this[e])&&delete t[i][this[e]]},has:function(t){if(!oe(t))return false;if(Le(t))return k(this).has(t);return je(t,i)&&je(t[i],this[e])}};W=g(W,v,{get:function(t){if(oe(t)){if(Le(t))return k(this).get(t);if(je(t,i))return t[i][this[e]]}},set:function(e,t){return b(this,e,t)}},_,true,true);if(r&&(new W).set(j.freeze(c),7).get(c)!=7){qe.call(Ge("delete,has,get,set"),function(e){var t=W[w][e];W[w][e]=function(r,n){if(oe(r)&&Le(r)){var i=k(this)[e](r,n);return e=="set"?this:i}return t.call(this,r,n)}})}z=g(z,d,{add:function(e){return b(this,e,true)}},_,false,true)}();!function(){function e(e){var t=[],r;for(r in e)t.push(r);Nt(this,Ht,{o:e,a:t,i:0})}tr(e,i,function(){var e=this[Ht],t=e.a,r;do{if(e.i>=t.length)return ir(1)}while(!((r=t[e.i++])in e.o));return ir(0,r)});function t(e){return function(t){yt(t);try{return e.apply(n,arguments),true}catch(r){return false}}}function r(e,t){var i=arguments.length<3?e:arguments[2],a=Ve(yt(e),t),u;if(a)return je(a,"value")?a.value:a.get===n?n:a.get.call(i);return oe(u=be(e))?r(u,t,i):n}function a(e,t,r){var i=arguments.length<4?e:arguments[3],u=Ve(yt(e),t),s,o;if(!u){if(oe(o=be(e))){return a(o,t,r,i)}u=wt(0)}if(je(u,"value")){if(u.writable===false||!oe(i))return false;s=Ve(i,t)||wt(0);s.value=r;return _e(i,t,s),true}return u.set===n?false:(u.set.call(i,r),true)}var u=j.isExtensible||Te;var s={apply:we(ge,pe,3),construct:function(e,t){var r=pt(arguments.length<3?e:arguments[2])[w],n=Ee(oe(r)?r:ie),i=pe.call(e,n,t);return oe(i)?i:n},defineProperty:t(_e),deleteProperty:function(e,t){var r=Ve(yt(e),t);return r&&!r.configurable?false:delete e[t]},enumerate:function(t){return new e(yt(t))},get:r,getOwnPropertyDescriptor:function(e,t){return Ve(yt(e),t)},getPrototypeOf:function(e){return be(yt(e))},has:function(e,t){return t in e},isExtensible:function(e){return!!u(yt(e))},ownKeys:Ae,preventExtensions:t(j.preventExtensions||Te),set:a};if(ke)s.setPrototypeOf=function(e,t){return ke(yt(e),t),true};qt(Yt,{Reflect:{}});qt(Dt,"Reflect",s)}();!function(){qt(Jt,u,{includes:Xe(true)});qt(Jt,s,{at:ht(true)});function e(e){return function(t){var r=Fe(t),n=Ne(t),i=n.length,a=0,u=C(i),s;if(e)while(i>a)u[a]=[s=n[a++],r[s]];else while(i>a)u[a]=r[n[a++]];return u}}qt(Dt,i,{getOwnPropertyDescriptors:function(e){var t=Fe(e),r={};qe.call(Ae(t),function(e){_e(r,e,wt(0,Ve(t,e)))});return r},values:e(false),entries:e(true)});qt(Dt,f,{escape:lt(/([\\\-[\]{}()*+?.,^$|])/g,"\\$1",true)})}();!function(e){ye=kt(e+"Get",true);var t=kt(e+h,true),r=kt(e+"Delete",true);qt(Dt,g,{referenceGet:ye,referenceSet:t,referenceDelete:r});Vt(ae,ye,Re);function n(e){if(e){var n=e[w];Vt(n,ye,n.get);Vt(n,t,n.set);Vt(n,r,n["delete"])}}n(M);n(W)}("reference");!function(e){function t(t,r){qe.call(Ge(t),function(t){if(t in ne)e[t]=we(ge,ne[t],r)})}t("pop,reverse,shift,keys,values,entries",1);t("indexOf,every,some,forEach,map,filter,find,findIndex,includes",3);t("join,slice,concat,push,splice,unshift,sort,lastIndexOf,"+"reduce,reduceRight,copyWithin,fill,turn");qt(Dt,u,e)}({});!function(e){if(r&&e&&!(Ft in e[w])){Vt(e[w],Ft,Bt[u])}Bt.NodeList=Bt[u]}(t.NodeList)}(typeof self!="undefined"&&self.Math===Math?self:Function("return this")(),true)},function(e,t,r){(function(t){!function(t){"use strict";var r=Object.prototype.hasOwnProperty;var n;var i=typeof Symbol==="function"&&Symbol.iterator||"@@iterator";var a=typeof e==="object";var u=t.regeneratorRuntime;if(u){if(a){e.exports=u}return}u=t.regeneratorRuntime=a?e.exports:{};function s(e,t,r,n){return new y(e,t,r||null,n||[])}u.wrap=s;function o(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(n){return{type:"throw",arg:n}}}var f="suspendedStart";var c="suspendedYield";var l="executing";var h="completed";var v={};function d(){}function g(){}var p=g.prototype=y.prototype;d.prototype=p.constructor=g;g.constructor=d;d.displayName="GeneratorFunction";u.isGeneratorFunction=function(e){var t=typeof e==="function"&&e.constructor;return t?t===d||(t.displayName||t.name)==="GeneratorFunction":false};u.mark=function(e){e.__proto__=g;e.prototype=Object.create(p);return e};u.async=function(e,t,r,n){return new Promise(function(i,a){var u=s(e,t,r,n);var f=l.bind(u.next);var c=l.bind(u["throw"]);function l(e){var t=o(this,null,e);if(t.type==="throw"){a(t.arg);return}var r=t.arg;if(r.done){i(r.value)}else{Promise.resolve(r.value).then(f,c)}}f()})};function y(e,t,r,i){var a=t?Object.create(t.prototype):this;var u=new m(i);var s=f;function d(t,i){if(s===l){throw new Error("Generator is already running")}if(s===h){return b()}while(true){var a=u.delegate;if(a){var d=o(a.iterator[t],a.iterator,i);if(d.type==="throw"){u.delegate=null;t="throw";i=d.arg;continue}t="next";i=n;var g=d.arg;if(g.done){u[a.resultName]=g.value;u.next=a.nextLoc}else{s=c;return g}u.delegate=null}if(t==="next"){if(s===f&&typeof i!=="undefined"){throw new TypeError("attempt to send "+JSON.stringify(i)+" to newborn generator")}if(s===c){u.sent=i}else{delete u.sent}}else if(t==="throw"){if(s===f){s=h;throw i}if(u.dispatchException(i)){t="next";i=n}}else if(t==="return"){u.abrupt("return",i)}s=l;var d=o(e,r,u);if(d.type==="normal"){s=u.done?h:c;var g={value:d.arg,done:u.done};if(d.arg===v){if(u.delegate&&t==="next"){i=n}}else{return g}}else if(d.type==="throw"){s=h;if(t==="next"){u.dispatchException(d.arg)}else{i=d.arg}}}}a.next=d.bind(a,"next");a["throw"]=d.bind(a,"throw");a["return"]=d.bind(a,"return");return a}p[i]=function(){return this};p.toString=function(){return"[object Generator]"};function x(e){var t={tryLoc:e[0]};if(1 in e){t.catchLoc=e[1]}if(2 in e){t.finallyLoc=e[2];t.afterLoc=e[3]}this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal";delete t.arg;e.completion=t}function m(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(x,this);this.reset()}u.keys=function(e){var t=[];for(var r in e){t.push(r)}t.reverse();return function n(){while(t.length){var r=t.pop();if(r in e){n.value=r;n.done=false;return n}}n.done=true;return n}};function E(e){if(e){var t=e[i];if(t){return t.call(e)}if(typeof e.next==="function"){return e}if(!isNaN(e.length)){var a=-1,u=function s(){while(++a<e.length){if(r.call(e,a)){s.value=e[a];s.done=false;return s}}s.value=n;s.done=true;return s};return u.next=u}}return{next:b}}u.values=E;function b(){return{value:n,done:true}}m.prototype={constructor:m,reset:function(){this.prev=0;this.next=0;this.sent=n;this.done=false;this.delegate=null;this.tryEntries.forEach(w);for(var e=0,t;r.call(this,t="t"+e)||e<20;++e){this[t]=null}},stop:function(){this.done=true;var e=this.tryEntries[0];var t=e.completion;if(t.type==="throw"){throw t.arg}return this.rval},dispatchException:function(e){if(this.done){throw e}var t=this;function n(r,n){u.type="throw";u.arg=e;t.next=r;return!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i];var u=a.completion;if(a.tryLoc==="root"){return n("end")}if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc");var o=r.call(a,"finallyLoc");if(s&&o){if(this.prev<a.catchLoc){return n(a.catchLoc,true)}else if(this.prev<a.finallyLoc){return n(a.finallyLoc)}}else if(s){if(this.prev<a.catchLoc){return n(a.catchLoc,true)}}else if(o){if(this.prev<a.finallyLoc){return n(a.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}if(a&&(e==="break"||e==="continue")&&a.tryLoc<=t&&t<a.finallyLoc){a=null}var u=a?a.completion:{};u.type=e;u.arg=t;if(a){this.next=a.finallyLoc}else{this.complete(u)}return v},complete:function(e,t){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=e.arg;this.next="end"}else if(e.type==="normal"&&t){this.next=t}return v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e){return this.complete(r.completion,r.afterLoc)}}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if(n.type==="throw"){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){this.delegate={iterator:E(e),resultName:t,nextLoc:r};return v}}}(typeof t==="object"?t:typeof window==="object"?window:this)}).call(t,function(){return this}())}])}); | ||
//# sourceMappingURL=dist/js-graph.full.min.js.map |
@@ -1,2 +0,2 @@ | ||
(function e(r,t){if(typeof exports==="object"&&typeof module==="object")module.exports=t();else if(typeof define==="function"&&define.amd)define(t);else if(typeof exports==="object")exports["JsGraph"]=t();else r["JsGraph"]=t()})(this,function(){return function(e){var r={};function t(a){if(r[a])return r[a].exports;var n=r[a]={exports:{},id:a,loaded:false};e[a].call(n.exports,n,n.exports,t);n.loaded=true;return n.exports}t.m=e;t.c=r;t.p="";return t(0)}([function(e,r,t){e.exports=t(2)},,function(e,r,t){"use strict";var a=function(e,r){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var t=[];for(var a=e[Symbol.iterator](),n;!(n=a.next()).done;){t.push(n.value);if(r&&t.length===r)break}return t}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var n=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}else{return Array.from(e)}};var i=function(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})};var s=function(e,r){if(typeof r!=="function"&&r!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof r)}e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(r)e.__proto__=r};var u=function(){function e(e,r){for(var t=0;t<r.length;t++){var a=r[t];a.configurable=true;if(a.value)a.writable=true;Object.defineProperty(e,a.key,a)}}return function(r,t,a){if(t)e(r.prototype,t);if(a)e(r,a);return r}}();var o=function(){function e(e,r){for(var t in r){var a=r[t];a.configurable=true;if(a.value)a.writable=true}Object.defineProperties(e,r)}return function(r,t,a){if(t)e(r.prototype,t);if(a)e(r,a);return r}}();var f=function(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}};var h=function(){function e(){f(this,e);this._callbacks=new Set}o(e,{add:{value:function r(e){var r=this;if(!this._callbacks.has(e)){this._callbacks.add(e)}return function(){r._callbacks["delete"](e)}}},fire:{value:function t(){for(var e=arguments.length,r=Array(e),t=0;t<e;t++){r[t]=arguments[t]}var a=true;var n=false;var i=undefined;try{for(var s=this._callbacks[Symbol.iterator](),u;!(a=(u=s.next()).done);a=true){var o=u.value;o.apply(undefined,r)}}catch(f){n=true;i=f}finally{try{if(!a&&s["return"]){s["return"]()}}finally{if(n){throw i}}}}}});return e}();var c=function(){function e(){f(this,e);this._vertices=new Map;this._edges=new Map;this._reverseEdges=new Map;this._vertexCount=0;this._edgeCount=0;this._addVertexCallbacks=new h;this._removeVertexCallbacks=new h;this._addEdgeCallbacks=new h;this._removeEdgeCallbacks=new h}u(e,[{key:"onAddVertex",value:function r(e){return this._addVertexCallbacks.add(e)}},{key:"onRemoveVertex",value:function t(e){return this._removeVertexCallbacks.add(e)}},{key:"addNewVertex",value:function i(r,t){if(this.hasVertex(r)){throw new e.VertexExistsError(r,this._vertices.get(r))}this._vertices.set(r,t);this._edges.set(r,new Map);this._reverseEdges.set(r,new Set);this._vertexCount+=1;this._addVertexCallbacks.fire(r,t)}},{key:"setVertex",value:function s(r,t){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._vertices.set(r,t)}},{key:"ensureVertex",value:function o(e,r){if(!this.hasVertex(e)){this.addNewVertex(e,r)}}},{key:"addVertex",value:function c(e,r){if(this.hasVertex(e)){this.setVertex(e,r)}else{this.addNewVertex(e,r)}}},{key:"removeExistingVertex",value:function v(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(this._edges.get(r).size>0){throw new e.HasConnectedEdgesError(r)}if(this._reverseEdges.get(r).size>0){throw new e.HasConnectedEdgesError(r)}var t=this._vertices.get(r);this._vertices["delete"](r);this._vertexCount-=1;this._removeVertexCallbacks.fire(r,t)}},{key:"destroyExistingVertex",value:function l(r){var t=this;if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this.eachVertexFrom(r,function(e){t.removeEdge(r,e)});this.eachVertexTo(r,function(e){t.removeEdge(e,r)});this.removeExistingVertex(r)}},{key:"removeVertex",value:function d(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function x(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function g(){return this._vertexCount}},{key:"hasVertex",value:function y(e){return this._vertices.has(e)}},{key:"vertexValue",value:function k(e){return this._vertices.get(e)}},{key:"onAddEdge",value:function p(e){return this._addEdgeCallbacks.add(e)}},{key:"onRemoveEdge",value:function E(e){return this._removeEdgeCallbacks.add(e)}},{key:"addNewEdge",value:function w(r,t,a){if(this.hasEdge(r,t)){throw new e.EdgeExistsError(r,t,this.edgeValue(r,t))}if(!this.hasVertex(r)){if(this.hasVertex(t)){throw new e.VertexNotExistsError(r)}else{throw new e.VertexNotExistsError(r).v(t)}}else if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._edges.get(r).set(t,a);this._reverseEdges.get(t).add(r);this._edgeCount+=1;this._addEdgeCallbacks.fire(r,t,a)}},{key:"createNewEdge",value:function b(r,t,a){if(this.hasEdge(r,t)){throw new e.EdgeExistsError(r,t,this.edgeValue(r,t))}this.ensureVertex(r);this.ensureVertex(t);this.addNewEdge(r,t,a)}},{key:"setEdge",value:function m(r,t,a){if(!this.hasEdge(r,t)){throw new e.EdgeNotExistsError(r,t)}this._edges.get(r).set(t,a)}},{key:"spanEdge",value:function _(r,t,a){if(!this.hasVertex(r)){if(this.hasVertex(t)){throw new e.VertexNotExistsError(r)}else{throw new e.VertexNotExistsError(r).v(t)}}else if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(!this.hasEdge(r,t)){this.addNewEdge(r,t,a)}}},{key:"addEdge",value:function V(e,r,t){if(this.hasEdge(e,r)){this.setEdge(e,r,t)}else{this.addNewEdge(e,r,t)}}},{key:"ensureEdge",value:function S(e,r,t){if(!this.hasEdge(e,r)){this.createNewEdge(e,r,t)}}},{key:"createEdge",value:function C(e,r,t){if(this.hasEdge(e,r)){this.setEdge(e,r,t)}else{this.createNewEdge(e,r,t)}}},{key:"removeExistingEdge",value:function N(r,t){if(!this.hasEdge(r,t)){throw new e.EdgeNotExistsError(r,t)}var a=this._edges.get(r).get(t);this._edges.get(r)["delete"](t);this._reverseEdges.get(t)["delete"](r);this._edgeCount-=1;this._removeEdgeCallbacks.fire(r,t,a)}},{key:"removeEdge",value:function T(e,r){if(this.hasEdge(e,r)){this.removeExistingEdge(e,r)}}},{key:"edgeCount",value:function R(){return this._edgeCount}},{key:"hasEdge",value:function j(e,r){return this.hasVertex(e)&&this.hasVertex(r)&&this._edges.has(e)&&this._edges.get(e).has(r)}},{key:"edgeValue",value:function P(e,r){return this.hasEdge(e,r)?this._edges.get(e).get(r):undefined}},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"vertices",value:regeneratorRuntime.mark(function F(){var e=this;var r,t,n,i,s,u,o,f,h;return regeneratorRuntime.wrap(function c(v){while(1)switch(v.prev=v.next){case 0:r=new Set;t=true;n=false;i=undefined;v.prev=4;s=e._vertices[Symbol.iterator]();case 6:if(t=(u=s.next()).done){v.next=17;break}o=a(u.value,2);f=o[0];h=o[1];if(!(e.hasVertex(f)&&!r.has(f))){v.next=14;break}r.add(f);v.next=14;return[f,h];case 14:t=true;v.next=6;break;case 17:v.next=23;break;case 19:v.prev=19;v.t0=v["catch"](4);n=true;i=v.t0;case 23:v.prev=23;v.prev=24;if(!t&&s["return"]){s["return"]()}case 26:v.prev=26;if(!n){v.next=29;break}throw i;case 29:return v.finish(26);case 30:return v.finish(23);case 31:case"end":return v.stop()}},F,this,[[4,19,23,31],[24,,26,30]])})},{key:"edges",value:regeneratorRuntime.mark(function M(){var e=this;var r,t,a,n,i,s,u,o,f,h,c,v,l;return regeneratorRuntime.wrap(function d(x){while(1)switch(x.prev=x.next){case 0:r=new Map;t=true;a=false;n=undefined;x.prev=4;i=e._edges.keys()[Symbol.iterator]();case 6:if(t=(s=i.next()).done){x.next=40;break}u=s.value;if(!r.has(u)){r.set(u,new Set)}o=true;f=false;h=undefined;x.prev=12;c=e._edges.get(u).keys()[Symbol.iterator]();case 14:if(o=(v=c.next()).done){x.next=23;break}l=v.value;if(!(e.hasEdge(u,l)&&!r.get(u).has(l))){x.next=20;break}r.get(u).add(l);x.next=20;return[u,l,e._edges.get(u).get(l)];case 20:o=true;x.next=14;break;case 23:x.next=29;break;case 25:x.prev=25;x.t1=x["catch"](12);f=true;h=x.t1;case 29:x.prev=29;x.prev=30;if(!o&&c["return"]){c["return"]()}case 32:x.prev=32;if(!f){x.next=35;break}throw h;case 35:return x.finish(32);case 36:return x.finish(29);case 37:t=true;x.next=6;break;case 40:x.next=46;break;case 42:x.prev=42;x.t2=x["catch"](4);a=true;n=x.t2;case 46:x.prev=46;x.prev=47;if(!t&&i["return"]){i["return"]()}case 49:x.prev=49;if(!a){x.next=52;break}throw n;case 52:return x.finish(49);case 53:return x.finish(46);case 54:case"end":return x.stop()}},M,this,[[4,42,46,54],[12,25,29,37],[30,,32,36],[47,,49,53]])})},{key:"verticesFrom",value:function O(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesFrom(r)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function W(e){var r=this;var t,a,n,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:t=new Set;a=true;n=false;i=undefined;h.prev=4;s=r._edges.get(e).keys()[Symbol.iterator]();case 6:if(a=(u=s.next()).done){h.next=15;break}o=u.value;if(!(r.hasEdge(e,o)&&!t.has(o))){h.next=12;break}t.add(o);h.next=12;return[o,r._vertices.get(o),r._edges.get(e).get(o)];case 12:a=true;h.next=6;break;case 15:h.next=21;break;case 17:h.prev=17;h.t3=h["catch"](4);n=true;i=h.t3;case 21:h.prev=21;h.prev=22;if(!a&&s["return"]){s["return"]()}case 24:h.prev=24;if(!n){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},W,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesTo",value:function A(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesTo(r)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function Y(e){var r=this;var t,a,n,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:t=new Set;a=true;n=false;i=undefined;h.prev=4;s=r._reverseEdges.get(e)[Symbol.iterator]();case 6:if(a=(u=s.next()).done){h.next=15;break}o=u.value;if(!(r.hasEdge(o,e)&&!t.has(o))){h.next=12;break}t.add(o);h.next=12;return[o,r._vertices.get(o),r._edges.get(o).get(e)];case 12:a=true;h.next=6;break;case 15:h.next=21;break;case 17:h.prev=17;h.t4=h["catch"](4);n=true;i=h.t4;case 21:h.prev=21;h.prev=22;if(!a&&s["return"]){s["return"]()}case 24:h.prev=24;if(!n){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},Y,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesWithPathFrom",value:function H(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesWithPathFrom(r,new Set)}},{key:"_verticesWithPathFrom",value:regeneratorRuntime.mark(function z(e,r){var t=this;var a,n,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:a=true;n=false;i=undefined;h.prev=3;s=t._edges.get(e).keys()[Symbol.iterator]();case 5:if(a=(u=s.next()).done){h.next=15;break}o=u.value;if(!(t.hasEdge(e,o)&&!r.has(o))){h.next=12;break}r.add(o);h.next=11;return[o,t._vertices.get(o)];case 11:return h.delegateYield(t._verticesWithPathFrom(o,r),"t5",12);case 12:a=true;h.next=5;break;case 15:h.next=21;break;case 17:h.prev=17;h.t6=h["catch"](3);n=true;i=h.t6;case 21:h.prev=21;h.prev=22;if(!a&&s["return"]){s["return"]()}case 24:h.prev=24;if(!n){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},z,this,[[3,17,21,29],[22,,24,28]])})},{key:"verticesWithPathTo",value:function G(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesWithPathTo(r,new Set)}},{key:"_verticesWithPathTo",value:regeneratorRuntime.mark(function J(e,r){var t=this;var a,n,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:a=true;n=false;i=undefined;h.prev=3;s=t._reverseEdges.get(e)[Symbol.iterator]();case 5:if(a=(u=s.next()).done){h.next=15;break}o=u.value;if(!(t.hasEdge(o,e)&&!r.has(o))){h.next=12;break}r.add(o);h.next=11;return[o,t._vertices.get(o)];case 11:return h.delegateYield(t._verticesWithPathTo(o,r),"t7",12);case 12:a=true;h.next=5;break;case 15:h.next=21;break;case 17:h.prev=17;h.t8=h["catch"](3);n=true;i=h.t8;case 21:h.prev=21;h.prev=22;if(!a&&s["return"]){s["return"]()}case 24:h.prev=24;if(!n){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},J,this,[[3,17,21,29],[22,,24,28]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function q(){var r=this;var t=regeneratorRuntime.mark(function d(r){var t,u,o,f,h,c,v,l,x;return regeneratorRuntime.wrap(function g(y){while(1)switch(y.prev=y.next){case 0:n.push(r);t=n.indexOf(r);if(!(t!==n.length-1)){y.next=5;break}u=n.slice(t+1).reverse();throw new e.CycleError(u);case 5:if(i.has(r)){y.next=36;break}o=true;f=false;h=undefined;y.prev=9;c=s.verticesTo(r)[Symbol.iterator]();case 11:if(o=(v=c.next()).done){y.next=18;break}l=a(v.value,1);x=l[0];return y.delegateYield(d(x),"t9",15);case 15:o=true;y.next=11;break;case 18:y.next=24;break;case 20:y.prev=20;y.t10=y["catch"](9);f=true;h=y.t10;case 24:y.prev=24;y.prev=25;if(!o&&c["return"]){c["return"]()}case 27:y.prev=27;if(!f){y.next=30;break}throw h;case 30:return y.finish(27);case 31:return y.finish(24);case 32:if(!s.hasVertex(r)){y.next=35;break}y.next=35;return[r,s._vertices.get(r)];case 35:i.add(r);case 36:n.pop();case 37:case"end":return y.stop()}},d,this,[[9,20,24,32],[25,,27,31]])});var n,i,s,u,o,f,h,c,v,l;return regeneratorRuntime.wrap(function x(e){while(1)switch(e.prev=e.next){case 0:n=[];i=new Set;s=r;u=true;o=false;f=undefined;e.prev=6;h=r.vertices()[Symbol.iterator]();case 8:if(u=(c=h.next()).done){e.next=16;break}v=a(c.value,1);l=v[0];if(i.has(l)){e.next=13;break}return e.delegateYield(t(l),"t11",13);case 13:u=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t12=e["catch"](6);o=true;f=e.t12;case 22:e.prev=22;e.prev=23;if(!u&&h["return"]){h["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw f;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},q,this,[[6,18,22,30],[23,,25,29]])})},{key:"eachVertex",value:function I(e){var r=true;var t=false;var a=undefined;try{for(var i=this.vertices()[Symbol.iterator](),s;!(r=(s=i.next()).done);r=true){var u=s.value;if(e.apply(undefined,n(u))===false){break}}}catch(o){t=true;a=o}finally{try{if(!r&&i["return"]){i["return"]()}}finally{if(t){throw a}}}}},{key:"eachEdge",value:function B(e){var r=true;var t=false;var a=undefined;try{for(var i=this.edges()[Symbol.iterator](),s;!(r=(s=i.next()).done);r=true){var u=s.value;if(e.apply(undefined,n(u))===false){break}}}catch(o){t=true;a=o}finally{try{if(!r&&i["return"]){i["return"]()}}finally{if(t){throw a}}}}},{key:"eachVertexFrom",value:function D(e,r){var t=true;var a=false;var i=undefined;try{for(var s=this.verticesFrom(e)[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=u.value;if(r.apply(undefined,n(o))===false){break}}}catch(f){a=true;i=f}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}}},{key:"eachVertexTo",value:function K(e,r){var t=true;var a=false;var i=undefined;try{for(var s=this.verticesTo(e)[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=u.value;if(r.apply(undefined,n(o))===false){break}}}catch(f){a=true;i=f}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}}},{key:"eachVertexWithPathFrom",value:function L(e,r){var t=true;var a=false;var i=undefined;try{for(var s=this.verticesWithPathFrom(e)[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=u.value;if(r.apply(undefined,n(o))===false){break}}}catch(f){a=true;i=f}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}}},{key:"eachVertexWithPathTo",value:function Q(e,r){var t=true;var a=false;var i=undefined;try{for(var s=this.verticesWithPathTo(e)[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=u.value;if(r.apply(undefined,n(o))===false){break}}}catch(f){a=true;i=f}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}}},{key:"eachVertexTopologically",value:function U(e){var r=true;var t=false;var a=undefined;try{for(var i=this.vertices_topologically()[Symbol.iterator](),s;!(r=(s=i.next()).done);r=true){var u=s.value;if(e.apply(undefined,n(u))===false){break}}}catch(o){t=true;a=o}finally{try{if(!r&&i["return"]){i["return"]()}}finally{if(t){throw a}}}}},{key:"clearEdges",value:function X(){var e=this;this.eachEdge(function(r,t){e.removeEdge(r,t)})}},{key:"clear",value:function Z(){var e=this;this.eachVertex(function(r){e.destroyVertex(r)})}},{key:"equals",value:function $(r){var t=arguments[1]===undefined?function(e,r,t,a){return e===r}:arguments[1];if(!(r instanceof e)){return false}if(this.vertexCount()!==r.vertexCount()){return false}if(this.edgeCount()!==r.edgeCount()){return false}var n=true;var i=false;var s=undefined;try{for(var u=this.vertices()[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var f=a(o.value,2);var h=f[0];var c=f[1];if(!r.hasVertex(h)){return false}if(!t(c,r.vertexValue(h),h)){return false}}}catch(v){i=true;s=v}finally{try{if(!n&&u["return"]){u["return"]()}}finally{if(i){throw s}}}var l=true;var d=false;var x=undefined;try{for(var g=this.edges()[Symbol.iterator](),y;!(l=(y=g.next()).done);l=true){var k=a(y.value,3);var p=k[0];var E=k[1];var c=k[2];if(!r.hasEdge(p,E)){return false}if(!t(c,r.edgeValue(p,E),p,E)){return false}}}catch(v){d=true;x=v}finally{try{if(!l&&g["return"]){g["return"]()}}finally{if(d){throw x}}}return true}},{key:"hasCycle",value:function ee(){var e=this;var r={};var t={};var a=false;var n=function(i){if(r[i]){a=true;return}if(t[i]){return}t[i]=true;r[i]=true;e.eachVertexFrom(i,function(e){n(e);if(a){return false}});r[i]=false};this.eachVertex(function(e){n(e);if(a){return false}});return a}},{key:"hasPath",value:function re(e,r){var t=this;if(!this.hasVertex(e)||!this.hasVertex(r)){return false}var a={};var n=function(e){if(t.hasEdge(e,r)){return true}a[e]=true;var i=false;t.eachVertexFrom(e,function(e){if(!i&&!a[e]&&n(e)){i=true}});delete a[e];return i};return n(e)}},{key:"clone",value:function te(){var r=arguments[0]===undefined?function(e){return e}:arguments[0];var t=new e;var n=true;var i=false;var s=undefined;try{for(var u=this.vertices()[Symbol.iterator](),o;!(n=(o=u.next()).done);n=true){var f=a(o.value,2);var h=f[0];var c=f[1];t.addVertex(h,r(c))}}catch(v){i=true;s=v}finally{try{if(!n&&u["return"]){u["return"]()}}finally{if(i){throw s}}}var l=true;var d=false;var x=undefined;try{for(var g=this.edges()[Symbol.iterator](),y;!(l=(y=g.next()).done);l=true){var k=a(y.value,3);var p=k[0];var E=k[1];var c=k[2];t.addEdge(p,E,r(c))}}catch(v){d=true;x=v}finally{try{if(!l&&g["return"]){g["return"]()}}finally{if(d){throw x}}}return t}},{key:"transitiveReduction",value:function ae(){var e=this.clone();var r=true;var t=false;var n=undefined;try{for(var i=this.vertices()[Symbol.iterator](),s;!(r=(s=i.next()).done);r=true){var u=a(s.value,1);var o=u[0];var f=true;var h=false;var c=undefined;try{for(var v=this.vertices()[Symbol.iterator](),l;!(f=(l=v.next()).done);f=true){var d=a(l.value,1);var x=d[0];if(e.hasEdge(o,x)){var g=true;var y=false;var k=undefined;try{for(var p=this.vertices()[Symbol.iterator](),E;!(g=(E=p.next()).done);g=true){var w=a(E.value,1);var b=w[0];if(e.hasPath(x,b)){e.removeEdge(o,b)}}}catch(m){y=true;k=m}finally{try{if(!g&&p["return"]){p["return"]()}}finally{if(y){throw k}}}}}}catch(m){h=true;c=m}finally{try{if(!f&&v["return"]){v["return"]()}}finally{if(h){throw c}}}}}catch(m){t=true;n=m}finally{try{if(!r&&i["return"]){i["return"]()}}finally{if(t){throw n}}}return e}}]);return e}();e.exports=c;c.VertexExistsError=function(e){function r(e,t){f(this,r);this.vertices={};this.v(e,t)}s(r,e);o(r,{v:{value:function t(e,r){this.vertices[e]=r;this._refreshMessage();return this}},_refreshMessage:{value:function a(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return r}(Error);c.VertexNotExistsError=function(e){function r(e){f(this,r);this.vertices={};this.v(e)}s(r,e);o(r,{v:{value:function t(e){this.vertices[e]=undefined;this._refreshMessage();return this}},_refreshMessage:{value:function a(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return r}(Error);c.EdgeExistsError=function(e){function r(e,t,a){f(this,r);this.edges={};this.e(e,t,a)}s(r,e);o(r,{e:{value:function t(e,r,a){this.edges[e]=i({},r,a);this._refreshMessage();return this}},_refreshMessage:{value:function a(){var e=this;var r=[];Object.keys(this.edges).forEach(function(t){Object.keys(e.edges[t]).forEach(function(e){r.push("('"+t+"', '"+e+"')")})});var t=r.length===1?"an edge":"edges";this.message="This graph has "+t+" "+r.join(", ")}}});return r}(Error);c.EdgeNotExistsError=function(e){function r(e,t){f(this,r);this.edges={};this.e(e,t)}s(r,e);o(r,{e:{value:function t(e,r){this.edges[e]=i({},r,undefined);this._refreshMessage();return this}},_refreshMessage:{value:function a(){var e=this;var r=[];Object.keys(this.edges).forEach(function(t){Object.keys(e.edges[t]).forEach(function(e){r.push("('"+t+"', '"+e+"')")})});var t=r.length===1?"an edge":"edges";this.message="This graph does not have "+t+" "+r.join(", ")}}});return r}(Error);c.HasConnectedEdgesError=function(e){function r(e){f(this,r);this.message="The '"+e+"' vertex has connected edges";this.key=e}s(r,e);return r}(Error);c.CycleError=function(e){function r(e){f(this,r);this.message="This graph contains a cycle: "+e;this.cycle=e}s(r,e);return r}(Error)}])}); | ||
(function e(r,t){if(typeof exports==="object"&&typeof module==="object")module.exports=t();else if(typeof define==="function"&&define.amd)define(t);else if(typeof exports==="object")exports["JsGraph"]=t();else r["JsGraph"]=t()})(this,function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:false};e[n].call(a.exports,a,a.exports,t);a.loaded=true;return a.exports}t.m=e;t.c=r;t.p="";return t(0)}([function(e,r,t){e.exports=t(2)},,function(e,r,t){"use strict";var n=function(e,r){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var t=[];for(var n=e[Symbol.iterator](),a;!(a=n.next()).done;){t.push(a.value);if(r&&t.length===r)break}return t}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var a=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}else{return Array.from(e)}};var i=function(){function e(e,r){for(var t in r){var n=r[t];n.configurable=true;if(n.value)n.writable=true}Object.defineProperties(e,r)}return function(r,t,n){if(t)e(r.prototype,t);if(n)e(r,n);return r}}();var s=function(e,r){if(typeof r!=="function"&&r!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof r)}e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(r)e.__proto__=r};var u=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.configurable=true;if(n.value)n.writable=true;Object.defineProperty(e,n.key,n)}}return function(r,t,n){if(t)e(r.prototype,t);if(n)e(r,n);return r}}();var o=function(e,r){if(!(e instanceof r)){throw new TypeError("Cannot call a class as a function")}};var f=function(){function e(){o(this,e);this._vertices=new Map;this._edges=new Map;this._reverseEdges=new Map;this._vertexCount=0;this._edgeCount=0}u(e,[{key:"addNewVertex",value:function r(t,n){if(this.hasVertex(t)){throw new e.VertexExistsError(t,this._vertices.get(t))}this._vertices.set(t,n);this._edges.set(t,new Map);this._reverseEdges.set(t,new Set);this._vertexCount+=1}},{key:"setVertex",value:function t(r,n){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._vertices.set(r,n)}},{key:"ensureVertex",value:function a(e,r){if(!this.hasVertex(e)){this.addNewVertex(e,r)}}},{key:"addVertex",value:function i(e,r){if(this.hasVertex(e)){this.setVertex(e,r)}else{this.addNewVertex(e,r)}}},{key:"removeExistingVertex",value:function s(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(this._edges.get(r).size>0||this._reverseEdges.get(r).size>0){throw new e.HasConnectedEdgesError(r)}this._vertices["delete"](r);this._vertexCount-=1}},{key:"destroyExistingVertex",value:function f(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}var t=true;var a=false;var i=undefined;try{for(var s=this.verticesFrom(r)[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=n(u.value,1);var f=o[0];this.removeEdge(r,f)}}catch(h){a=true;i=h}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}var v=true;var c=false;var l=undefined;try{for(var d=this.verticesTo(r)[Symbol.iterator](),x;!(v=(x=d.next()).done);v=true){var g=n(x.value,1);var y=g[0];this.removeEdge(y,r)}}catch(h){c=true;l=h}finally{try{if(!v&&d["return"]){d["return"]()}}finally{if(c){throw l}}}this.removeExistingVertex(r)}},{key:"removeVertex",value:function h(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function v(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function c(){return this._vertexCount}},{key:"hasVertex",value:function l(e){return this._vertices.has(e)}},{key:"vertexValue",value:function d(e){return this._vertices.get(e)}},{key:"addNewEdge",value:function x(r,t,n){if(this.hasEdge(r,t)){throw new e.EdgeExistsError(r,t,this.edgeValue(r,t))}if(!this.hasVertex(r)){if(this.hasVertex(t)){throw new e.VertexNotExistsError(r)}else{throw new e.VertexNotExistsError(r).v(t)}}else if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._edges.get(r).set(t,n);this._reverseEdges.get(t).add(r);this._edgeCount+=1}},{key:"createNewEdge",value:function g(r,t,n){if(this.hasEdge(r,t)){throw new e.EdgeExistsError(r,t,this.edgeValue(r,t))}this.ensureVertex(r);this.ensureVertex(t);this.addNewEdge(r,t,n)}},{key:"setEdge",value:function y(r,t,n){if(!this.hasEdge(r,t)){throw new e.EdgeNotExistsError(r,t)}this._edges.get(r).set(t,n)}},{key:"spanEdge",value:function w(r,t,n){if(!this.hasVertex(r)){if(this.hasVertex(t)){throw new e.VertexNotExistsError(r)}else{throw new e.VertexNotExistsError(r).v(t)}}else if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(!this.hasEdge(r,t)){this.addNewEdge(r,t,n)}}},{key:"addEdge",value:function p(e,r,t){if(this.hasEdge(e,r)){this.setEdge(e,r,t)}else{this.addNewEdge(e,r,t)}}},{key:"ensureEdge",value:function E(e,r,t){if(!this.hasEdge(e,r)){this.createNewEdge(e,r,t)}}},{key:"createEdge",value:function k(e,r,t){if(this.hasEdge(e,r)){this.setEdge(e,r,t)}else{this.createNewEdge(e,r,t)}}},{key:"removeExistingEdge",value:function m(r,t){if(!this.hasEdge(r,t)){throw new e.EdgeNotExistsError(r,t)}this._edges.get(r)["delete"](t);this._reverseEdges.get(t)["delete"](r);this._edgeCount-=1}},{key:"removeEdge",value:function b(e,r){if(this.hasEdge(e,r)){this.removeExistingEdge(e,r)}}},{key:"edgeCount",value:function _(){return this._edgeCount}},{key:"hasEdge",value:function V(e,r){return this.hasVertex(e)&&this.hasVertex(r)&&this._edges.has(e)&&this._edges.get(e).has(r)}},{key:"edgeValue",value:function S(e,r){return this.hasEdge(e,r)?this._edges.get(e).get(r):undefined}},{key:"vertices",value:regeneratorRuntime.mark(function N(){var e=this;var r,t,a,i,s,u,o,f,h;return regeneratorRuntime.wrap(function v(c){while(1)switch(c.prev=c.next){case 0:r=new Set;t=true;a=false;i=undefined;c.prev=4;s=e._vertices[Symbol.iterator]();case 6:if(t=(u=s.next()).done){c.next=17;break}o=n(u.value,2);f=o[0];h=o[1];if(!(e.hasVertex(f)&&!r.has(f))){c.next=14;break}r.add(f);c.next=14;return[f,h];case 14:t=true;c.next=6;break;case 17:c.next=23;break;case 19:c.prev=19;c.t0=c["catch"](4);a=true;i=c.t0;case 23:c.prev=23;c.prev=24;if(!t&&s["return"]){s["return"]()}case 26:c.prev=26;if(!a){c.next=29;break}throw i;case 29:return c.finish(26);case 30:return c.finish(23);case 31:case"end":return c.stop()}},N,this,[[4,19,23,31],[24,,26,30]])})},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"edges",value:regeneratorRuntime.mark(function C(){var e=this;var r,t,n,a,i,s,u,o,f,h,v,c,l;return regeneratorRuntime.wrap(function d(x){while(1)switch(x.prev=x.next){case 0:r=new Map;t=true;n=false;a=undefined;x.prev=4;i=e._edges.keys()[Symbol.iterator]();case 6:if(t=(s=i.next()).done){x.next=40;break}u=s.value;if(!r.has(u)){r.set(u,new Set)}o=true;f=false;h=undefined;x.prev=12;v=e._edges.get(u).keys()[Symbol.iterator]();case 14:if(o=(c=v.next()).done){x.next=23;break}l=c.value;if(!(e.hasEdge(u,l)&&!r.get(u).has(l))){x.next=20;break}r.get(u).add(l);x.next=20;return[u,l,e._edges.get(u).get(l)];case 20:o=true;x.next=14;break;case 23:x.next=29;break;case 25:x.prev=25;x.t1=x["catch"](12);f=true;h=x.t1;case 29:x.prev=29;x.prev=30;if(!o&&v["return"]){v["return"]()}case 32:x.prev=32;if(!f){x.next=35;break}throw h;case 35:return x.finish(32);case 36:return x.finish(29);case 37:t=true;x.next=6;break;case 40:x.next=46;break;case 42:x.prev=42;x.t2=x["catch"](4);n=true;a=x.t2;case 46:x.prev=46;x.prev=47;if(!t&&i["return"]){i["return"]()}case 49:x.prev=49;if(!n){x.next=52;break}throw a;case 52:return x.finish(49);case 53:return x.finish(46);case 54:case"end":return x.stop()}},C,this,[[4,42,46,54],[12,25,29,37],[30,,32,36],[47,,49,53]])})},{key:"verticesFrom",value:function T(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesFrom(r)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function R(e){var r=this;var t,n,a,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:t=new Set;n=true;a=false;i=undefined;h.prev=4;s=r._edges.get(e).keys()[Symbol.iterator]();case 6:if(n=(u=s.next()).done){h.next=15;break}o=u.value;if(!(r.hasEdge(e,o)&&!t.has(o))){h.next=12;break}t.add(o);h.next=12;return[o,r._vertices.get(o),r._edges.get(e).get(o)];case 12:n=true;h.next=6;break;case 15:h.next=21;break;case 17:h.prev=17;h.t3=h["catch"](4);a=true;i=h.t3;case 21:h.prev=21;h.prev=22;if(!n&&s["return"]){s["return"]()}case 24:h.prev=24;if(!a){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},R,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesTo",value:function M(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesTo(r)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function P(e){var r=this;var t,n,a,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:t=new Set;n=true;a=false;i=undefined;h.prev=4;s=r._reverseEdges.get(e)[Symbol.iterator]();case 6:if(n=(u=s.next()).done){h.next=15;break}o=u.value;if(!(r.hasEdge(o,e)&&!t.has(o))){h.next=12;break}t.add(o);h.next=12;return[o,r._vertices.get(o),r._edges.get(o).get(e)];case 12:n=true;h.next=6;break;case 15:h.next=21;break;case 17:h.prev=17;h.t4=h["catch"](4);a=true;i=h.t4;case 21:h.prev=21;h.prev=22;if(!n&&s["return"]){s["return"]()}case 24:h.prev=24;if(!a){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},P,this,[[4,17,21,29],[22,,24,28]])})},{key:"verticesWithPathFrom",value:function j(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesWithPathFrom(r,new Set)}},{key:"_verticesWithPathFrom",value:regeneratorRuntime.mark(function F(e,r){var t=this;var n,a,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:n=true;a=false;i=undefined;h.prev=3;s=t._edges.get(e).keys()[Symbol.iterator]();case 5:if(n=(u=s.next()).done){h.next=15;break}o=u.value;if(!(t.hasEdge(e,o)&&!r.has(o))){h.next=12;break}r.add(o);h.next=11;return[o,t._vertices.get(o)];case 11:return h.delegateYield(t._verticesWithPathFrom(o,r),"t5",12);case 12:n=true;h.next=5;break;case 15:h.next=21;break;case 17:h.prev=17;h.t6=h["catch"](3);a=true;i=h.t6;case 21:h.prev=21;h.prev=22;if(!n&&s["return"]){s["return"]()}case 24:h.prev=24;if(!a){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},F,this,[[3,17,21,29],[22,,24,28]])})},{key:"verticesWithPathTo",value:function W(r){if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}return this._verticesWithPathTo(r,new Set)}},{key:"_verticesWithPathTo",value:regeneratorRuntime.mark(function A(e,r){var t=this;var n,a,i,s,u,o;return regeneratorRuntime.wrap(function f(h){while(1)switch(h.prev=h.next){case 0:n=true;a=false;i=undefined;h.prev=3;s=t._reverseEdges.get(e)[Symbol.iterator]();case 5:if(n=(u=s.next()).done){h.next=15;break}o=u.value;if(!(t.hasEdge(o,e)&&!r.has(o))){h.next=12;break}r.add(o);h.next=11;return[o,t._vertices.get(o)];case 11:return h.delegateYield(t._verticesWithPathTo(o,r),"t7",12);case 12:n=true;h.next=5;break;case 15:h.next=21;break;case 17:h.prev=17;h.t8=h["catch"](3);a=true;i=h.t8;case 21:h.prev=21;h.prev=22;if(!n&&s["return"]){s["return"]()}case 24:h.prev=24;if(!a){h.next=27;break}throw i;case 27:return h.finish(24);case 28:return h.finish(21);case 29:case"end":return h.stop()}},A,this,[[3,17,21,29],[22,,24,28]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function O(){var r=this;var t=regeneratorRuntime.mark(function d(r){var t,u,o,f,h,v,c,l,x;return regeneratorRuntime.wrap(function g(y){while(1)switch(y.prev=y.next){case 0:a.push(r);t=a.indexOf(r);if(!(t!==a.length-1)){y.next=5;break}u=a.slice(t+1).reverse();throw new e.CycleError(u);case 5:if(i.has(r)){y.next=36;break}o=true;f=false;h=undefined;y.prev=9;v=s.verticesTo(r)[Symbol.iterator]();case 11:if(o=(c=v.next()).done){y.next=18;break}l=n(c.value,1);x=l[0];return y.delegateYield(d(x),"t9",15);case 15:o=true;y.next=11;break;case 18:y.next=24;break;case 20:y.prev=20;y.t10=y["catch"](9);f=true;h=y.t10;case 24:y.prev=24;y.prev=25;if(!o&&v["return"]){v["return"]()}case 27:y.prev=27;if(!f){y.next=30;break}throw h;case 30:return y.finish(27);case 31:return y.finish(24);case 32:if(!s.hasVertex(r)){y.next=35;break}y.next=35;return[r,s._vertices.get(r)];case 35:i.add(r);case 36:a.pop();case 37:case"end":return y.stop()}},d,this,[[9,20,24,32],[25,,27,31]])});var a,i,s,u,o,f,h,v,c,l;return regeneratorRuntime.wrap(function x(e){while(1)switch(e.prev=e.next){case 0:a=[];i=new Set;s=r;u=true;o=false;f=undefined;e.prev=6;h=r.vertices()[Symbol.iterator]();case 8:if(u=(v=h.next()).done){e.next=16;break}c=n(v.value,1);l=c[0];if(i.has(l)){e.next=13;break}return e.delegateYield(t(l),"t11",13);case 13:u=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t12=e["catch"](6);o=true;f=e.t12;case 22:e.prev=22;e.prev=23;if(!u&&h["return"]){h["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw f;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},O,this,[[6,18,22,30],[23,,25,29]])})},{key:"clearEdges",value:function z(){var e=true;var r=false;var t=undefined;try{for(var a=this.edges()[Symbol.iterator](),i;!(e=(i=a.next()).done);e=true){var s=n(i.value,2);var u=s[0];var o=s[1];this.removeEdge(u,o)}}catch(f){r=true;t=f}finally{try{if(!e&&a["return"]){a["return"]()}}finally{if(r){throw t}}}}},{key:"clear",value:function Y(){var e=true;var r=false;var t=undefined;try{for(var a=this.vertices()[Symbol.iterator](),i;!(e=(i=a.next()).done);e=true){var s=n(i.value,1);var u=s[0];this.destroyVertex(u)}}catch(o){r=true;t=o}finally{try{if(!e&&a["return"]){a["return"]()}}finally{if(r){throw t}}}}},{key:"equals",value:function G(){var r=arguments[0]===undefined?undefined:arguments[0];var t=arguments[1]===undefined?function(e,r,t,n){return e===r}:arguments[1];if(!(r instanceof e)){return false}if(this.vertexCount()!==r.vertexCount()){return false}if(this.edgeCount()!==r.edgeCount()){return false}var a=true;var i=false;var s=undefined;try{for(var u=this.vertices()[Symbol.iterator](),o;!(a=(o=u.next()).done);a=true){var f=n(o.value,2);var h=f[0];var v=f[1];if(!r.hasVertex(h)){return false}if(!t(v,r.vertexValue(h),h)){return false}}}catch(c){i=true;s=c}finally{try{if(!a&&u["return"]){u["return"]()}}finally{if(i){throw s}}}var l=true;var d=false;var x=undefined;try{for(var g=this.edges()[Symbol.iterator](),y;!(l=(y=g.next()).done);l=true){var w=n(y.value,3);var p=w[0];var E=w[1];var v=w[2];if(!r.hasEdge(p,E)){return false}if(!t(v,r.edgeValue(p,E),p,E)){return false}}}catch(c){d=true;x=c}finally{try{if(!l&&g["return"]){g["return"]()}}finally{if(d){throw x}}}return true}},{key:"hasCycle",value:function H(){var e=this;var r=new Set;var t=new Set;var a=function(i){if(r.has(i)){return true}if(t.has(i)){return false}t.add(i);r.add(i);var s=true;var u=false;var o=undefined;try{for(var f=e.verticesFrom(i)[Symbol.iterator](),h;!(s=(h=f.next()).done);s=true){var v=n(h.value,1);var c=v[0];if(a(c)){return true}}}catch(l){u=true;o=l}finally{try{if(!s&&f["return"]){f["return"]()}}finally{if(u){throw o}}}r["delete"](i)};var i=true;var s=false;var u=undefined;try{for(var o=this.vertices()[Symbol.iterator](),f;!(i=(f=o.next()).done);i=true){var h=n(f.value,1);var v=h[0];if(a(v)){return true}}}catch(c){s=true;u=c}finally{try{if(!i&&o["return"]){o["return"]()}}finally{if(s){throw u}}}return false}},{key:"hasPath",value:function J(e,r){var t=this;if(!this.hasVertex(e)||!this.hasVertex(r)){return false}var a=new Set;var i=function(e){if(t.hasEdge(e,r)){return true}a.add(e);var s=true;var u=false;var o=undefined;try{for(var f=t.verticesFrom(e)[Symbol.iterator](),h;!(s=(h=f.next()).done);s=true){var v=n(h.value,1);var c=v[0];if(!a.has(c)&&i(c)){return true}}}catch(l){u=true;o=l}finally{try{if(!s&&f["return"]){f["return"]()}}finally{if(u){throw o}}}a["delete"](e);return false};return i(e)}},{key:"clone",value:function q(){var r=arguments[0]===undefined?function(e){return e}:arguments[0];var t=new e;var a=true;var i=false;var s=undefined;try{for(var u=this.vertices()[Symbol.iterator](),o;!(a=(o=u.next()).done);a=true){var f=n(o.value,2);var h=f[0];var v=f[1];t.addVertex(h,r(v,h))}}catch(c){i=true;s=c}finally{try{if(!a&&u["return"]){u["return"]()}}finally{if(i){throw s}}}var l=true;var d=false;var x=undefined;try{for(var g=this.edges()[Symbol.iterator](),y;!(l=(y=g.next()).done);l=true){var w=n(y.value,3);var p=w[0];var E=w[1];var v=w[2];t.addEdge(p,E,r(v,p,E))}}catch(c){d=true;x=c}finally{try{if(!l&&g["return"]){g["return"]()}}finally{if(d){throw x}}}return t}},{key:"transitiveReduction",value:function I(){var e=arguments[0]===undefined?function(e){return e}:arguments[0];var r=this.clone(e);var t=true;var a=false;var i=undefined;try{for(var s=this.vertices()[Symbol.iterator](),u;!(t=(u=s.next()).done);t=true){var o=n(u.value,1);var f=o[0];var h=true;var v=false;var c=undefined;try{for(var l=this.vertices()[Symbol.iterator](),d;!(h=(d=l.next()).done);h=true){var x=n(d.value,1);var g=x[0];if(r.hasEdge(f,g)){var y=true;var w=false;var p=undefined;try{for(var E=this.vertices()[Symbol.iterator](),k;!(y=(k=E.next()).done);y=true){var m=n(k.value,1);var b=m[0];if(r.hasPath(g,b)){r.removeEdge(f,b)}}}catch(_){w=true;p=_}finally{try{if(!y&&E["return"]){E["return"]()}}finally{if(w){throw p}}}}}}catch(_){v=true;c=_}finally{try{if(!h&&l["return"]){l["return"]()}}finally{if(v){throw c}}}}}catch(_){a=true;i=_}finally{try{if(!t&&s["return"]){s["return"]()}}finally{if(a){throw i}}}return r}}]);return e}();e.exports=f;f.VertexExistsError=function(e){function r(e,t){o(this,r);this.vertices=new Set;this.v(e,t)}s(r,e);i(r,{v:{value:function t(e,r){this.vertices.add({key:e,value:r});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices.size===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+[].concat(a(this.vertices)).map(function(e){return e.key}).join("', '")+"'"}}});return r}(Error);f.VertexNotExistsError=function(e){function r(e){o(this,r);this.vertices=new Set;this.v(e)}s(r,e);i(r,{v:{value:function t(e){this.vertices.add({key:e});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=this.vertices.size===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+[].concat(a(this.vertices)).map(function(e){return e.key}).join("', '")+"'"}}});return r}(Error);f.EdgeExistsError=function(e){function r(e,t,n){o(this,r);this.edges=new Set;this.e(e,t,n)}s(r,e);i(r,{e:{value:function t(e,r,n){this.edges.add({from:e,to:r,value:n});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=[];var r=true;var t=false;var n=undefined;try{for(var a=this.edges[Symbol.iterator](),i;!(r=(i=a.next()).done);r=true){var s=i.value;var u=s.from;var o=s.to;e.push("('"+u+"', '"+o+"')")}}catch(f){t=true;n=f}finally{try{if(!r&&a["return"]){a["return"]()}}finally{if(t){throw n}}}var h=e.length===1?"an edge":"edges";this.message="This graph has "+h+" "+e.join(", ")}}});return r}(Error);f.EdgeNotExistsError=function(e){function r(e,t){o(this,r);this.edges=new Set;this.e(e,t)}s(r,e);i(r,{e:{value:function t(e,r){this.edges.add({from:e,to:r});this._refreshMessage();return this}},_refreshMessage:{value:function n(){var e=[];var r=true;var t=false;var n=undefined;try{for(var a=this.edges[Symbol.iterator](),i;!(r=(i=a.next()).done);r=true){var s=i.value;var u=s.from;var o=s.to;e.push("('"+u+"', '"+o+"')")}}catch(f){t=true;n=f}finally{try{if(!r&&a["return"]){a["return"]()}}finally{if(t){throw n}}}var h=e.length===1?"an edge":"edges";this.message="This graph does not have "+h+" "+e.join(", ")}}});return r}(Error);f.HasConnectedEdgesError=function(e){function r(e){o(this,r);this.key=e;this.message="The '"+e+"' vertex has connected edges"}s(r,e);return r}(Error);f.CycleError=function(e){function r(e){o(this,r);this.cycle=e;this.message="This graph contains a cycle: "+e}s(r,e);return r}(Error)}])}); | ||
//# sourceMappingURL=dist/js-graph.min.js.map |
{ | ||
"name": "js-graph", | ||
"version": "1.6.1-alpha", | ||
"version": "1.7.0-alpha", | ||
"title": "Javascript Graph Datastructure", | ||
@@ -40,3 +40,3 @@ "homepage": "https://github.com/mhelvens/js-graph", | ||
"babel-loader": "~4", | ||
"bower": "~1.3", | ||
"bower": "~1", | ||
"isparta": "~2", | ||
@@ -46,2 +46,4 @@ "isparta-instrumenter-loader": "~0.1", | ||
"jasmine-core": "~2", | ||
"jsdoc": "~3", | ||
"jsdoc-to-markdown": "~0.6", | ||
"karma": "~0.12", | ||
@@ -61,7 +63,8 @@ "karma-babel-preprocessor": "~4", | ||
"scripts": { | ||
"prepublish": "npm run-script build", | ||
"prepublish": "npm run build && npm run docs", | ||
"build": "mkdir -p dist && cp src/js-graph.es6.js dist && webpack && uglifyjs dist/js-graph.js -mo dist/js-graph.min.js --in-source-map dist/js-graph.js.map --source-map dist/js-graph.min.js.map && uglifyjs dist/js-graph.full.js -mo dist/js-graph.full.min.js --in-source-map dist/js-graph.full.js.map --source-map dist/js-graph.full.min.js.map", | ||
"test": "karma start", | ||
"test-ci": "karma start ./karma.ci.conf.js" | ||
"test-ci": "karma start ./karma.ci.conf.js", | ||
"docs": "jsdoc2md src/**/*.es6.js -t docs/README.md.hbs -d 3 --partial \"./docs/partials/**/*.hbs\" --separators -l JavaScript > README.md" | ||
} | ||
} |
847
README.md
@@ -8,8 +8,8 @@ js-graph | ||
as well as traversing and analyzing them in various ways. It was originally created to | ||
track dependencies between options and modules. It is now rewritten in ECMAScript 6, but | ||
ECMAScript 5 versions are shipped with it, automatically generated with [Babel](https://babeljs.io). | ||
track dependencies between options and modules. It is written in ECMAScript 6, but | ||
auto-generated ECMAScript 5 versions are shipped with it. | ||
The library is fully functional and has 100% test-coverage, but the API is not yet | ||
properly documented. You could, of course, read the tests in the `test` directory, but | ||
user-friendly API documentation is forthcoming. | ||
If you want to run this library in an ECMAScript 5 context, it depends on the [Babel ES6 polyfill](https://babeljs.io/docs/usage/polyfill/). | ||
For your convenience, a version is provided with this polyfill already baked in, but you also | ||
have the option of providing it yourself. | ||
@@ -25,10 +25,831 @@ Feedback of any kind (questions, issues, pull requests) is greatly appreciated. | ||
| File | Description | | ||
| ---------------------- | ----------------------------------------------------------------------------- | | ||
| `js‑graph.es6.js` | For use in an ECMAScript 6 context, e.g., a modern browser or transpiler | | ||
| `js‑graph.js` | Requires you to first load `babel/polyfill.js` or `babel/polyfill-browser.js` | | ||
| `js‑graph.min.js` | Same as above, but minified | | ||
| `js‑graph.full.js` | Already includes `babel/polyfill.js`; ready for use in any context | | ||
| `js‑graph.full.min.js` | Same as above, but minified | | ||
| File | Description | | ||
| --------------------------------------------- | ------------------------------------------------------------------------------------------- | | ||
| `js‑graph.es6.js` | for use in an ECMAScript 6 context, e.g., a modern browser or transpiler | | ||
| `js‑graph.js`,<br>`js‑graph.min.js` | requires you to load the [Babel polyfill](https://babeljs.io/docs/usage/polyfill/) yourself | | ||
| `js‑graph.full.js`,<br>`js‑graph.full.min.js` | already includes the Babel polyfill | | ||
If you don't know which one you need, you probably want `js-graph.full.min.js`. | ||
If you don't know which you need, you probably want `js-graph.full.min.js`, because it will work out-of-the-box. | ||
But it is generally more elegant to load the polyfill yourself, especially if you use other libraries that also | ||
depend on it. | ||
API Documentation | ||
----------------- | ||
* [JsGraph](#JsGraph) | ||
* ___instance___ | ||
* [.addNewVertex(key, value)](#JsGraph#addNewVertex) | ||
* [.setVertex(key, value)](#JsGraph#setVertex) | ||
* [.ensureVertex(key, value)](#JsGraph#ensureVertex) | ||
* [.addVertex(key, value)](#JsGraph#addVertex) | ||
* [.removeExistingVertex(key)](#JsGraph#removeExistingVertex) | ||
* [.destroyExistingVertex(key)](#JsGraph#destroyExistingVertex) | ||
* [.removeVertex(key)](#JsGraph#removeVertex) | ||
* [.destroyVertex(key)](#JsGraph#destroyVertex) | ||
* [.vertexCount()](#JsGraph#vertexCount) ⇒ <code>number</code> | ||
* [.hasVertex(key)](#JsGraph#hasVertex) ⇒ <code>boolean</code> | ||
* [.vertexValue(key)](#JsGraph#vertexValue) ⇒ <code>\*</code> | ||
* [.addNewEdge(from, to, value)](#JsGraph#addNewEdge) | ||
* [.createNewEdge(from, to, value)](#JsGraph#createNewEdge) | ||
* [.setEdge(from, to, value)](#JsGraph#setEdge) | ||
* [.spanEdge(from, to, value)](#JsGraph#spanEdge) | ||
* [.addEdge(from, to, value)](#JsGraph#addEdge) | ||
* [.ensureEdge(from, to, value)](#JsGraph#ensureEdge) | ||
* [.createEdge(from, to, value)](#JsGraph#createEdge) | ||
* [.removeExistingEdge(from, to)](#JsGraph#removeExistingEdge) | ||
* [.removeEdge(from, to)](#JsGraph#removeEdge) | ||
* [.edgeCount()](#JsGraph#edgeCount) ⇒ <code>number</code> | ||
* [.hasEdge(from, to)](#JsGraph#hasEdge) ⇒ <code>boolean</code> | ||
* [.edgeValue(from, to)](#JsGraph#edgeValue) ⇒ <code>\*</code> | ||
* [.vertices()](#JsGraph#vertices) ⇒ <code>Iterator.<string, \*></code> | ||
* [.@@iterator()](#JsGraph#@@iterator) ⇒ <code>Iterator.<string, \*></code> | ||
* [.edges()](#JsGraph#edges) ⇒ <code>Iterator.<string, string, \*></code> | ||
* [.verticesFrom(from)](#JsGraph#verticesFrom) ⇒ <code>Iterator.<string, \*, \*></code> | ||
* [.verticesTo(to)](#JsGraph#verticesTo) ⇒ <code>Iterator.<string, \*, \*></code> | ||
* [.verticesWithPathFrom(from)](#JsGraph#verticesWithPathFrom) ⇒ <code>Iterator.<string, \*></code> | ||
* [.verticesWithPathTo(to)](#JsGraph#verticesWithPathTo) ⇒ <code>Iterator.<string, \*></code> | ||
* [.vertices_topologically()](#JsGraph#vertices_topologically) ⇒ <code>Iterator.<string, \*></code> | ||
* [.clearEdges()](#JsGraph#clearEdges) | ||
* [.clear()](#JsGraph#clear) | ||
* [.equals(other, [eq])](#JsGraph#equals) ⇒ <code>boolean</code> | ||
* [.hasCycle()](#JsGraph#hasCycle) ⇒ <code>boolean</code> | ||
* [.hasPath(from, to)](#JsGraph#hasPath) ⇒ <code>boolean</code> | ||
* [.clone([tr])](#JsGraph#clone) ⇒ <code>[JsGraph](#JsGraph)</code> | ||
* [.transitiveReduction([tr])](#JsGraph#transitiveReduction) ⇒ <code>[JsGraph](#JsGraph)</code> | ||
* ___static___ | ||
* [.VertexExistsError](#JsGraph.VertexExistsError) ⇐ <code>Error</code> | ||
* [.vertices](#JsGraph.VertexExistsError#vertices) : <code>Set.<{key: string, value}></code> | ||
* [.VertexNotExistsError](#JsGraph.VertexNotExistsError) ⇐ <code>Error</code> | ||
* [.vertices](#JsGraph.VertexNotExistsError#vertices) : <code>Set.<{key: string}></code> | ||
* [.EdgeExistsError](#JsGraph.EdgeExistsError) ⇐ <code>Error</code> | ||
* [.edges](#JsGraph.EdgeExistsError#edges) : <code>Set.<{from: string, to: string, value}></code> | ||
* [.EdgeNotExistsError](#JsGraph.EdgeNotExistsError) ⇐ <code>Error</code> | ||
* [.edges](#JsGraph.EdgeNotExistsError#edges) : <code>Set.<{from: string, to: string}></code> | ||
* [.HasConnectedEdgesError](#JsGraph.HasConnectedEdgesError) ⇐ <code>Error</code> | ||
* [.key](#JsGraph.HasConnectedEdgesError#key) : <code>string</code> | ||
* [.CycleError](#JsGraph.CycleError) ⇐ <code>Error</code> | ||
* [.cycle](#JsGraph.CycleError#cycle) : <code>Array.<string></code> | ||
----- | ||
<a name="JsGraph"></a> | ||
### JsGraph | ||
The main class of this library, to be used for representing a mathematical (di)graph. | ||
----- | ||
<a name="JsGraph#addNewVertex"></a> | ||
#### *jsGraph*.addNewVertex(key, value) | ||
Add a new vertex to this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key with which to refer to this new vertex | | ||
| value | <code>\*</code> | the value to store in this new vertex | | ||
**Throws**: | ||
- <code>[VertexExistsError](#JsGraph.VertexExistsError)</code> if a vertex with this key already exists | ||
----- | ||
<a name="JsGraph#setVertex"></a> | ||
#### *jsGraph*.setVertex(key, value) | ||
Set the value of an existing vertex in this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key belonging to the vertex | | ||
| value | <code>\*</code> | the value to store in this vertex | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with this key does not exist | ||
----- | ||
<a name="JsGraph#ensureVertex"></a> | ||
#### *jsGraph*.ensureVertex(key, value) | ||
Make sure a vertex with a specific key exists in this graph. If it already exists, nothing is done. | ||
If it does not yet exist, a new vertex is added with the given value. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key for the vertex | | ||
| value | <code>\*</code> | the value to store if a new vertex is added | | ||
----- | ||
<a name="JsGraph#addVertex"></a> | ||
#### *jsGraph*.addVertex(key, value) | ||
Add a new vertex to this graph. If a vertex with this key already exists, | ||
the value of that vertex is overwritten. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key with which to refer to this new vertex | | ||
| value | <code>\*</code> | the value to store in this new vertex | | ||
----- | ||
<a name="JsGraph#removeExistingVertex"></a> | ||
#### *jsGraph*.removeExistingVertex(key) | ||
Remove an existing vertex from this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key of the vertex to remove | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with this key does not exist | ||
- <code>[HasConnectedEdgesError](#JsGraph.HasConnectedEdgesError)</code> if there are still edges connected to this vertex | ||
----- | ||
<a name="JsGraph#destroyExistingVertex"></a> | ||
#### *jsGraph*.destroyExistingVertex(key) | ||
Remove an existing vertex from this graph, as well as all edges connected to it. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key of the vertex to remove | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with this key does not exist | ||
----- | ||
<a name="JsGraph#removeVertex"></a> | ||
#### *jsGraph*.removeVertex(key) | ||
Remove an existing vertex from this graph. | ||
If a vertex with this key does not exist, nothing happens. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key of the vertex to remove | | ||
**Throws**: | ||
- <code>[HasConnectedEdgesError](#JsGraph.HasConnectedEdgesError)</code> if there are still edges connected to this vertex | ||
----- | ||
<a name="JsGraph#destroyVertex"></a> | ||
#### *jsGraph*.destroyVertex(key) | ||
Remove a vertex from this graph, as well as all edges connected to it. | ||
If a vertex with this key does not exist, nothing happens. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key of the vertex to remove | | ||
----- | ||
<a name="JsGraph#vertexCount"></a> | ||
#### *jsGraph*.vertexCount() ⇒ <code>number</code> | ||
**Returns**: <code>number</code> - the number of vertices in the whole graph | ||
----- | ||
<a name="JsGraph#hasVertex"></a> | ||
#### *jsGraph*.hasVertex(key) ⇒ <code>boolean</code> | ||
Ask whether a vertex with a given key exists. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key to query | | ||
**Returns**: <code>boolean</code> - whether there is a vertex with the given key | ||
----- | ||
<a name="JsGraph#vertexValue"></a> | ||
#### *jsGraph*.vertexValue(key) ⇒ <code>\*</code> | ||
Get the value associated with the vertex of a given key. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key to query | | ||
**Returns**: <code>\*</code> - the value associated with the vertex of the given key. | ||
Note that a return value of `undefined` can mean | ||
1. that there is no such vertex, or | ||
2. that the stored value is actually `undefined`. | ||
Use [hasVertex](#JsGraph#hasVertex) to distinguish these cases. | ||
----- | ||
<a name="JsGraph#addNewEdge"></a> | ||
#### *jsGraph*.addNewEdge(from, to, value) | ||
Add a new edge to this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store in this new edge | | ||
**Throws**: | ||
- <code>[EdgeExistsError](#JsGraph.EdgeExistsError)</code> if an edge between `from` and `to` already exists | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if the `from` and/or `to` vertices do not yet exist in the graph | ||
----- | ||
<a name="JsGraph#createNewEdge"></a> | ||
#### *jsGraph*.createNewEdge(from, to, value) | ||
Add a new edge to this graph. If the `from` and/or `to` vertices do not yet exist | ||
in the graph, they are implicitly added with an `undefined` value. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store in this new edge | | ||
**Throws**: | ||
- <code>[EdgeExistsError](#JsGraph.EdgeExistsError)</code> if an edge between `from` and `to` already exists | ||
----- | ||
<a name="JsGraph#setEdge"></a> | ||
#### *jsGraph*.setEdge(from, to, value) | ||
Set the value of an existing edge in this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store in this edge | | ||
**Throws**: | ||
- <code>[EdgeNotExistsError](#JsGraph.EdgeNotExistsError)</code> if an edge between `from` and `to` does not yet exist | ||
----- | ||
<a name="JsGraph#spanEdge"></a> | ||
#### *jsGraph*.spanEdge(from, to, value) | ||
Make sure an edge between the `from` and `to` vertices in this graph. | ||
If one already exists, nothing is done. | ||
If one does not yet exist, a new edge is added with the given value. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store if a new edge is added | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if the `from` and/or `to` vertices do not yet exist in the graph | ||
----- | ||
<a name="JsGraph#addEdge"></a> | ||
#### *jsGraph*.addEdge(from, to, value) | ||
Add a new edge to this graph. If an edge between `from` and `to` already exists, | ||
the value of that edge is overwritten. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store in this new edge | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if the `from` and/or `to` vertices do not yet exist in the graph | ||
----- | ||
<a name="JsGraph#ensureEdge"></a> | ||
#### *jsGraph*.ensureEdge(from, to, value) | ||
Make sure an edge between the `from` and `to` vertices exists in this graph. | ||
If it already exists, nothing is done. | ||
If it does not yet exist, a new edge is added with the given value. | ||
If the `from` and/or `to` vertices do not yet exist | ||
in the graph, they are implicitly added with an `undefined` value. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store if a new edge is added | | ||
----- | ||
<a name="JsGraph#createEdge"></a> | ||
#### *jsGraph*.createEdge(from, to, value) | ||
Add a new edge to this graph. If an edge between the `from` and `to` | ||
vertices already exists, the value of that edge is overwritten. | ||
If the `from` and/or `to` vertices do not yet exist | ||
in the graph, they are implicitly added with an `undefined` value. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
| value | <code>\*</code> | the value to store if a new edge is added | | ||
----- | ||
<a name="JsGraph#removeExistingEdge"></a> | ||
#### *jsGraph*.removeExistingEdge(from, to) | ||
Remove an existing edge from this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
**Throws**: | ||
- <code>[EdgeNotExistsError](#JsGraph.EdgeNotExistsError)</code> if an edge between the `from` and `to` vertices doesn't exist | ||
----- | ||
<a name="JsGraph#removeEdge"></a> | ||
#### *jsGraph*.removeEdge(from, to) | ||
Remove an edge from this graph. | ||
If an edge between the `from` and `to` vertices doesn't exist, nothing happens. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
----- | ||
<a name="JsGraph#edgeCount"></a> | ||
#### *jsGraph*.edgeCount() ⇒ <code>number</code> | ||
**Returns**: <code>number</code> - the number of edges in the whole graph | ||
----- | ||
<a name="JsGraph#hasEdge"></a> | ||
#### *jsGraph*.hasEdge(from, to) ⇒ <code>boolean</code> | ||
Ask whether an edge between given `from` and `to` vertices exist. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
**Returns**: <code>boolean</code> - whether there is an edge between the given `from` and `to` vertices | ||
----- | ||
<a name="JsGraph#edgeValue"></a> | ||
#### *jsGraph*.edgeValue(from, to) ⇒ <code>\*</code> | ||
Get the value associated with the edge between given `from` and `to` vertices. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key for the originating vertex | | ||
| to | <code>string</code> | the key for the terminating vertex | | ||
**Returns**: <code>\*</code> - the value associated with the edge between the given `from` and `to` vertices | ||
Note that a return value of `undefined` can mean | ||
1. that there is no such edge, or | ||
2. that the stored value is actually `undefined`. | ||
Use [hasEdge](#JsGraph#hasEdge) to distinguish these cases. | ||
----- | ||
<a name="JsGraph#vertices"></a> | ||
#### *jsGraph*.vertices() ⇒ <code>Iterator.<string, \*></code> | ||
Iterate over all vertices of the graph, in no particular order. | ||
**Returns**: <code>Iterator.<string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.vertices(), keyVal = it.next(); !it.done;) { | ||
var key = keyVal[0], | ||
value = keyVal[1]; | ||
// iterates over all vertices of the graph | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [key, value] of jsGraph.vertices()) { | ||
// iterates over all vertices of the graph | ||
} | ||
``` | ||
**See**: [@@iterator](#JsGraph#@@iterator) | ||
----- | ||
<a name="JsGraph#@@iterator"></a> | ||
#### *jsGraph*.@@iterator() ⇒ <code>Iterator.<string, \*></code> | ||
A [JsGraph](#JsGraph) object is itself [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol), | ||
and serves as a short notation in ECMAScript 6 to iterate over all vertices in the graph, in no particular order. | ||
**Returns**: <code>Iterator.<string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (let [key, value] of jsGraph) { | ||
// iterates over all vertices of the graph | ||
} | ||
``` | ||
**See**: [vertices](#JsGraph#vertices) | ||
----- | ||
<a name="JsGraph#edges"></a> | ||
#### *jsGraph*.edges() ⇒ <code>Iterator.<string, string, \*></code> | ||
Iterate over all edges of the graph, in no particular order. | ||
**Returns**: <code>Iterator.<string, string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.edges(), fromToVal = it.next(); !it.done;) { | ||
var from = fromToVal[0], | ||
to = fromToVal[1], | ||
value = fromToVal[2]; | ||
// iterates over all edges of the graph | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [from, to, value] of jsGraph.edges()) { | ||
// iterates over all vertices of the graph | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#verticesFrom"></a> | ||
#### *jsGraph*.verticesFrom(from) ⇒ <code>Iterator.<string, \*, \*></code> | ||
Iterate over the outgoing edges of a given vertex in the graph, in no particular order. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key of the vertex to take the outgoing edges from | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with the given `from` key does not exist | ||
**Returns**: <code>Iterator.<string, \*, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.verticesFrom(from), toVertexEdge = it.next(); !it.done;) { | ||
var to = toVertexEdge[0], | ||
vertexValue = toVertexEdge[1], | ||
edgeValue = toVertexEdge[2]; | ||
// iterates over all outgoing vertices of the `from` vertex | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [to, vertexValue, edgeValue] of jsGraph.verticesFrom(from)) { | ||
// iterates over all outgoing edges of the `from` vertex | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#verticesTo"></a> | ||
#### *jsGraph*.verticesTo(to) ⇒ <code>Iterator.<string, \*, \*></code> | ||
Iterate over the incoming edges of a given vertex in the graph, in no particular order. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| to | <code>string</code> | the key of the vertex to take the incoming edges from | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with the given `to` key does not exist | ||
**Returns**: <code>Iterator.<string, \*, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.verticesTo(to), fromVertexEdge = it.next(); !it.done;) { | ||
var from = fromVertexEdge[0], | ||
vertexValue = fromVertexEdge[1], | ||
edgeValue = fromVertexEdge[2]; | ||
// iterates over all outgoing vertices of the `from` vertex | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [from, vertexValue, edgeValue] of jsGraph.verticesTo(to)) { | ||
// iterates over all incoming edges of the `to` vertex | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#verticesWithPathFrom"></a> | ||
#### *jsGraph*.verticesWithPathFrom(from) ⇒ <code>Iterator.<string, \*></code> | ||
Iterate over all vertices reachable from a given vertex in the graph, in no particular order. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the key of the vertex to take the reachable vertices from | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with the given `from` key does not exist | ||
**Returns**: <code>Iterator.<string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.verticesWithPathFrom(from), keyValue = it.next(); !it.done;) { | ||
var key = keyValue[0], | ||
value = keyValue[1]; | ||
// iterates over all vertices reachable from `from` | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [key, value] of jsGraph.verticesWithPathFrom(from)) { | ||
// iterates over all vertices reachable from `from` | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#verticesWithPathTo"></a> | ||
#### *jsGraph*.verticesWithPathTo(to) ⇒ <code>Iterator.<string, \*></code> | ||
Iterate over all vertices from which a given vertex in the graph can be reached, in no particular order. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| to | <code>string</code> | the key of the vertex to take the reachable vertices from | | ||
**Throws**: | ||
- <code>[VertexNotExistsError](#JsGraph.VertexNotExistsError)</code> if a vertex with the given `to` key does not exist | ||
**Returns**: <code>Iterator.<string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.verticesWithPathTo(to), keyValue = it.next(); !it.done;) { | ||
var key = keyValue[0], | ||
value = keyValue[1]; | ||
// iterates over all vertices from which `to` can be reached | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [key, value] of jsGraph.verticesWithPathTo(to)) { | ||
// iterates over all vertices from which `to` can be reached | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#vertices_topologically"></a> | ||
#### *jsGraph*.vertices_topologically() ⇒ <code>Iterator.<string, \*></code> | ||
Iterate over all vertices of the graph in topological order. | ||
**Returns**: <code>Iterator.<string, \*></code> - an object conforming to the [ES6 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol) | ||
**Example** | ||
```JavaScript | ||
for (var it = jsGraph.vertices_topologically(), keyVal = it.next(); !it.done;) { | ||
var key = keyVal[0], | ||
value = keyVal[1]; | ||
// iterates over all vertices of the graph in topological order | ||
} | ||
``` | ||
**Example** | ||
```JavaScript | ||
// in ECMAScript 6, you can use a for..of loop | ||
for (let [key, value] of jsGraph.vertices_topologically()) { | ||
// iterates over all vertices of the graph in topological order | ||
} | ||
``` | ||
----- | ||
<a name="JsGraph#clearEdges"></a> | ||
#### *jsGraph*.clearEdges() | ||
Remove all edges from the graph, but leave the vertices intact. | ||
----- | ||
<a name="JsGraph#clear"></a> | ||
#### *jsGraph*.clear() | ||
Remove all edges and vertices from the graph, putting it back in its initial state. | ||
----- | ||
<a name="JsGraph#equals"></a> | ||
#### *jsGraph*.equals(other, [eq]) ⇒ <code>boolean</code> | ||
Ask whether this graph and another graph are equal. | ||
Two graphs are equal if they have the same vertices and the same edges. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| other | <code>[JsGraph](#JsGraph)</code> | the other graph to compare this one to | | ||
| [eq] | <code>function</code> | a custom equality function for stored values; defaults to `===` comparison; The first two arguments are the two values to compare. If they are vertex values, the third argument is the vertex key. If they are edge values, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) | | ||
**Returns**: <code>boolean</code> - `true` if the two graphs are equal; `false` otherwise | ||
----- | ||
<a name="JsGraph#hasCycle"></a> | ||
#### *jsGraph*.hasCycle() ⇒ <code>boolean</code> | ||
Test whether the graph contains a directed cycle. | ||
**Returns**: <code>boolean</code> - `false`, if there is no cycle; a truthy value if there *is* a cycle | ||
(not necessarily `true`; future versions of the library might return | ||
a description of the cycle) | ||
----- | ||
<a name="JsGraph#hasPath"></a> | ||
#### *jsGraph*.hasPath(from, to) ⇒ <code>boolean</code> | ||
Test whether there is a directed path between a given pair of keys. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| from | <code>string</code> | the originating vertex | | ||
| to | <code>string</code> | the terminating vertex | | ||
**Returns**: <code>boolean</code> - `false`, if there is no such path; a truthy value if there *is* such a path | ||
(not necessarily `true`; future versions of the library might return | ||
a description of the path) | ||
----- | ||
<a name="JsGraph#clone"></a> | ||
#### *jsGraph*.clone([tr]) ⇒ <code>[JsGraph](#JsGraph)</code> | ||
Create a clone of this graph. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [tr] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) | | ||
**Returns**: <code>[JsGraph](#JsGraph)</code> - a clone of this graph | ||
----- | ||
<a name="JsGraph#transitiveReduction"></a> | ||
#### *jsGraph*.transitiveReduction([tr]) ⇒ <code>[JsGraph](#JsGraph)</code> | ||
Create a clone of this graph, but without any transitive edges. | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| [tr] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) | | ||
**Returns**: <code>[JsGraph](#JsGraph)</code> - a clone of this graph | ||
----- | ||
<a name="JsGraph.VertexExistsError"></a> | ||
#### *JsGraph*.VertexExistsError ⇐ <code>Error</code> | ||
This type of error is thrown when specific vertices are expected not to exist, but do. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.VertexExistsError#vertices"></a> | ||
##### *vertexExistsError*.vertices : <code>Set.<{key: string, value}></code> | ||
the set of relevant vertices | ||
----- | ||
<a name="JsGraph.VertexNotExistsError"></a> | ||
#### *JsGraph*.VertexNotExistsError ⇐ <code>Error</code> | ||
This type of error is thrown when specific vertices are expected to exist, but don't. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.VertexNotExistsError#vertices"></a> | ||
##### *vertexNotExistsError*.vertices : <code>Set.<{key: string}></code> | ||
the set of relevant vertices | ||
----- | ||
<a name="JsGraph.EdgeExistsError"></a> | ||
#### *JsGraph*.EdgeExistsError ⇐ <code>Error</code> | ||
This type of error is thrown when specific edges are expected not to exist, but do. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.EdgeExistsError#edges"></a> | ||
##### *edgeExistsError*.edges : <code>Set.<{from: string, to: string, value}></code> | ||
the set of relevant edges | ||
----- | ||
<a name="JsGraph.EdgeNotExistsError"></a> | ||
#### *JsGraph*.EdgeNotExistsError ⇐ <code>Error</code> | ||
This type of error is thrown when specific edges are expected to exist, but don't. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.EdgeNotExistsError#edges"></a> | ||
##### *edgeNotExistsError*.edges : <code>Set.<{from: string, to: string}></code> | ||
the set of relevant edges | ||
----- | ||
<a name="JsGraph.HasConnectedEdgesError"></a> | ||
#### *JsGraph*.HasConnectedEdgesError ⇐ <code>Error</code> | ||
This type of error is thrown when a vertex is expected not to have connected edges, but does. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.HasConnectedEdgesError#key"></a> | ||
##### *hasConnectedEdgesError*.key : <code>string</code> | ||
the key of the relevant vertex | ||
----- | ||
<a name="JsGraph.CycleError"></a> | ||
#### *JsGraph*.CycleError ⇐ <code>Error</code> | ||
This type of error is thrown when a graph is expected not to have a directed cycle, but does. | ||
**Extends:** <code>Error</code> | ||
----- | ||
<a name="JsGraph.CycleError#cycle"></a> | ||
##### *cycleError*.cycle : <code>Array.<string></code> | ||
the vertices involved in the cycle | ||
----- | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
866499
23
7412
854
22