Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphology

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphology - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

4

build/graphology.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.graphology=t():e.graphology=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";function n(e){e=e||{};for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var o=0,i=r.length;o<i;o++)if(r[o])for(var a in r[o])e[a]=r[o][a];return e}function o(){var e=new Map;return e.set=function(e,t){return e=""+e,Map.prototype.set.call(this,e,t)},e.get=function(e){return e=""+e,Map.prototype.get.call(this,e)},e.has=function(e){return e=""+e,Map.prototype.has.call(this,e)},e}function i(e,t,r,n){if("mixed"===n)return i(e,t,r,"directed")||i(e,t,r,"undirected");var o=e._nodes.get(t),a="directed"===n?o.out:o.undirectedOut;return a&&(a[r]||"undirected"!==n)||(a=o.undirectedIn),a&&a[r]?a[r]:null}function a(e){return!!e&&"object"===("undefined"==typeof e?"undefined":b(e))&&(Array.isArray(e)||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set||!(e instanceof Date)&&!(e instanceof RegExp))}function d(e){return!!e&&"object"===("undefined"==typeof e?"undefined":b(e))&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode}function u(e){return!(!e||"object"!==("undefined"==typeof e?"undefined":b(e))||Array.isArray(e)||e instanceof Date||e instanceof RegExp||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set)}function s(e,t){if(Array.isArray(e))for(var r=0,n=e.length;r<n;r++){var o=t(e[r],null)===!1;if(o)break}else if("function"==typeof e.forEach)for(var i=e.entries(),a=!1,d=void 0;d=i.next();){var u=d,s=u.value,h=u.done;if(h)break;var c=s[0],p=s[1];if(a=p===c?t(p,null)===!1:t(c,p)===!1)break}else for(var f in e){var g=e[f],l=t(f,g);if(l)break}}function h(e){for(var t=""+e,r="",n=0,o=t.length;n<o;n++){var i=o-n-1;r=t[i]+r,(n-2)%3||(r=","+r)}return r}function c(e,t,r){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:r})}function p(e,t,r){var n={enumerable:!0,configurable:!1};"function"==typeof r?n.get=r:(n.value=r,n.writable=!1),Object.defineProperty(e,t,n)}function f(){for(var e,t=0;t<16;t++)0===(3&t)&&(e=4294967296*Math.random()),y[t]=e>>>((3&t)<<3)&255;return y}function g(){var e=f();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function l(e){for(var t=[0],r=0,n=e.length;r<n;r++){for(var o=e[r],i=0,a=t.length;i<a;i++)o+=t[i]<<8,t[i]=o%62,o=o/62|0;for(;o>0;)t.push(o%62),o=o/62|0}for(var d="",u=0,s=e.length;0===e[u]&&u<s-1;u++)d+=m[0];for(var h=t.length-1;h>=0;h--)d+=m[t[h]];for(;d.length<22;)d+="0";return d}function v(){var e=g();return l(e)}Object.defineProperty(t,"__esModule",{value:!0});var b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.assign=n,t.createInternalMap=o,t.getMatchingEdge=i,t.isBunch=a,t.isGraph=d,t.isPlainObject=u,t.overBunch=s,t.prettyPrint=h,t.privateProperty=c,t.readOnlyProperty=p,t.uuid=v;var y=new Uint8Array(16),m="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=t.GraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this));return a.name="GraphError",a.message=r||"",a.data=i||{},a}return i(t,e),t}(Error);t.InvalidArgumentsGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a),t.NotFoundGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a),t.UsageGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){if("structure"===t){var r=e._indices.structure;if(!r.computed)return e;for(var n=arguments.length,o=Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];var a=o[0],d=o[1];(0,p.updateStructureIndex)(e,a,d)}return e}function d(e,t,r,n){if("structure"===t){var o=e._indices.structure;if(!o.computed)return e;(0,p.clearEdgeFromStructureIndex)(e,r,n)}return e}function u(e,t,r,n,o,i,d,u,s){if(!o&&"undirected"===e.type)throw new c.UsageGraphError("Graph."+t+": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.");if(o&&"directed"===e.type)throw new c.UsageGraphError("Graph."+t+": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.");if(s&&!(0,b.isPlainObject)(s))throw new c.InvalidArgumentsGraphError("Graph."+t+': invalid attributes. Expecting an object but got "'+s+'"');d=""+d,u=""+u;var h=!1,p=!1;if(!e.hasNode(d)){if(!r)throw new c.NotFoundGraphError("Graph."+t+': source node "'+d+'" not found.');h=!0}if(!e.hasNode(u)){if(!r)throw new c.NotFoundGraphError("Graph."+t+': target node "'+u+'" not found.');p=!0}if(!e.allowSelfLoops&&d===u)throw new c.UsageGraphError("Graph."+t+": source & target are the same, thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.");n&&(i=e._options.edgeKeyGenerator({undirected:o,source:d,target:u,attributes:s||{}}));var f=null;if(e.hasEdge(i)){if(!r)throw new c.UsageGraphError("Graph."+t+': the "'+i+'" edge already exists in the graph.');f=i}if(!e.multi&&(o?e.hasUndirectedEdge(d,u):e.hasDirectedEdge(d,u))){if(!r)throw new c.UsageGraphError("Graph."+t+': an edge linking "'+d+'" to "'+u+"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.");f=(0,b.getMatchingEdge)(e,d,u,o?"undirected":"directed")}if(s=(0,b.assign)({},e._options.defaultEdgeAttributes,s),f){if(e.source(f)!==d||e.target(f)!==u)throw new c.UsageGraphError("Graph."+t+': inconsitency detected when attempting to merge the "'+i+'" edge with "'+d+'" source & "'+u+'" target vs. ('+e.source(f)+", "+e.target(f)+").");return e.mergeEdgeAttributes(f,s),f}h&&e.addNode(d),p&&e.addNode(u);var g={attributes:s,source:d,target:u};o&&(g.undirected=!0),n&&(g.generatedId=!0),e._edges.set(i,g);var l=e._nodes.get(d),v=e._nodes.get(u);return d===u?o?l.undirectedSelfLoops++:l.directedSelfLoops++:o?(l.undirectedDegree++,v.undirectedDegree++):(l.outDegree++,v.inDegree++),a(e,"structure",i,g),e.emit("edgeAdded",{key:i,source:d,target:u,attributes:s,undirected:o}),i}function s(e,t,r,n){var o=[];if(n){if(!(0,b.isBunch)(n))throw new c.InvalidArgumentsGraphError("Graph."+t+": invalid bunch.");(0,b.overBunch)(n,function(n){if(!e.hasEdge(n))throw new c.NotFoundGraphError("Graph."+t+': could not find the "'+n+'" edge from the bunch in the graph.');r&&!r(n)||o.push(n)})}else o="exportEdges"===t?e.edges():"exportDirectedEdges"===t?e.directedEdges():e.undirectedEdges();for(var i=new Array(o.length),a=0,d=o.length;a<d;a++)i[a]=e.exportEdge(o[a]);return i}Object.defineProperty(t,"__esModule",{value:!0});var h=r(8),c=r(1),p=r(4),f=r(3),g=r(5),l=r(6),v=r(7),b=r(0),y=new Set(["directed","undirected","mixed"]),m=new Set(["domain","_events","_eventsCount","_maxListeners"]),w=[{name:function(e){return e+"Edge"},generateKey:!0},{name:function(e){return e+"DirectedEdge"},generateKey:!0,type:"directed"},{name:function(e){return e+"UndirectedEdge"},generateKey:!0,type:"undirected"},{name:function(e){return e+"EdgeWithKey"}},{name:function(e){return e+"DirectedEdgeWithKey"},type:"directed"},{name:function(e){return e+"UndirectedEdgeWithKey"},type:"undirected"}],E={allowSelfLoops:!0,defaultEdgeAttributes:{},defaultNodeAttributes:{},edgeKeyGenerator:b.uuid,multi:!1,type:"mixed"},G=function(e){function t(r){n(this,t);var i=o(this,e.call(this));if(r=(0,b.assign)({},E,r),Object.freeze(r),"function"!=typeof r.edgeKeyGenerator)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'edgeKeyGenerator' option. Expecting a function but got \""+r.edgeKeyGenerator+'".');if("boolean"!=typeof r.multi)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \""+r.multi+'".');if(!y.has(r.type))throw new c.InvalidArgumentsGraphError('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'+r.type+'".');if("boolean"!=typeof r.allowSelfLoops)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \""+r.allowSelfLoops+'".');if(!(0,b.isPlainObject)(r.defaultEdgeAttributes))throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultEdgeAttributes' option. Expecting a plain object but got \""+r.defaultEdgeAttributes+'".');if(!(0,b.isPlainObject)(r.defaultNodeAttributes))throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultNodeAttributes' option. Expecting a plain object but got \""+r.defaultNodeAttributes+'".');(0,b.privateProperty)(i,"_attributes",{}),(0,b.privateProperty)(i,"_nodes",(0,b.createInternalMap)()),(0,b.privateProperty)(i,"_edges",(0,b.createInternalMap)()),(0,b.privateProperty)(i,"_indices",{structure:{lazy:r.indices&&r.indices.structure&&r.indices.structure.lazy||!1,computed:!1}}),(0,b.privateProperty)(i,"_options",r),m.forEach(function(e){return(0,b.privateProperty)(i,e,i[e])}),(0,b.readOnlyProperty)(i,"order",function(){return i._nodes.size}),(0,b.readOnlyProperty)(i,"size",function(){return i._edges.size}),(0,b.readOnlyProperty)(i,"multi",i._options.multi),(0,b.readOnlyProperty)(i,"type",i._options.type),(0,b.readOnlyProperty)(i,"allowSelfLoops",i._options.allowSelfLoops);for(var a in i._indices){var d=i._indices[a];d.lazy||(d.computed=!0)}return i}return i(t,e),t.prototype.hasNode=function(e){return this._nodes.has(e)},t.prototype.hasDirectedEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)&&this.directed(r)}if(2===arguments.length){if(this.computeIndex("structure"),!this.hasNode(e)||!this.hasNode(t))return!1;var n=this._nodes.get(e),o=n.out;if(!o)return!1;var i=o[t];return!!i&&(this.multi?!!i.size:!!i)}throw new c.InvalidArgumentsGraphError("Graph.hasDirectedEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.hasUndirectedEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)&&this.undirected(r)}if(2===arguments.length){if(this.computeIndex("structure"),!this.hasNode(e)||!this.hasNode(t))return!1;var n=this._nodes.get(e),o=n.undirectedOut,i=void 0;return o&&(i=o[t]),o=n.undirectedIn,!i&&o&&(i=o[t]),!!i&&(this.multi?!!i.size:!!i)}throw new c.InvalidArgumentsGraphError("Graph.hasDirectedEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.hasEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)}if(2===arguments.length)return this.hasDirectedEdge(e,t)||this.hasUndirectedEdge(e,t);throw new c.InvalidArgumentsGraphError("Graph.hasEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.inDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.inDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.inDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?r.directedSelfLoops:0;return r.inDegree+n},t.prototype.outDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.outDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.outDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?r.directedSelfLoops:0;return r.outDegree+n},t.prototype.directedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.directedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.directedDegree: could not find the "'+e+'" node in the graph.');return this.inDegree(e,t)+this.outDegree(e,t)},t.prototype.undirectedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.undirectedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.undirectedDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?2*r.undirectedSelfLoops:0;return r.undirectedDegree+n},t.prototype.degree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.degree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.degree: could not find the "'+e+'" node in the graph.');return this.directedDegree(e,t)+this.undirectedDegree(e,t)},t.prototype.source=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.source: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).source},t.prototype.target=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.target: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).target},t.prototype.extremities=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.extremities: could not find the "'+e+'" edge in the graph.');return[this._edges.get(e).source,this._edges.get(e).target]},t.prototype.opposite=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.opposite: could not find the "'+e+'" node in the graph.');if(!this.hasEdge(t))throw new c.NotFoundGraphError('Graph.opposite: could not find the "'+t+'" edge in the graph.');var r=this.extremities(t),n=r[0],o=r[1];if(e!==n&&e!==o)throw new c.NotFoundGraphError('Graph.opposite: the "'+e+'" node is not attached to the "'+t+'" edge ('+n+", "+o+").");return e===n?o:n},t.prototype.undirected=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.undirected: could not find the "'+e+'" edge in the graph.');return!!this._edges.get(e).undirected},t.prototype.directed=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.directed: could not find the "'+e+'" edge in the graph.');return!this._edges.get(e).undirected},t.prototype.selfLoop=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.selfLoop: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return t.source===t.target},t.prototype.addNode=function(e,t){if(t&&!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError('Graph.addNode: invalid attributes. Expecting an object but got "'+t+'"');if(t=(0,b.assign)({},this._options.defaultNodeAttributes,t),this.hasNode(e))throw new c.UsageGraphError('Graph.addNode: the "'+e+'" node already exist in the graph.');var r={attributes:t};return this.allowSelfLoops&&("mixed"!==this.type&&"directed"!==this.type||(r.directedSelfLoops=0),"mixed"!==this.type&&"undirected"!==this.type||(r.undirectedSelfLoops=0)),"mixed"!==this.type&&"directed"!==this.type||(r.inDegree=0,r.outDegree=0),"mixed"!==this.type&&"undirected"!==this.type||(r.undirectedDegree=0),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:t}),e},t.prototype.mergeNode=function(e,t){return this.hasNode(e)?(t&&this.mergeNodeAttributes(e,t),e):this.addNode(e,t)},t.prototype.addNodesFrom=function(e){var t=this;if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError('Graph.addNodesFrom: invalid bunch provided ("'+e+'").');return(0,b.overBunch)(e,function(e,r){t.addNode(e,r)}),this},t.prototype.dropNode=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.dropNode: could not find the "'+e+'" node in the graph.');for(var t=this.edges(e),r=0,n=t.length;r<n;r++)this.dropEdge(t[r]);var o=this._nodes.get(e);this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:o.attributes})},t.prototype.dropEdge=function(e){if(arguments.length>1){var t=arguments[0],r=arguments[1];if(!this.hasNode(t))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" source node in the graph.');if(!this.hasNode(r))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+r+'" target node in the graph.');if(!this.hasEdge(t,r))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" -> "'+r+'" edge in the graph.');e=(0,b.getMatchingEdge)(this,t,r,this.type)}else if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+e+'" edge in the graph.');var n=this._edges.get(e);this._edges.delete(e);var o=n.source,i=n.target,a=n.attributes,u=n.undirected,s=void 0!==u&&u,h=this._nodes.get(o),p=this._nodes.get(i);return o===i?h.selfLoops--:s?(h.undirectedDegree--,p.undirectedDegree--):(h.outDegree--,p.inDegree--),d(this,"structure",e,n),this.emit("edgeDropped",{key:e,attributes:a,source:o,target:i,undirected:s}),this},t.prototype.dropNodes=function(e){var t=this;if(!arguments.length)return this.clear();if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.dropNodes: invalid bunch.");return(0,b.overBunch)(e,function(e){t.dropNode(e)}),this},t.prototype.dropEdges=function(e){var t=this;if(!arguments.length){this._edges=(0,b.createInternalMap)(),this.clearIndex("structure");var r=this._indices.structure;return r.lazy||(r.computed=!0),this}if(2===arguments.length){var n=arguments[0],o=arguments[1];e=this.edges(n,o)}if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.dropEdges: invalid bunch.");return(0,b.overBunch)(e,function(e){t.dropEdge(e)}),this},t.prototype.clear=function(){this._edges=(0,b.createInternalMap)(),this._nodes=(0,b.createInternalMap)();for(var e in this._indices){var t=this._indices[e];t.lazy&&(t.computed=!1)}this.emit("cleared")},t.prototype.getAttribute=function(e){return this._attributes[e]},t.prototype.getAttributes=function(){return this._attributes},t.prototype.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},t.prototype.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",meta:{name:e,value:t}}),this},t.prototype.updateAttribute=function(e,t){if("function"!=typeof t)throw new c.InvalidArgumentsGraphError("Graph.updateAttribute: updater should be a function.");return this._attributes[e]=t(this._attributes[e]),this.emit("attributesUpdated",{type:"set",meta:{name:e,value:this._attributes[e]}}),this},t.prototype.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",meta:{name:e}}),this},t.prototype.replaceAttributes=function(e){if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.replaceAttributes: provided attributes are not a plain object.");var t=this._attributes;return this._attributes=e,this.emit("attributesUpdated",{type:"replace",meta:{before:t,after:e}}),this},t.prototype.mergeAttributes=function(e){if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.mergeAttributes: provided attributes are not a plain object.");return this._attributes=(0,b.assign)(this._attributes,e),this.emit("attributesUpdated",{type:"merge",meta:{data:this._attributes}}),this},t.prototype.getNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.getNodeAttribute: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes[t]},t.prototype.getNodeAttributes=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.getNodeAttributes: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes},t.prototype.hasNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.hasNodeAttribute: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes.hasOwnProperty(t)},t.prototype.setNodeAttribute=function(e,t,r){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.setNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new c.InvalidArgumentsGraphError("Graph.setNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or value, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");return this._nodes.get(e).attributes[t]=r,this.emit("nodeAttributesUpdated",{key:e,type:"set",meta:{name:t,value:r}}),this},t.prototype.updateNodeAttribute=function(e,t,r){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.updateNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new c.InvalidArgumentsGraphError("Graph.updateNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or value, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");if("function"!=typeof r)throw new c.InvalidArgumentsGraphError("Graph.updateAttribute: updater should be a function.");var n=this._nodes.get(e).attributes;return n[t]=r(n[t]),this.emit("nodeAttributesUpdated",{key:e,type:"set",meta:{name:t,value:n[t]}}),this},t.prototype.removeNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.hasNodeAttribute: could not find the "'+e+'" node in the graph.');return delete this._nodes.get(e).attributes[t],this.emit("nodeAttributesUpdated",{key:e,type:"remove",meta:{name:t}}),this},t.prototype.replaceNodeAttributes=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.replaceNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError("Graph.replaceNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e),n=r.attributes;return r.attributes=t,this.emit("nodeAttributesUpdated",{key:e,type:"replace",meta:{before:n,after:t}}),this},t.prototype.mergeNodeAttributes=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.mergeNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError("Graph.mergeNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e);return(0,b.assign)(r.attributes,t),this.emit("nodeAttributesUpdated",{key:e,type:"merge",meta:{data:t}}),this},t.prototype.nodes=function(){return Array.from(this._nodes.keys())},t.prototype.exportNode=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.exportNode: could not find the "'+e+'" node in the graph.');var t=this._nodes.get(e);return(0,v.serializeNode)(e,t)},t.prototype.exportEdge=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.exportEdge: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return(0,v.serializeEdge)(e,t)},t.prototype.exportNodes=function(e){var t=this,r=[];if(arguments.length){if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.exportNodes: invalid bunch.");(0,b.overBunch)(e,function(e){if(!t.hasNode(e))throw new c.NotFoundGraphError('Graph.exportNodes: could not find the "'+e+'" node from the bunch in the graph.');r.push(e)})}else r=this.nodes();for(var n=new Array(r.length),o=0,i=r.length;o<i;o++)n[o]=this.exportNode(r[o]);return n},t.prototype.exportEdges=function(e){return s(this,"exportEdges",null,e)},t.prototype.exportDirectedEdges=function(e){var t=this;return s(this,"exportDirectedEdges",function(e){return t.directed(e)},e)},t.prototype.exportUndirectedEdges=function(e){var t=this;return s(this,"exportUndirectedEdges",function(e){return t.undirected(e)},e)},t.prototype.export=function(){return{attributes:this.getAttributes(),nodes:this.exportNodes(),edges:this.exportEdges()}},t.prototype.importNode=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(0,v.validateSerializedNode)(e);if(r){if("not-object"===r)throw new c.InvalidArgumentsGraphError('Graph.importNode: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if("no-key"===r)throw new c.InvalidArgumentsGraphError("Graph.importNode: no key provided.");if("invalid-attributes"===r)throw new c.InvalidArgumentsGraphError("Graph.importNode: invalid attributes. Attributes should be a plain object, null or omitted.")}var n=e.key,o=e.attributes,i=void 0===o?{}:o;return t?this.mergeNode(n,i):this.addNode(n,i),this},t.prototype.importEdge=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(0,v.validateSerializedEdge)(e);if(r){if("not-object"===r)throw new c.InvalidArgumentsGraphError('Graph.importEdge: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if("no-source"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: missing souce.");if("no-target"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: missing target");if("invalid-attributes"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if("invalid-undirected"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: invalid undirected. Undirected should be boolean or omitted.")}var n=e.source,o=e.target,i=e.attributes,a=void 0===i?{}:i,d=e.undirected,u=void 0!==d&&d,s=void 0;return"key"in e?(s=t?u?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:u?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,s.call(this,e.key,n,o,a)):(s=t?u?this.mergeUndirectedEdge:this.mergeDirectedEdge:u?this.addUndirectedEdge:this.addDirectedEdge,s.call(this,n,o,a)),this},t.prototype.importNodes=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))throw new c.InvalidArgumentsGraphError("Graph.importNodes: invalid argument. Expecting an array.");for(var r=0,n=e.length;r<n;r++)this.importNode(e[r],t);return this},t.prototype.importEdges=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))throw new c.InvalidArgumentsGraphError("Graph.importEdges: invalid argument. Expecting an array.");for(var r=0,n=e.length;r<n;r++)this.importEdge(e[r],t);return this},t.prototype.import=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,b.isGraph)(e))return this.import(e.export(),t),this;if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!(0,b.isPlainObject)(e.attributes))throw new c.InvalidArgumentsGraphError("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}return e.nodes&&this.importNodes(e.nodes,t),e.edges&&this.importEdges(e.edges,t),this},t.prototype.emptyCopy=function(){return new t(this._options)},t.prototype.copy=function(){var e=new t(this._options);return e.import(this),e},t.prototype.computeIndex=function(e){var t=this;if(!p.INDICES.has(e))throw new c.InvalidArgumentsGraphError('Graph.computeIndex: unknown "'+e+'" index.');if("structure"===e){var r=this._indices.structure;if(r.computed)return this;r.computed=!0,this._edges.forEach(function(r,n){return a(t,e,n,r)})}return this},t.prototype.clearIndex=function(e){if(!p.INDICES.has(e))throw new c.InvalidArgumentsGraphError('Graph.clearIndex: unknown "'+e+'" index.');if("structure"===e){var t=this._indices.structure;if(!t.computed)return this;(0,p.clearStructureIndex)(this),t.computed=!1}return this},t.prototype.toJSON=function(){return this.export()},t.prototype.toString=function(){var e=this.order>1||0===this.order,t=this.size>1||0===this.size;return"Graph<"+(0,b.prettyPrint)(this.order)+" node"+(e?"s":"")+", "+(0,b.prettyPrint)(this.size)+" edge"+(t?"s":"")+">"},t.prototype.inspect=function(){var e={};this._nodes.forEach(function(t,r){e[r]=t.attributes});var t={};this._edges.forEach(function(e,r){var n=e.undirected?"<->":"->",o="";e.generatedId||(o+="["+r+"]: "),o+="("+e.source+")"+n+"("+e.target+")",t[o]=e.attributes});var r={};for(var n in this)this.hasOwnProperty(n)&&!m.has(n)&&"function"!=typeof this[n]&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,(0,b.privateProperty)(r,"constructor",this.constructor),r},t}(h.EventEmitter);t.default=G,w.forEach(function(e){["add","merge"].forEach(function(t){var r=e.name(t);e.generateKey?G.prototype[r]=function(n,o,i){return u(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),null,n,o,i)}:G.prototype[r]=function(n,o,i,a){return u(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),n,o,i,a)}})}),(0,f.attachAttributesMethods)(G),(0,g.attachEdgeIterationMethods)(G),(0,l.attachNeighborIterationMethods)(G)},function(e,t,r){"use strict";function n(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');
var d=this._edges.get(e);return d.attributes[o]}}function o(e,t,r,n){e.prototype[t]=function(e){if(arguments.length>1){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var o=e,i=arguments[1];if(!this[r](o,i))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+o+'" - "'+i+'").');e=(0,p.getMatchingEdge)(this,o,i,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var a=this._edges.get(e);return a.attributes}}function i(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var d=this._edges.get(e);return d.attributes.hasOwnProperty(o)}}function a(e,t,r,n){e.prototype[t]=function(e,o,i){if(arguments.length>3){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var a=e,d=o;if(o=arguments[2],i=arguments[3],!this[r](a,d))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+d+'").');e=(0,p.getMatchingEdge)(this,a,d,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var u=this._edges.get(e);return u.attributes[o]=i,this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:i}}),this}}function d(e,t,r,n){e.prototype[t]=function(e,o,i){if(arguments.length>3){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var a=e,d=o;if(o=arguments[2],i=arguments[3],!this[r](a,d))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+d+'").');e=(0,p.getMatchingEdge)(this,a,d,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if("function"!=typeof i)throw new f.InvalidArgumentsGraphError("Graph."+t+": updater should be a function.");var u=this._edges.get(e);return u.attributes[o]=i(u.attributes[o]),this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:u.attributes[o]}}),this}}function u(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var d=this._edges.get(e);return delete d.attributes[o],this.emit("edgeAttributesUpdated",{key:e,type:"remove",meta:{name:o}}),this}}function s(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,p.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e),u=d.attributes;return d.attributes=o,this.emit("edgeAttributesUpdated",{key:e,type:"replace",meta:{before:u,after:o}}),this}}function h(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,p.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e);return(0,p.assign)(d.attributes,o),this.emit("edgeAttributesUpdated",{key:e,type:"merge",meta:{data:o}}),this}}function c(e){g.forEach(function(t){var r=t.name,n=t.attacher;n(e,r("Edge"),"hasEdge","mixed"),n(e,r("DirectedEdge"),"hasDirectedEdge","directed"),n(e,r("UndirectedEdge"),"hasUndirectedEdge","undirected")})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachAttributesMethods=c;var p=r(0),f=r(1),g=[{name:function(e){return"get"+e+"Attribute"},attacher:n},{name:function(e){return"get"+e+"Attributes"},attacher:o},{name:function(e){return"has"+e+"Attribute"},attacher:i},{name:function(e){return"set"+e+"Attribute"},attacher:a},{name:function(e){return"update"+e+"Attribute"},attacher:d},{name:function(e){return"remove"+e+"Attribute"},attacher:u},{name:function(e){return"replace"+e+"Attributes"},attacher:s},{name:function(e){return"merge"+e+"Attributes"},attacher:h}]},function(e,t,r){"use strict";function n(e,t,r){var n=e.multi,o=r.undirected,i=r.source,a=r.target,d=e._nodes.get(i),u=e._nodes.get(a),s=o?"undirectedOut":"out",h=o?"undirectedIn":"in",c=void 0;c=n?new Set:t,d[s]=d[s]||Object.create(null),a in d[s]||(d[s][a]=c),n&&d[s][a].add(t),i!==a&&(u[h]=u[h]||Object.create(null),i in u[h]||(u[h][i]=c))}function o(e,t,r){var n=e.multi,o=r.source,i=r.target,a=r.undirected,d=e._nodes.get(o),u=a?"undirectedOut":"out",s=d[u];if(i in s&&(n?s[i].delete(t):delete s[i]),!n){var h=e._nodes.get(i),c=a?"undirectedIn":"in",p=h[c];delete p[o]}}function i(e){e._nodes.forEach(function(e){delete e.in,delete e.out,delete e.undirectedIn,delete e.undirectedOut})}Object.defineProperty(t,"__esModule",{value:!0}),t.updateStructureIndex=n,t.clearEdgeFromStructureIndex=o,t.clearStructureIndex=i;t.INDICES=new Set(["structure"])},function(e,t,r){"use strict";function n(e,t,r){var n=arguments.length>2;if(t&&(!n||r in t)){if(n)return void(t[r]instanceof Set?e.push.apply(e,Array.from(t[r])):e.push(t[r]));for(var o in t)t[o]instanceof Set?e.push.apply(e,Array.from(t[o])):e.push(t[o])}}function o(e,t){var r=0,n=arguments.length>1;if(!e||n&&!(t in e))return r;if(n)return e[t]instanceof Set?e[t].size:+!!e[t];for(var o in e)r+=e[o]instanceof Set?e[o].size:+!!e[o];return r}function i(e,t,r){if(t)if(r){var n=t[r];n&&(n instanceof Set?n.forEach(function(t){return e.add(t)}):e.add(n))}else for(var o in t)t[o]instanceof Set?t[o].forEach(function(t){return e.add(t)}):e.add(t[o])}function a(e,t){if("mixed"===t)return e.size;var r=0;return e._edges.forEach(function(e){!!e.undirected==("undirected"===t)&&r++}),r}function d(e,t){if("mixed"===t)return Array.from(e._edges.keys());var r=[];return e._edges.forEach(function(e,n){!!e.undirected==("undirected"===t)&&r.push(n)}),r}function u(e,t,r,n){e.computeIndex("structure");var i=0,a=e._nodes.get(n);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||(i+=o(a.in)),r&&"out"!==r||(i+=o(a.out))),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||(i+=o(a.undirectedIn)),r&&"out"!==r||(i+=o(a.undirectedOut))),i}function s(e,t,r,o){e.computeIndex("structure");var i=[],a=e._nodes.get(o);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||n(i,a.in),r&&"out"!==r||n(i,a.out)),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||n(i,a.undirectedIn),r&&"out"!==r||n(i,a.undirectedOut)),i}function h(e,t,r,n,o){t.computeIndex("structure");var a=new Set;return(0,v.overBunch)(o,function(o){if(!t.hasNode(o))throw new l.NotFoundGraphError("Graph."+e+': could not find the "'+o+'" node in the graph in the given bunch.');var d=t._nodes.get(o);"mixed"!==r&&"directed"!==r||(n&&"in"!==n||i(a,d.in),n&&"out"!==n||i(a,d.out)),"mixed"!==r&&"undirected"!==r||(n&&"in"!==n||i(a,d.undirectedIn),n&&"out"!==n||i(a,d.undirectedOut))}),Array.from(a.values())}function c(e,t,r,n){e.computeIndex("structure");var i=0,a=e._nodes.get(r);return"mixed"!==t&&"directed"!==t||(i+=o(a.in,n),i+=o(a.out,n)),"mixed"!==t&&"undirected"!==t||(i+=o(a.undirectedIn,n),i+=o(a.undirectedOut,n)),i}function p(e,t,r,o){e.computeIndex("structure");var i=[],a=e._nodes.get(r);return"mixed"!==t&&"directed"!==t||(n(i,a.in,o),n(i,a.out,o)),"mixed"!==t&&"undirected"!==t||(n(i,a.undirectedIn,o),n(i,a.undirectedOut,o)),i}function f(e,t,r){var n=r.type,o=r.direction,i=t?r.counter:r.name;e.prototype[i]=function(){for(var e=arguments.length,r=Array(e),f=0;f<e;f++)r[f]=arguments[f];if(!r.length)return t?a(this,n):d(this,n);if(1===r.length){var g=r[0];if(this.hasNode(g))return t?u(this,n,o,g):s(this,n,o,g);if((0,v.isBunch)(g)){var b=h(i,this,n,o,g);return t?b.length:b}throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+g+'" node in the graph.')}if(2===r.length){var y=r[0],m=r[1];if(!this.hasNode(y))throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+y+'" source node in the graph.');if(!this.hasNode(m))throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+m+'" target node in the graph.');var w=void 0;return w="mixed"===n||"directed"===n?this.hasDirectedEdge(y,m):this.hasUndirectedEdge(y,m),w?t?c(this,n,y,m):p(this,n,y,m):t?0:[]}throw new l.InvalidArgumentsGraphError("Graph."+i+": too many arguments (expecting 0, 1 or 2 and got "+r.length+").")}}function g(e){b.forEach(function(t){f(e,!1,t),f(e,!0,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachEdgeIterationMethods=g;var l=r(1),v=r(0),b=[{name:"edges",counter:"countEdges",type:"mixed"},{name:"inEdges",counter:"countInEdges",type:"directed",direction:"in"},{name:"outEdges",counter:"countOutEdges",type:"directed",direction:"out"},{name:"inboundEdges",counter:"countInboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",counter:"countOutboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",counter:"countDirectedEdges",type:"directed"},{name:"undirectedEdges",counter:"countUndirectedEdges",type:"undirected"}]},function(e,t,r){"use strict";function n(e,t){if(t)for(var r in t)e.add(r)}function o(e,t,r,o){e.computeIndex("structure");var i=new Set,a=e._nodes.get(o);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||n(i,a.in),r&&"out"!==r||n(i,a.out)),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||n(i,a.undirectedIn),r&&"out"!==r||n(i,a.undirectedOut)),i}function i(e,t,r,o,i){t.computeIndex("structure");var a=new Set;return(0,s.overBunch)(i,function(i){if(!t.hasNode(i))throw new u.NotFoundGraphError("Graph."+e+': could not find the "'+i+'" node in the graph in the given bunch.');var d=t._nodes.get(i);"mixed"!==r&&"directed"!==r||(o&&"in"!==o||n(a,d.in),o&&"out"!==o||n(a,d.out)),"mixed"!==r&&"undirected"!==r||(o&&"in"!==o||n(a,d.undirectedIn),o&&"out"!==o||n(a,d.undirectedOut))}),a}function a(e,t,r){var n=r.type,a=r.direction,d=t?r.counter:r.name;e.prototype[d]=function(){for(var e=arguments.length,r=Array(e),h=0;h<e;h++)r[h]=arguments[h];if(2===r.length){var c=r[0],p=r[1];if(t)throw new u.InvalidArgumentsGraphError("Graph."+d+": invalid arguments.");if(!this.hasNode(c))throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+c+'" node in the graph.');if(!this.hasNode(p))throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+p+'" node in the graph.');var f=o(this,n,a,c);return f.has(p)}if(1===r.length){var g=r[0];if(this.hasNode(g)){var l=o(this,n,a,g);return t?l.size:Array.from(l)}if((0,s.isBunch)(g)){var v=i(d,this,n,a,g);return t?v.size:Array.from(v)}throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+g+'" node in the graph.')}throw new u.InvalidArgumentsGraphError("Graph."+d+": invalid number of arguments (expecting 1 or 2 and got "+r.length+").")}}function d(e){h.forEach(function(t){a(e,!1,t),a(e,!0,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachNeighborIterationMethods=d;var u=r(1),s=r(0),h=[{name:"neighbors",counter:"countNeighbors",type:"mixed"},{name:"inNeighbors",counter:"countInNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",counter:"countOutNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",counter:"countInboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",counter:"countOutboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",counter:"countDirectedNeighbors",type:"directed"},{name:"undirectedNeighbors",counter:"countUndirectedNeighbors",type:"undirected"}]},function(e,t,r){"use strict";function n(e,t){var r={key:e};return Object.keys(t.attributes).length&&(r.attributes=t.attributes),r}function o(e,t){var r={key:e,source:t.source,target:t.target};return Object.keys(t.attributes).length&&(r.attributes=t.attributes),t.undirected&&(r.undirected=!0),r}function i(e){return(0,d.isPlainObject)(e)?"key"in e?"attributes"in e&&(!(0,d.isPlainObject)(e.attributes)||null===e.attributes)?"invalid-attributes":null:"no-key":"not-object"}function a(e){return(0,d.isPlainObject)(e)?"source"in e?"target"in e?"attributes"in e&&(!(0,d.isPlainObject)(e.attributes)||null===e.attributes)?"invalid-attributes":"undirected"in e&&"boolean"!=typeof e.undirected?"invalid-undirected":null:"no-target":"no-source":"not-object"}Object.defineProperty(t,"__esModule",{value:!0}),t.serializeNode=n,t.serializeEdge=o,t.validateSerializedNode=i,t.validateSerializedEdge=a;var d=r(0)},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,o,d,u,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(r=this._events[e],a(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:d=Array.prototype.slice.call(arguments,1),r.apply(this,d)}else if(i(r))for(d=Array.prototype.slice.call(arguments,1),s=r.slice(),o=s.length,u=0;u<o;u++)s[u].apply(this,d);return!0},r.prototype.addListener=function(e,t){var o;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(o=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,o&&o>0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,o,a,d;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(r)){for(d=a;d-- >0;)if(r[d]===t||r[d].listener&&r[d].listener===t){o=d;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function d(e){e.from=function(t,r){var n=new e(r);return n.import(t),n}}var u=r(0),s=r(2),h=n(s),c=r(1),p=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({type:"directed"},r)))}return a(t,e),t}(h.default),f=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({type:"undirected"},r)))}return a(t,e),t}(h.default),g=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({multi:!0,type:"directed"},r)))}return a(t,e),t}(h.default),l=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({multi:!0,type:"undirected"},r)))}return a(t,e),t}(h.default);d(h.default),d(p),d(f),d(g),d(l),h.default.Graph=h.default,h.default.DirectedGraph=p,h.default.UndirectedGraph=f,h.default.MultiDirectedGraph=g,h.default.MultiUndirectedGraph=l,h.default.InvalidArgumentsGraphError=c.InvalidArgumentsGraphError,h.default.NotFoundGraphError=c.NotFoundGraphError,h.default.UsageGraphError=c.UsageGraphError,e.exports=h.default}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.graphology=t():e.graphology=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";function n(e){e=e||{};for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];for(var o=0,i=r.length;o<i;o++)if(r[o])for(var a in r[o])e[a]=r[o][a];return e}function o(){var e=new Map;return e.set=function(e,t){return e=""+e,Map.prototype.set.call(this,e,t)},e.get=function(e){return e=""+e,Map.prototype.get.call(this,e)},e.has=function(e){return e=""+e,Map.prototype.has.call(this,e)},e}function i(e,t){for(var r=new Array(e),n=0,o=void 0;o=t.next(),!o.done;)r[n++]=o.value;return r}function a(e,t,r,n){if("mixed"===n)return a(e,t,r,"directed")||a(e,t,r,"undirected");var o=e._nodes.get(t),i="directed"===n?o.out:o.undirectedOut;return i&&(i[r]||"undirected"!==n)||(i=o.undirectedIn),i&&i[r]?i[r]:null}function d(e){return!!e&&"object"===("undefined"==typeof e?"undefined":y(e))&&(Array.isArray(e)||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set||!(e instanceof Date)&&!(e instanceof RegExp))}function u(e){return!!e&&"object"===("undefined"==typeof e?"undefined":y(e))&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode}function s(e){return!(!e||"object"!==("undefined"==typeof e?"undefined":y(e))||Array.isArray(e)||e instanceof Date||e instanceof RegExp||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set)}function h(e,t){if(Array.isArray(e))for(var r=0,n=e.length;r<n;r++){var o=t(e[r],null)===!1;if(o)break}else if("function"==typeof e.forEach)for(var i=e.entries(),a=!1,d=void 0;d=i.next();){var u=d,s=u.value,h=u.done;if(h)break;var c=s[0],p=s[1];if(a=p===c?t(p,null)===!1:t(c,p)===!1)break}else for(var f in e){var g=e[f],l=t(f,g);if(l)break}}function c(e){for(var t=""+e,r="",n=0,o=t.length;n<o;n++){var i=o-n-1;r=t[i]+r,(n-2)%3||n===o-1||(r=","+r)}return r}function p(e,t,r){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:r})}function f(e,t,r){var n={enumerable:!0,configurable:!1};"function"==typeof r?n.get=r:(n.value=r,n.writable=!1),Object.defineProperty(e,t,n)}function g(){for(var e,t=0;t<16;t++)0===(3&t)&&(e=4294967296*Math.random()),m[t]=e>>>((3&t)<<3)&255;return m}function l(){var e=g();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}function v(e){for(var t=[0],r=0,n=e.length;r<n;r++){for(var o=e[r],i=0,a=t.length;i<a;i++)o+=t[i]<<8,t[i]=o%62,o=o/62|0;for(;o>0;)t.push(o%62),o=o/62|0}for(var d="",u=0,s=e.length;0===e[u]&&u<s-1;u++)d+=w[0];for(var h=t.length-1;h>=0;h--)d+=w[t[h]];for(;d.length<22;)d+="0";return d}function b(){var e=l();return v(e)}Object.defineProperty(t,"__esModule",{value:!0});var y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.assign=n,t.createInternalMap=o,t.consumeIterator=i,t.getMatchingEdge=a,t.isBunch=d,t.isGraph=u,t.isPlainObject=s,t.overBunch=h,t.prettyPrint=c,t.privateProperty=p,t.readOnlyProperty=f,t.uuid=b;var m=new Uint8Array(16),w="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=t.GraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this));return a.name="GraphError",a.message=r||"",a.data=i||{},a}return i(t,e),t}(Error);t.InvalidArgumentsGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a),t.NotFoundGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a),t.UsageGraphError=function(e){function t(r,i){n(this,t);var a=o(this,e.call(this,r,i));return a.name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(a,t.prototype.constructor),a}return i(t,e),t}(a)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function a(e,t){if("structure"===t){var r=e._indices.structure;if(!r.computed)return e;for(var n=arguments.length,o=Array(n>2?n-2:0),i=2;i<n;i++)o[i-2]=arguments[i];var a=o[0],d=o[1];(0,p.updateStructureIndex)(e,a,d)}return e}function d(e,t,r,n){if("structure"===t){var o=e._indices.structure;if(!o.computed)return e;(0,p.clearEdgeFromStructureIndex)(e,r,n)}return e}function u(e,t,r,n,o,i,d,u,s){if(!o&&"undirected"===e.type)throw new c.UsageGraphError("Graph."+t+": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.");if(o&&"directed"===e.type)throw new c.UsageGraphError("Graph."+t+": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.");if(s&&!(0,b.isPlainObject)(s))throw new c.InvalidArgumentsGraphError("Graph."+t+': invalid attributes. Expecting an object but got "'+s+'"');d=""+d,u=""+u;var h=!1,p=!1;if(!e.hasNode(d)){if(!r)throw new c.NotFoundGraphError("Graph."+t+': source node "'+d+'" not found.');h=!0}if(!e.hasNode(u)){if(!r)throw new c.NotFoundGraphError("Graph."+t+': target node "'+u+'" not found.');p=!0}if(!e.allowSelfLoops&&d===u)throw new c.UsageGraphError("Graph."+t+': source & target are the same ("'+d+"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.");n&&(i=e._options.edgeKeyGenerator({undirected:o,source:d,target:u,attributes:s||{}}));var f=null;if(e.hasEdge(i)){if(!r)throw new c.UsageGraphError("Graph."+t+': the "'+i+'" edge already exists in the graph.');f=i}if(!e.multi&&(o?e.hasUndirectedEdge(d,u):e.hasDirectedEdge(d,u))){if(!r)throw new c.UsageGraphError("Graph."+t+': an edge linking "'+d+'" to "'+u+"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.");f=(0,b.getMatchingEdge)(e,d,u,o?"undirected":"directed")}if(s=(0,b.assign)({},e._options.defaultEdgeAttributes,s),f){if(e.source(f)!==d||e.target(f)!==u)throw new c.UsageGraphError("Graph."+t+': inconsitency detected when attempting to merge the "'+i+'" edge with "'+d+'" source & "'+u+'" target vs. ('+e.source(f)+", "+e.target(f)+").");return e.mergeEdgeAttributes(f,s),f}h&&e.addNode(d),p&&e.addNode(u);var g={attributes:s,source:d,target:u};o&&(g.undirected=!0),n&&(g.generatedId=!0),e._edges.set(i,g);var l=e._nodes.get(d),v=e._nodes.get(u);return d===u?o?l.undirectedSelfLoops++:l.directedSelfLoops++:o?(l.undirectedDegree++,v.undirectedDegree++):(l.outDegree++,v.inDegree++),a(e,"structure",i,g),e.emit("edgeAdded",{key:i,source:d,target:u,attributes:s,undirected:o}),i}function s(e,t,r,n){var o=[];if(n){if(!(0,b.isBunch)(n))throw new c.InvalidArgumentsGraphError("Graph."+t+": invalid bunch.");(0,b.overBunch)(n,function(n){if(!e.hasEdge(n))throw new c.NotFoundGraphError("Graph."+t+': could not find the "'+n+'" edge from the bunch in the graph.');r&&!r(n)||o.push(n)})}else o="exportEdges"===t?e.edges():"exportDirectedEdges"===t?e.directedEdges():e.undirectedEdges();for(var i=new Array(o.length),a=0,d=o.length;a<d;a++)i[a]=e.exportEdge(o[a]);return i}Object.defineProperty(t,"__esModule",{value:!0});var h=r(8),c=r(1),p=r(4),f=r(3),g=r(5),l=r(6),v=r(7),b=r(0),y=new Set(["directed","undirected","mixed"]),m=new Set(["domain","_events","_eventsCount","_maxListeners"]),w=[{name:function(e){return e+"Edge"},generateKey:!0},{name:function(e){return e+"DirectedEdge"},generateKey:!0,type:"directed"},{name:function(e){return e+"UndirectedEdge"},generateKey:!0,type:"undirected"},{name:function(e){return e+"EdgeWithKey"}},{name:function(e){return e+"DirectedEdgeWithKey"},type:"directed"},{name:function(e){return e+"UndirectedEdgeWithKey"},type:"undirected"}],E={allowSelfLoops:!0,defaultEdgeAttributes:{},defaultNodeAttributes:{},edgeKeyGenerator:b.uuid,multi:!1,type:"mixed"},G=function(e){function t(r){n(this,t);var i=o(this,e.call(this));if(r=(0,b.assign)({},E,r),Object.freeze(r),"function"!=typeof r.edgeKeyGenerator)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'edgeKeyGenerator' option. Expecting a function but got \""+r.edgeKeyGenerator+'".');if("boolean"!=typeof r.multi)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \""+r.multi+'".');if(!y.has(r.type))throw new c.InvalidArgumentsGraphError('Graph.constructor: invalid \'type\' option. Should be one of "mixed", "directed" or "undirected" but got "'+r.type+'".');if("boolean"!=typeof r.allowSelfLoops)throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \""+r.allowSelfLoops+'".');if(!(0,b.isPlainObject)(r.defaultEdgeAttributes))throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultEdgeAttributes' option. Expecting a plain object but got \""+r.defaultEdgeAttributes+'".');if(!(0,b.isPlainObject)(r.defaultNodeAttributes))throw new c.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultNodeAttributes' option. Expecting a plain object but got \""+r.defaultNodeAttributes+'".');(0,b.privateProperty)(i,"_attributes",{}),(0,b.privateProperty)(i,"_nodes",(0,b.createInternalMap)()),(0,b.privateProperty)(i,"_edges",(0,b.createInternalMap)()),(0,b.privateProperty)(i,"_indices",{structure:{lazy:r.indices&&r.indices.structure&&r.indices.structure.lazy||!1,computed:!1}}),(0,b.privateProperty)(i,"_options",r),m.forEach(function(e){return(0,b.privateProperty)(i,e,i[e])}),(0,b.readOnlyProperty)(i,"order",function(){return i._nodes.size}),(0,b.readOnlyProperty)(i,"size",function(){return i._edges.size}),(0,b.readOnlyProperty)(i,"multi",i._options.multi),(0,b.readOnlyProperty)(i,"type",i._options.type),(0,b.readOnlyProperty)(i,"allowSelfLoops",i._options.allowSelfLoops);for(var a in i._indices){var d=i._indices[a];d.lazy||(d.computed=!0)}return i}return i(t,e),t.prototype.hasNode=function(e){return this._nodes.has(e)},t.prototype.hasDirectedEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)&&this.directed(r)}if(2===arguments.length){if(this.computeIndex("structure"),!this.hasNode(e)||!this.hasNode(t))return!1;var n=this._nodes.get(e),o=n.out;if(!o)return!1;var i=o[t];return!!i&&(this.multi?!!i.size:!!i)}throw new c.InvalidArgumentsGraphError("Graph.hasDirectedEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.hasUndirectedEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)&&this.undirected(r)}if(2===arguments.length){if(this.computeIndex("structure"),!this.hasNode(e)||!this.hasNode(t))return!1;var n=this._nodes.get(e),o=n.undirectedOut,i=void 0;return o&&(i=o[t]),o=n.undirectedIn,!i&&o&&(i=o[t]),!!i&&(this.multi?!!i.size:!!i)}throw new c.InvalidArgumentsGraphError("Graph.hasDirectedEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.hasEdge=function(e,t){if(1===arguments.length){var r=e;return this._edges.has(r)}if(2===arguments.length)return this.hasDirectedEdge(e,t)||this.hasUndirectedEdge(e,t);throw new c.InvalidArgumentsGraphError("Graph.hasEdge: invalid arity ("+arguments.length+", instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.")},t.prototype.inDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.inDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.inDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?r.directedSelfLoops:0;return r.inDegree+n},t.prototype.outDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.outDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.outDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?r.directedSelfLoops:0;return r.outDegree+n},t.prototype.directedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.directedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.directedDegree: could not find the "'+e+'" node in the graph.');return this.inDegree(e,t)+this.outDegree(e,t)},t.prototype.undirectedDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.undirectedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.undirectedDegree: could not find the "'+e+'" node in the graph.');var r=this._nodes.get(e),n=t?2*r.undirectedSelfLoops:0;return r.undirectedDegree+n},t.prototype.degree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new c.InvalidArgumentsGraphError('Graph.degree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.degree: could not find the "'+e+'" node in the graph.');return this.directedDegree(e,t)+this.undirectedDegree(e,t)},t.prototype.source=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.source: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).source},t.prototype.target=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.target: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).target},t.prototype.extremities=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.extremities: could not find the "'+e+'" edge in the graph.');return[this._edges.get(e).source,this._edges.get(e).target]},t.prototype.opposite=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.opposite: could not find the "'+e+'" node in the graph.');if(!this.hasEdge(t))throw new c.NotFoundGraphError('Graph.opposite: could not find the "'+t+'" edge in the graph.');var r=this.extremities(t),n=r[0],o=r[1];if(e!==n&&e!==o)throw new c.NotFoundGraphError('Graph.opposite: the "'+e+'" node is not attached to the "'+t+'" edge ('+n+", "+o+").");return e===n?o:n},t.prototype.undirected=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.undirected: could not find the "'+e+'" edge in the graph.');return!!this._edges.get(e).undirected},t.prototype.directed=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.directed: could not find the "'+e+'" edge in the graph.');return!this._edges.get(e).undirected},t.prototype.selfLoop=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.selfLoop: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return t.source===t.target},t.prototype.addNode=function(e,t){if(t&&!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError('Graph.addNode: invalid attributes. Expecting an object but got "'+t+'"');if(t=(0,b.assign)({},this._options.defaultNodeAttributes,t),this.hasNode(e))throw new c.UsageGraphError('Graph.addNode: the "'+e+'" node already exist in the graph.');var r={attributes:t};return this.allowSelfLoops&&("mixed"!==this.type&&"directed"!==this.type||(r.directedSelfLoops=0),"mixed"!==this.type&&"undirected"!==this.type||(r.undirectedSelfLoops=0)),"mixed"!==this.type&&"directed"!==this.type||(r.inDegree=0,r.outDegree=0),"mixed"!==this.type&&"undirected"!==this.type||(r.undirectedDegree=0),this._nodes.set(e,r),this.emit("nodeAdded",{key:e,attributes:t}),e},t.prototype.mergeNode=function(e,t){return this.hasNode(e)?(t&&this.mergeNodeAttributes(e,t),e):this.addNode(e,t)},t.prototype.addNodesFrom=function(e){var t=this;if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError('Graph.addNodesFrom: invalid bunch provided ("'+e+'").');return(0,b.overBunch)(e,function(e,r){t.addNode(e,r)}),this},t.prototype.dropNode=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.dropNode: could not find the "'+e+'" node in the graph.');for(var t=this.edges(e),r=0,n=t.length;r<n;r++)this.dropEdge(t[r]);var o=this._nodes.get(e);this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:o.attributes})},t.prototype.dropEdge=function(e){if(arguments.length>1){var t=arguments[0],r=arguments[1];if(!this.hasNode(t))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" source node in the graph.');if(!this.hasNode(r))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+r+'" target node in the graph.');if(!this.hasEdge(t,r))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" -> "'+r+'" edge in the graph.');e=(0,b.getMatchingEdge)(this,t,r,this.type)}else if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.dropEdge: could not find the "'+e+'" edge in the graph.');var n=this._edges.get(e);this._edges.delete(e);var o=n.source,i=n.target,a=n.attributes,u=n.undirected,s=void 0!==u&&u,h=this._nodes.get(o),p=this._nodes.get(i);return o===i?h.selfLoops--:s?(h.undirectedDegree--,p.undirectedDegree--):(h.outDegree--,p.inDegree--),d(this,"structure",e,n),this.emit("edgeDropped",{key:e,attributes:a,source:o,target:i,undirected:s}),this},t.prototype.dropNodes=function(e){var t=this;if(!arguments.length)return this.clear();if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.dropNodes: invalid bunch.");return(0,b.overBunch)(e,function(e){t.dropNode(e)}),this},t.prototype.dropEdges=function(e){var t=this;if(!arguments.length){this._edges=(0,b.createInternalMap)(),this.clearIndex("structure");var r=this._indices.structure;return r.lazy||(r.computed=!0),this}if(2===arguments.length){var n=arguments[0],o=arguments[1];e=this.edges(n,o)}if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.dropEdges: invalid bunch.");return(0,b.overBunch)(e,function(e){t.dropEdge(e)}),this},t.prototype.clear=function(){this._edges=(0,b.createInternalMap)(),this._nodes=(0,b.createInternalMap)();for(var e in this._indices){var t=this._indices[e];t.lazy&&(t.computed=!1)}this.emit("cleared")},t.prototype.getAttribute=function(e){return this._attributes[e]},t.prototype.getAttributes=function(){return this._attributes},t.prototype.hasAttribute=function(e){return this._attributes.hasOwnProperty(e)},t.prototype.setAttribute=function(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",meta:{name:e,value:t}}),this},t.prototype.updateAttribute=function(e,t){if("function"!=typeof t)throw new c.InvalidArgumentsGraphError("Graph.updateAttribute: updater should be a function.");return this._attributes[e]=t(this._attributes[e]),this.emit("attributesUpdated",{type:"set",meta:{name:e,value:this._attributes[e]}}),this},t.prototype.removeAttribute=function(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",meta:{name:e}}),this},t.prototype.replaceAttributes=function(e){if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.replaceAttributes: provided attributes are not a plain object.");var t=this._attributes;return this._attributes=e,this.emit("attributesUpdated",{type:"replace",meta:{before:t,after:e}}),this},t.prototype.mergeAttributes=function(e){if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.mergeAttributes: provided attributes are not a plain object.");return this._attributes=(0,b.assign)(this._attributes,e),this.emit("attributesUpdated",{type:"merge",meta:{data:this._attributes}}),this},t.prototype.getNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.getNodeAttribute: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes[t]},t.prototype.getNodeAttributes=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.getNodeAttributes: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes},t.prototype.hasNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.hasNodeAttribute: could not find the "'+e+'" node in the graph.');return this._nodes.get(e).attributes.hasOwnProperty(t)},t.prototype.setNodeAttribute=function(e,t,r){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.setNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new c.InvalidArgumentsGraphError("Graph.setNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or value, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");return this._nodes.get(e).attributes[t]=r,this.emit("nodeAttributesUpdated",{key:e,type:"set",meta:{name:t,value:r}}),this},t.prototype.updateNodeAttribute=function(e,t,r){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.updateNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new c.InvalidArgumentsGraphError("Graph.updateNodeAttribute: not enough arguments. Either you forgot to pass the attribute's name or updater, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.");if("function"!=typeof r)throw new c.InvalidArgumentsGraphError("Graph.updateAttribute: updater should be a function.");var n=this._nodes.get(e).attributes;return n[t]=r(n[t]),this.emit("nodeAttributesUpdated",{key:e,type:"set",meta:{name:t,value:n[t]}}),this},t.prototype.removeNodeAttribute=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.hasNodeAttribute: could not find the "'+e+'" node in the graph.');return delete this._nodes.get(e).attributes[t],this.emit("nodeAttributesUpdated",{key:e,type:"remove",meta:{name:t}}),this},t.prototype.replaceNodeAttributes=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.replaceNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError("Graph.replaceNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e),n=r.attributes;return r.attributes=t,this.emit("nodeAttributesUpdated",{key:e,type:"replace",meta:{before:n,after:t}}),this},t.prototype.mergeNodeAttributes=function(e,t){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.mergeNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,b.isPlainObject)(t))throw new c.InvalidArgumentsGraphError("Graph.mergeNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e);return(0,b.assign)(r.attributes,t),this.emit("nodeAttributesUpdated",{key:e,type:"merge",meta:{data:t}}),this},t.prototype.nodes=function(){return(0,b.consumeIterator)(this._nodes.size,this._nodes.keys())},t.prototype.exportNode=function(e){if(!this.hasNode(e))throw new c.NotFoundGraphError('Graph.exportNode: could not find the "'+e+'" node in the graph.');var t=this._nodes.get(e);return(0,v.serializeNode)(e,t)},t.prototype.exportEdge=function(e){if(!this.hasEdge(e))throw new c.NotFoundGraphError('Graph.exportEdge: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return(0,v.serializeEdge)(e,t)},t.prototype.exportNodes=function(e){var t=this,r=[];if(arguments.length){if(!(0,b.isBunch)(e))throw new c.InvalidArgumentsGraphError("Graph.exportNodes: invalid bunch.");(0,b.overBunch)(e,function(e){if(!t.hasNode(e))throw new c.NotFoundGraphError('Graph.exportNodes: could not find the "'+e+'" node from the bunch in the graph.');r.push(e)})}else r=this.nodes();for(var n=new Array(r.length),o=0,i=r.length;o<i;o++)n[o]=this.exportNode(r[o]);return n},t.prototype.exportEdges=function(e){return s(this,"exportEdges",null,e)},t.prototype.exportDirectedEdges=function(e){var t=this;return s(this,"exportDirectedEdges",function(e){return t.directed(e)},e)},t.prototype.exportUndirectedEdges=function(e){var t=this;return s(this,"exportUndirectedEdges",function(e){return t.undirected(e)},e)},t.prototype.export=function(){return{attributes:this.getAttributes(),nodes:this.exportNodes(),edges:this.exportEdges()}},t.prototype.importNode=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(0,v.validateSerializedNode)(e);if(r){if("not-object"===r)throw new c.InvalidArgumentsGraphError('Graph.importNode: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if("no-key"===r)throw new c.InvalidArgumentsGraphError("Graph.importNode: no key provided.");if("invalid-attributes"===r)throw new c.InvalidArgumentsGraphError("Graph.importNode: invalid attributes. Attributes should be a plain object, null or omitted.")}var n=e.key,o=e.attributes,i=void 0===o?{}:o;return t?this.mergeNode(n,i):this.addNode(n,i),this},t.prototype.importEdge=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(0,v.validateSerializedEdge)(e);if(r){if("not-object"===r)throw new c.InvalidArgumentsGraphError('Graph.importEdge: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if("no-source"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: missing souce.");if("no-target"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: missing target");if("invalid-attributes"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if("invalid-undirected"===r)throw new c.InvalidArgumentsGraphError("Graph.importEdge: invalid undirected. Undirected should be boolean or omitted.")}var n=e.source,o=e.target,i=e.attributes,a=void 0===i?{}:i,d=e.undirected,u=void 0!==d&&d,s=void 0;return"key"in e?(s=t?u?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:u?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,s.call(this,e.key,n,o,a)):(s=t?u?this.mergeUndirectedEdge:this.mergeDirectedEdge:u?this.addUndirectedEdge:this.addDirectedEdge,s.call(this,n,o,a)),this},t.prototype.importNodes=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))throw new c.InvalidArgumentsGraphError("Graph.importNodes: invalid argument. Expecting an array.");for(var r=0,n=e.length;r<n;r++)this.importNode(e[r],t);return this},t.prototype.importEdges=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!Array.isArray(e))throw new c.InvalidArgumentsGraphError("Graph.importEdges: invalid argument. Expecting an array.");for(var r=0,n=e.length;r<n;r++)this.importEdge(e[r],t);return this},t.prototype.import=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if((0,b.isGraph)(e))return this.import(e.export(),t),this;if(!(0,b.isPlainObject)(e))throw new c.InvalidArgumentsGraphError("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!(0,b.isPlainObject)(e.attributes))throw new c.InvalidArgumentsGraphError("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}return e.nodes&&this.importNodes(e.nodes,t),e.edges&&this.importEdges(e.edges,t),this},t.prototype.emptyCopy=function(){return new t(this._options)},t.prototype.copy=function(){var e=new t(this._options);return e.import(this),e},t.prototype.computeIndex=function(e){var t=this;if(!p.INDICES.has(e))throw new c.InvalidArgumentsGraphError('Graph.computeIndex: unknown "'+e+'" index.');if("structure"===e){var r=this._indices.structure;if(r.computed)return this;r.computed=!0,this._edges.forEach(function(r,n){return a(t,e,n,r)})}return this},t.prototype.clearIndex=function(e){if(!p.INDICES.has(e))throw new c.InvalidArgumentsGraphError('Graph.clearIndex: unknown "'+e+'" index.');if("structure"===e){var t=this._indices.structure;if(!t.computed)return this;(0,p.clearStructureIndex)(this),t.computed=!1}return this},t.prototype.toJSON=function(){return this.export()},t.prototype.toString=function(){var e=this.order>1||0===this.order,t=this.size>1||0===this.size;return"Graph<"+(0,b.prettyPrint)(this.order)+" node"+(e?"s":"")+", "+(0,b.prettyPrint)(this.size)+" edge"+(t?"s":"")+">"},t.prototype.inspect=function(){var e={};this._nodes.forEach(function(t,r){e[r]=t.attributes});var t={};this._edges.forEach(function(e,r){var n=e.undirected?"<->":"->",o="";e.generatedId||(o+="["+r+"]: "),o+="("+e.source+")"+n+"("+e.target+")",t[o]=e.attributes});var r={};for(var n in this)this.hasOwnProperty(n)&&!m.has(n)&&"function"!=typeof this[n]&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,(0,b.privateProperty)(r,"constructor",this.constructor),r},t}(h.EventEmitter);t.default=G,w.forEach(function(e){["add","merge"].forEach(function(t){var r=e.name(t);e.generateKey?G.prototype[r]=function(n,o,i){return u(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),null,n,o,i)}:G.prototype[r]=function(n,o,i,a){return u(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),n,o,i,a)}})}),(0,f.attachAttributesMethods)(G),(0,g.attachEdgeIterationMethods)(G),(0,l.attachNeighborIterationMethods)(G)},function(e,t,r){"use strict";function n(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');
e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var d=this._edges.get(e);return d.attributes[o]}}function o(e,t,r,n){e.prototype[t]=function(e){if(arguments.length>1){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var o=e,i=arguments[1];if(!this[r](o,i))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+o+'" - "'+i+'").');e=(0,p.getMatchingEdge)(this,o,i,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var a=this._edges.get(e);return a.attributes}}function i(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var d=this._edges.get(e);return d.attributes.hasOwnProperty(o)}}function a(e,t,r,n){e.prototype[t]=function(e,o,i){if(arguments.length>3){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var a=e,d=o;if(o=arguments[2],i=arguments[3],!this[r](a,d))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+d+'").');e=(0,p.getMatchingEdge)(this,a,d,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var u=this._edges.get(e);return u.attributes[o]=i,this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:i}}),this}}function d(e,t,r,n){e.prototype[t]=function(e,o,i){if(arguments.length>3){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var a=e,d=o;if(o=arguments[2],i=arguments[3],!this[r](a,d))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+d+'").');e=(0,p.getMatchingEdge)(this,a,d,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if("function"!=typeof i)throw new f.InvalidArgumentsGraphError("Graph."+t+": updater should be a function.");var u=this._edges.get(e);return u.attributes[o]=i(u.attributes[o]),this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:u.attributes[o]}}),this}}function u(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');var d=this._edges.get(e);return delete d.attributes[o],this.emit("edgeAttributesUpdated",{key:e,type:"remove",meta:{name:o}}),this}}function s(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,p.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e),u=d.attributes;return d.attributes=o,this.emit("edgeAttributesUpdated",{key:e,type:"replace",meta:{before:u,after:o}}),this}}function h(e,t,r,n){e.prototype[t]=function(e,o){if(arguments.length>2){if(this.multi)throw new f.UsageGraphError("Graph."+t+": cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.");var i=e,a=o;if(o=arguments[2],!this[r](i,a))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+i+'" - "'+a+'").');e=(0,p.getMatchingEdge)(this,i,a,n)}if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,p.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e);return(0,p.assign)(d.attributes,o),this.emit("edgeAttributesUpdated",{key:e,type:"merge",meta:{data:o}}),this}}function c(e){g.forEach(function(t){var r=t.name,n=t.attacher;n(e,r("Edge"),"hasEdge","mixed"),n(e,r("DirectedEdge"),"hasDirectedEdge","directed"),n(e,r("UndirectedEdge"),"hasUndirectedEdge","undirected")})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachAttributesMethods=c;var p=r(0),f=r(1),g=[{name:function(e){return"get"+e+"Attribute"},attacher:n},{name:function(e){return"get"+e+"Attributes"},attacher:o},{name:function(e){return"has"+e+"Attribute"},attacher:i},{name:function(e){return"set"+e+"Attribute"},attacher:a},{name:function(e){return"update"+e+"Attribute"},attacher:d},{name:function(e){return"remove"+e+"Attribute"},attacher:u},{name:function(e){return"replace"+e+"Attributes"},attacher:s},{name:function(e){return"merge"+e+"Attributes"},attacher:h}]},function(e,t,r){"use strict";function n(e,t,r){var n=e.multi,o=r.undirected,i=r.source,a=r.target,d=e._nodes.get(i),u=e._nodes.get(a),s=o?"undirectedOut":"out",h=void 0;if(h=n?new Set:t,d[s]=d[s]||Object.create(null),a in d[s]||(d[s][a]=h),n&&d[s][a].add(t),i!==a){var c=o?"undirectedIn":"in";u[c]=u[c]||Object.create(null),i in u[c]||(u[c][i]=h)}}function o(e,t,r){var n=e.multi,o=r.source,i=r.target,a=r.undirected,d=e._nodes.get(o),u=a?"undirectedOut":"out",s=d[u];if(i in s&&(n?s[i].delete(t):delete s[i]),!n){var h=e._nodes.get(i),c=a?"undirectedIn":"in",p=h[c];delete p[o]}}function i(e){e._nodes.forEach(function(e){delete e.in,delete e.out,delete e.undirectedIn,delete e.undirectedOut})}Object.defineProperty(t,"__esModule",{value:!0}),t.updateStructureIndex=n,t.clearEdgeFromStructureIndex=o,t.clearStructureIndex=i;t.INDICES=new Set(["structure"])},function(e,t,r){"use strict";function n(e,t,r){var n=arguments.length>2;if(t&&(!n||r in t)){if(n)return void(t[r]instanceof Set?e.push.apply(e,(0,v.consumeIterator)(t[r].size,t[r].values())):e.push(t[r]));for(var o in t)t[o]instanceof Set?e.push.apply(e,(0,v.consumeIterator)(t[o].size,t[o].values())):e.push(t[o])}}function o(e,t){var r=0,n=arguments.length>1;if(!e||n&&!(t in e))return r;if(n)return e[t]instanceof Set?e[t].size:+!!e[t];for(var o in e)r+=e[o]instanceof Set?e[o].size:+!!e[o];return r}function i(e,t,r){if(t)if(r){var n=t[r];n&&(n instanceof Set?n.forEach(function(t){return e.add(t)}):e.add(n))}else for(var o in t)t[o]instanceof Set?t[o].forEach(function(t){return e.add(t)}):e.add(t[o])}function a(e,t){if("mixed"===t)return e.size;var r=0;return e._edges.forEach(function(e){!!e.undirected==("undirected"===t)&&r++}),r}function d(e,t){if("mixed"===t)return(0,v.consumeIterator)(e._edges.size,e._edges.keys());var r=[];return e._edges.forEach(function(e,n){!!e.undirected==("undirected"===t)&&r.push(n)}),r}function u(e,t,r,n){e.computeIndex("structure");var i=0,a=e._nodes.get(n);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||(i+=o(a.in)),r&&"out"!==r||(i+=o(a.out))),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||(i+=o(a.undirectedIn)),r&&"out"!==r||(i+=o(a.undirectedOut))),i}function s(e,t,r,o){e.computeIndex("structure");var i=[],a=e._nodes.get(o);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||n(i,a.in),r&&"out"!==r||n(i,a.out)),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||n(i,a.undirectedIn),r&&"out"!==r||n(i,a.undirectedOut)),i}function h(e,t,r,n,o){t.computeIndex("structure");var a=new Set;return(0,v.overBunch)(o,function(o){if(!t.hasNode(o))throw new l.NotFoundGraphError("Graph."+e+': could not find the "'+o+'" node in the graph in the given bunch.');var d=t._nodes.get(o);"mixed"!==r&&"directed"!==r||(n&&"in"!==n||i(a,d.in),n&&"out"!==n||i(a,d.out)),"mixed"!==r&&"undirected"!==r||(n&&"in"!==n||i(a,d.undirectedIn),n&&"out"!==n||i(a,d.undirectedOut))}),(0,v.consumeIterator)(a.size,a.values())}function c(e,t,r,n){e.computeIndex("structure");var i=0,a=e._nodes.get(r);return"mixed"!==t&&"directed"!==t||(i+=o(a.in,n),i+=o(a.out,n)),"mixed"!==t&&"undirected"!==t||(i+=o(a.undirectedIn,n),i+=o(a.undirectedOut,n)),i}function p(e,t,r,o){e.computeIndex("structure");var i=[],a=e._nodes.get(r);return"mixed"!==t&&"directed"!==t||(n(i,a.in,o),n(i,a.out,o)),"mixed"!==t&&"undirected"!==t||(n(i,a.undirectedIn,o),n(i,a.undirectedOut,o)),i}function f(e,t,r){var n=r.type,o=r.direction,i=t?r.counter:r.name;e.prototype[i]=function(){for(var e=arguments.length,r=Array(e),f=0;f<e;f++)r[f]=arguments[f];if(!r.length)return t?a(this,n):d(this,n);if(1===r.length){var g=r[0];if(this.hasNode(g))return t?u(this,n,o,g):s(this,n,o,g);if((0,v.isBunch)(g)){var b=h(i,this,n,o,g);return t?b.length:b}throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+g+'" node in the graph.')}if(2===r.length){var y=r[0],m=r[1];if(!this.hasNode(y))throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+y+'" source node in the graph.');if(!this.hasNode(m))throw new l.NotFoundGraphError("Graph."+i+': could not find the "'+m+'" target node in the graph.');var w=void 0;return w="mixed"===n||"directed"===n?this.hasDirectedEdge(y,m):this.hasUndirectedEdge(y,m),w?t?c(this,n,y,m):p(this,n,y,m):t?0:[]}throw new l.InvalidArgumentsGraphError("Graph."+i+": too many arguments (expecting 0, 1 or 2 and got "+r.length+").")}}function g(e){b.forEach(function(t){f(e,!1,t),f(e,!0,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachEdgeIterationMethods=g;var l=r(1),v=r(0),b=[{name:"edges",counter:"countEdges",type:"mixed"},{name:"inEdges",counter:"countInEdges",type:"directed",direction:"in"},{name:"outEdges",counter:"countOutEdges",type:"directed",direction:"out"},{name:"inboundEdges",counter:"countInboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",counter:"countOutboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",counter:"countDirectedEdges",type:"directed"},{name:"undirectedEdges",counter:"countUndirectedEdges",type:"undirected"}]},function(e,t,r){"use strict";function n(e,t){if(t)for(var r in t)e.add(r)}function o(e,t,r,o){e.computeIndex("structure");var i=new Set,a=e._nodes.get(o);return"mixed"!==t&&"directed"!==t||(r&&"in"!==r||n(i,a.in),r&&"out"!==r||n(i,a.out)),"mixed"!==t&&"undirected"!==t||(r&&"in"!==r||n(i,a.undirectedIn),r&&"out"!==r||n(i,a.undirectedOut)),i}function i(e,t,r,o,i){t.computeIndex("structure");var a=new Set;return(0,s.overBunch)(i,function(i){if(!t.hasNode(i))throw new u.NotFoundGraphError("Graph."+e+': could not find the "'+i+'" node in the graph in the given bunch.');var d=t._nodes.get(i);"mixed"!==r&&"directed"!==r||(o&&"in"!==o||n(a,d.in),o&&"out"!==o||n(a,d.out)),"mixed"!==r&&"undirected"!==r||(o&&"in"!==o||n(a,d.undirectedIn),o&&"out"!==o||n(a,d.undirectedOut))}),a}function a(e,t,r){var n=r.type,a=r.direction,d=t?r.counter:r.name;e.prototype[d]=function(e){if(2===arguments.length){var r=arguments[0],h=arguments[1];if(t)throw new u.InvalidArgumentsGraphError("Graph."+d+": invalid arguments.");if(!this.hasNode(r))throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+r+'" node in the graph.');if(!this.hasNode(h))throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+h+'" node in the graph.');var c=o(this,n,a,r);return c.has(h)}if(1===arguments.length){if(this.hasNode(e)){var p=o(this,n,a,e);return t?p.size:(0,s.consumeIterator)(p.size,p.values())}if((0,s.isBunch)(e)){var f=i(d,this,n,a,e);return t?f.size:(0,s.consumeIterator)(f.size,f.values())}throw new u.NotFoundGraphError("Graph."+d+': could not find the "'+e+'" node in the graph.')}throw new u.InvalidArgumentsGraphError("Graph."+d+": invalid number of arguments (expecting 1 or 2 and got "+arguments.length+").")}}function d(e){h.forEach(function(t){a(e,!1,t),a(e,!0,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachNeighborIterationMethods=d;var u=r(1),s=r(0),h=[{name:"neighbors",counter:"countNeighbors",type:"mixed"},{name:"inNeighbors",counter:"countInNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",counter:"countOutNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",counter:"countInboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",counter:"countOutboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",counter:"countDirectedNeighbors",type:"directed"},{name:"undirectedNeighbors",counter:"countUndirectedNeighbors",type:"undirected"}]},function(e,t,r){"use strict";function n(e,t){var r={key:e};return Object.keys(t.attributes).length&&(r.attributes=t.attributes),r}function o(e,t){var r={key:e,source:t.source,target:t.target};return Object.keys(t.attributes).length&&(r.attributes=t.attributes),t.undirected&&(r.undirected=!0),r}function i(e){return(0,d.isPlainObject)(e)?"key"in e?"attributes"in e&&(!(0,d.isPlainObject)(e.attributes)||null===e.attributes)?"invalid-attributes":null:"no-key":"not-object"}function a(e){return(0,d.isPlainObject)(e)?"source"in e?"target"in e?"attributes"in e&&(!(0,d.isPlainObject)(e.attributes)||null===e.attributes)?"invalid-attributes":"undirected"in e&&"boolean"!=typeof e.undirected?"invalid-undirected":null:"no-target":"no-source":"not-object"}Object.defineProperty(t,"__esModule",{value:!0}),t.serializeNode=n,t.serializeEdge=o,t.validateSerializedNode=i,t.validateSerializedEdge=a;var d=r(0)},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,o,d,u,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(r=this._events[e],a(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:d=Array.prototype.slice.call(arguments,1),r.apply(this,d)}else if(i(r))for(d=Array.prototype.slice.call(arguments,1),s=r.slice(),o=s.length,u=0;u<o;u++)s[u].apply(this,d);return!0},r.prototype.addListener=function(e,t){var o;if(!n(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,n(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(o=a(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,o&&o>0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,o,a,d;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(r=this._events[e],a=r.length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(r)){for(d=a;d-- >0;)if(r[d]===t||r[d].listener&&r[d].listener===t){o=d;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[e],n(r))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)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:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function d(e){e.from=function(t,r){var n=new e(r);return n.import(t),n}}var u=r(0),s=r(2),h=n(s),c=r(1),p=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({type:"directed"},r)))}return a(t,e),t}(h.default),f=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({type:"undirected"},r)))}return a(t,e),t}(h.default),g=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({multi:!0,type:"directed"},r)))}return a(t,e),t}(h.default),l=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,u.assign)({multi:!0,type:"undirected"},r)))}return a(t,e),t}(h.default);d(h.default),d(p),d(f),d(g),d(l),h.default.Graph=h.default,h.default.DirectedGraph=p,h.default.UndirectedGraph=f,h.default.MultiDirectedGraph=g,h.default.MultiUndirectedGraph=l,h.default.InvalidArgumentsGraphError=c.InvalidArgumentsGraphError,h.default.NotFoundGraphError=c.NotFoundGraphError,h.default.UsageGraphError=c.UsageGraphError,e.exports=h.default}])});
# Changelog
## 0.5.2
* Node.js 0.12.x compatibility.
* Fixing bug related to the graph's string coercion.
* Improving performance.
* Better error message when adding a self-loop when it's not authorized.
## 0.5.1

@@ -4,0 +11,0 @@

@@ -188,3 +188,3 @@ 'use strict';

if (!graph.allowSelfLoops && source === target) throw new _errors.UsageGraphError('Graph.' + name + ': source & target are the same, thus creating a loop explicitly forbidden by this graph \'allowSelfLoops\' option set to false.');
if (!graph.allowSelfLoops && source === target) throw new _errors.UsageGraphError('Graph.' + name + ': source & target are the same ("' + source + '"), thus creating a loop explicitly forbidden by this graph \'allowSelfLoops\' option set to false.');

@@ -1363,3 +1363,3 @@ // Must the graph generate an id for this edge?

if (arguments.length < 3) throw new _errors.InvalidArgumentsGraphError('Graph.updateNodeAttribute: not enough arguments. Either you forgot to pass the attribute\'s name or value, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.');
if (arguments.length < 3) throw new _errors.InvalidArgumentsGraphError('Graph.updateNodeAttribute: not enough arguments. Either you forgot to pass the attribute\'s name or updater, or you meant to use #.replaceNodeAttributes / #.mergeNodeAttributes instead.');

@@ -1495,3 +1495,3 @@ if (typeof updater !== 'function') throw new _errors.InvalidArgumentsGraphError('Graph.updateAttribute: updater should be a function.');

Graph.prototype.nodes = function nodes() {
return Array.from(this._nodes.keys());
return (0, _utils.consumeIterator)(this._nodes.size, this._nodes.keys());
};

@@ -1498,0 +1498,0 @@

@@ -41,4 +41,3 @@ 'use strict';

var outKey = undirected ? 'undirectedOut' : 'out',
inKey = undirected ? 'undirectedIn' : 'in';
var outKey = undirected ? 'undirectedOut' : 'out';

@@ -62,2 +61,4 @@ // NOTE: The set of edges is the same for source & target

// care of with source above)
var inKey = undirected ? 'undirectedIn' : 'in';
targetData[inKey] = targetData[inKey] || Object.create(null);

@@ -64,0 +65,0 @@

@@ -71,3 +71,3 @@ 'use strict';

if (object[key] instanceof Set) edges.push.apply(edges, Array.from(object[key]));else edges.push(object[key]);
if (object[key] instanceof Set) edges.push.apply(edges, (0, _utils.consumeIterator)(object[key].size, object[key].values()));else edges.push(object[key]);

@@ -79,3 +79,3 @@ return;

if (object[k] instanceof Set) edges.push.apply(edges, Array.from(object[k]));else edges.push(object[k]);
if (object[k] instanceof Set) edges.push.apply(edges, (0, _utils.consumeIterator)(object[k].size, object[k].values()));else edges.push(object[k]);
}

@@ -159,3 +159,3 @@ }

function createEdgeArray(graph, type) {
if (type === 'mixed') return Array.from(graph._edges.keys());
if (type === 'mixed') return (0, _utils.consumeIterator)(graph._edges.size, graph._edges.keys());

@@ -273,3 +273,3 @@ var list = [];

return Array.from(edges.values());
return (0, _utils.consumeIterator)(edges.size, edges.values());
}

@@ -276,0 +276,0 @@

@@ -188,12 +188,8 @@ 'use strict';

*/
Class.prototype[name] = function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
Class.prototype[name] = function (nodeOrBunch) {
if (args.length === 2) {
var node1 = args[0],
node2 = args[1];
if (arguments.length === 2) {
var node1 = arguments[0],
node2 = arguments[1];
if (counter) throw new _errors.InvalidArgumentsGraphError('Graph.' + name + ': invalid arguments.');

@@ -210,4 +206,3 @@

return neighbors.has(node2);
} else if (args.length === 1) {
var nodeOrBunch = args[0];
} else if (arguments.length === 1) {

@@ -221,3 +216,3 @@ if (this.hasNode(nodeOrBunch)) {

return Array.from(_neighbors);
return (0, _utils.consumeIterator)(_neighbors.size, _neighbors.values());
} else if ((0, _utils.isBunch)(nodeOrBunch)) {

@@ -235,3 +230,3 @@

return Array.from(_neighbors2);
return (0, _utils.consumeIterator)(_neighbors2.size, _neighbors2.values());
} else {

@@ -242,3 +237,3 @@ throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + nodeOrBunch + '" node in the graph.');

throw new _errors.InvalidArgumentsGraphError('Graph.' + name + ': invalid number of arguments (expecting 1 or 2 and got ' + args.length + ').');
throw new _errors.InvalidArgumentsGraphError('Graph.' + name + ': invalid number of arguments (expecting 1 or 2 and got ' + arguments.length + ').');
};

@@ -245,0 +240,0 @@ }

@@ -11,2 +11,3 @@ 'use strict';

exports.createInternalMap = createInternalMap;
exports.consumeIterator = consumeIterator;
exports.getMatchingEdge = getMatchingEdge;

@@ -80,2 +81,20 @@ exports.isBunch = isBunch;

/**
* Function consuming the given iterator.
*
* @param {number} size - Size of the target.
* @param {Iterator} iterator - Target iterator.
* @return {Array}
*/
function consumeIterator(size, iterator) {
var array = new Array(size);
var i = 0,
step = void 0;
while (step = iterator.next(), !step.done) {
array[i++] = step.value;
}return array;
}
/**
* Function returning the first matching edge for given path.

@@ -205,3 +224,3 @@ * Note: this function does not check the existence of source & target. This

if (!((i - 2) % 3)) prettyString = ',' + prettyString;
if (!((i - 2) % 3) && i !== l - 1) prettyString = ',' + prettyString;
}

@@ -208,0 +227,0 @@

{
"name": "graphology",
"version": "0.5.1",
"version": "0.5.2",
"description": "A robust and multipurpose Graph object for JavaScript.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -273,2 +273,11 @@ 'use strict';

'it should throw if not enough arguments are provided.': function itShouldThrowIfNotEnoughArgumentsAreProvided() {
var graph = new Graph();
graph.addNode('Lucy');
_assert2.default.throws(function () {
graph.setNodeAttribute('Lucy', { hello: 'world' });
}, invalid());
},
'it should correctly set the node\'s attribute.': function itShouldCorrectlySetTheNodeSAttribute() {

@@ -355,2 +364,11 @@ var graph = new Graph();

'it should throw if not enough arguments are provided.': function itShouldThrowIfNotEnoughArgumentsAreProvided() {
var graph = new Graph();
graph.addNode('Lucy');
_assert2.default.throws(function () {
graph.updateNodeAttribute('Lucy', { hello: 'world' });
}, invalid());
},
'it should correctly set the node\'s attribute.': function itShouldCorrectlySetTheNodeSAttribute() {

@@ -357,0 +375,0 @@ var graph = new Graph();

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc