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

graphology

Package Overview
Dependencies
Maintainers
1
Versions
65
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.7.1 to 0.8.0

dist/iteration/iterators.js

3

build/graphology.min.js

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

!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.delete=function(e){return e=""+e,Map.prototype.delete.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){var o=e._nodes.get(t),i=null;return i="mixed"===n?o.out&&o.out[r]||o.undirected&&o.undirected[r]:"directed"===n?o.out&&o.out[r]:o.undirected&&o.undirected[r]}function d(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 s(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 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 s=d,u=s.value,h=s.done;if(h)break;var p=u[0],c=u[1];if(a=c===p?t(c,null)===!1:t(p,c)===!1)break}else for(var f in e){var g=e[f],l=t(f,g);if(l)break}}function p(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 c(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:!0};"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 y(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="",s=0,u=e.length;0===e[s]&&s<u-1;s++)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 v(){var e=l();return y(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.consumeIterator=i,t.getMatchingEdge=a,t.isBunch=d,t.isGraph=s,t.isPlainObject=u,t.overBunch=h,t.prettyPrint=p,t.privateProperty=c,t.readOnlyProperty=f,t.uuid=v;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,r){e._structureIsComputed&&(0,c.updateStructureIndex)(e,t,r)}function d(e,t,r){e._structureIsComputed&&(0,c.clearEdgeFromStructureIndex)(e,t,r)}function s(e,t,r,n,o,i,d,s,u){if(!o&&"undirected"===e.type)throw new p.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 p.UsageGraphError("Graph."+t+": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.");if(u&&!(0,v.isPlainObject)(u))throw new p.InvalidArgumentsGraphError("Graph."+t+': invalid attributes. Expecting an object but got "'+u+'"');d=""+d,s=""+s;var h=!1,c=!1;if(!e.hasNode(d)){if(!r)throw new p.NotFoundGraphError("Graph."+t+': source node "'+d+'" not found.');h=!0}if(!e.hasNode(s)){if(!r)throw new p.NotFoundGraphError("Graph."+t+': target node "'+s+'" not found.');c=!0}if(!e.allowSelfLoops&&d===s)throw new p.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:s,attributes:u||{}}));var f=null;if(e.hasEdge(i)){if(!r)throw new p.UsageGraphError("Graph."+t+': the "'+i+'" edge already exists in the graph.');f=i}if(!e.multi&&(o?e.hasUndirectedEdge(d,s):e.hasDirectedEdge(d,s))){if(!r)throw new p.UsageGraphError("Graph."+t+': an edge linking "'+d+'" to "'+s+"\" 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,v.getMatchingEdge)(e,d,s,o?"undirected":"directed")}if(u=(0,v.assign)({},e._options.defaultEdgeAttributes,u),f){if(e.source(f)!==d||e.target(f)!==s)throw new p.UsageGraphError("Graph."+t+': inconsitency detected when attempting to merge the "'+i+'" edge with "'+d+'" source & "'+s+'" target vs. ('+e.source(f)+", "+e.target(f)+").");return e.mergeEdgeAttributes(f,u),f}h&&e.addNode(d),c&&e.addNode(s);var g={attributes:u,source:d,target:s};o&&(g.undirected=!0),n&&(g.generatedId=!0),e._edges.set(i,g);var l=e._nodes.get(d),y=e._nodes.get(s);return d===s?o?l.undirectedSelfLoops++:l.directedSelfLoops++:o?(l.undirectedDegree++,y.undirectedDegree++):(l.outDegree++,y.inDegree++),a(e,i,g),e.emit("edgeAdded",{key:i,source:d,target:s,attributes:u,undirected:o}),i}function u(e,t,r,n){var o=[];if(n){if(!(0,v.isBunch)(n))throw new p.InvalidArgumentsGraphError("Graph."+t+": invalid bunch.");(0,v.overBunch)(n,function(n){if(!e.hasEdge(n))throw new p.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),p=r(1),c=r(4),f=r(3),g=r(5),l=r(6),y=r(7),v=r(0),b=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:v.uuid,multi:!1,type:"mixed"},G=function(e){function t(r){n(this,t);var i=o(this,e.call(this));if(r=(0,v.assign)({},E,r),"function"!=typeof r.edgeKeyGenerator)throw new p.InvalidArgumentsGraphError("Graph.constructor: invalid 'edgeKeyGenerator' option. Expecting a function but got \""+r.edgeKeyGenerator+'".');if("boolean"!=typeof r.multi)throw new p.InvalidArgumentsGraphError("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \""+r.multi+'".');if(!b.has(r.type))throw new p.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 p.InvalidArgumentsGraphError("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \""+r.allowSelfLoops+'".');if(!(0,v.isPlainObject)(r.defaultEdgeAttributes))throw new p.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultEdgeAttributes' option. Expecting a plain object but got \""+r.defaultEdgeAttributes+'".');if(!(0,v.isPlainObject)(r.defaultNodeAttributes))throw new p.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultNodeAttributes' option. Expecting a plain object but got \""+r.defaultNodeAttributes+'".');return(0,v.privateProperty)(i,"_attributes",{}),(0,v.privateProperty)(i,"_nodes",(0,v.createInternalMap)()),(0,v.privateProperty)(i,"_edges",(0,v.createInternalMap)()),(0,v.privateProperty)(i,"_structureIsComputed",!1),(0,v.privateProperty)(i,"_options",r),m.forEach(function(e){return(0,v.privateProperty)(i,e,i[e])}),(0,v.readOnlyProperty)(i,"order",function(){return i._nodes.size}),(0,v.readOnlyProperty)(i,"size",function(){return i._edges.size}),(0,v.readOnlyProperty)(i,"multi",i._options.multi),(0,v.readOnlyProperty)(i,"type",i._options.type),(0,v.readOnlyProperty)(i,"allowSelfLoops",i._options.allowSelfLoops),i}return i(t,e),t.prototype.hasNode=function(e){return this._nodes.has(e)},t.prototype.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var r=e;return this._edges.has(r)&&this.directed(r)}if(2===arguments.length){if(this.computeIndex(),!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 p.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("directed"===this.type)return!1;if(1===arguments.length){var r=e;return this._edges.has(r)&&this.undirected(r)}if(2===arguments.length){if(this.computeIndex(),!this.hasNode(e)||!this.hasNode(t))return!1;var n=this._nodes.get(e),o=n.undirected,i=void 0;return o&&(i=o[t]),!!i&&(this.multi?!!i.size:!!i)}throw new p.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 p.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.directedEdge=function(e,t){if(this.multi)throw new p.UsageGraphError("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");if(!this.hasNode(e))throw new p.NotFoundGraphError('Graph.directedEdge: could not find the "'+e+'" source node in the graph.');if(!this.hasNode(t))throw new p.NotFoundGraphError('Graph.directedEdge: could not find the "'+t+'" target node in the graph.');if("undirected"!==this.type){this.computeIndex();var r=this._nodes.get(e);return r.out&&r.out[t]||void 0}},t.prototype.undirectedEdge=function(e,t){if(this.multi)throw new p.UsageGraphError("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");if(!this.hasNode(e))throw new p.NotFoundGraphError('Graph.undirectedEdge: could not find the "'+e+'" source node in the graph.');if(!this.hasNode(t))throw new p.NotFoundGraphError('Graph.undirectedEdge: could not find the "'+t+'" target node in the graph.');if("directed"!==this.type){this.computeIndex();var r=this._nodes.get(e);return r.undirected&&r.undirected[t]||void 0}},t.prototype.edge=function(e,t){if(this.multi)throw new p.UsageGraphError("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");if(!this.hasNode(e))throw new p.NotFoundGraphError('Graph.edge: could not find the "'+e+'" source node in the graph.');if(!this.hasNode(t))throw new p.NotFoundGraphError('Graph.edge: could not find the "'+t+'" target node in the graph.');this.computeIndex();var r=this._nodes.get(e);return r.out&&r.out[t]||r.undirected&&r.undirected[t]||void 0},t.prototype.inDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new p.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 p.NotFoundGraphError('Graph.inDegree: could not find the "'+e+'" node in the graph.');if("undirected"===this.type)return 0;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 p.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 p.NotFoundGraphError('Graph.outDegree: could not find the "'+e+'" node in the graph.');if("undirected"===this.type)return 0;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 p.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 p.NotFoundGraphError('Graph.directedDegree: could not find the "'+e+'" node in the graph.');return"undirected"===this.type?0: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 p.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 p.NotFoundGraphError('Graph.undirectedDegree: could not find the "'+e+'" node in the graph.');if("directed"===this.type)return 0;var r=this._nodes.get(e),n=t?2*r.undirectedSelfLoops:0;return r.undirectedDegree+n},t.prototype.degree=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof r)throw new p.InvalidArgumentsGraphError('Graph.degree: Expecting a boolean but got "'+r+'" for the second parameter (allowing self-loops to be counted).');if(!this.hasNode(t))throw new p.NotFoundGraphError('Graph.degree: could not find the "'+t+'" node in the graph.');var e=0;return"undirected"!==this.type&&(e+=this.directedDegree(t,r)),"directed"!==this.type&&(e+=this.undirectedDegree(t,r)),e},t.prototype.source=function(e){if(!this.hasEdge(e))throw new p.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 p.NotFoundGraphError('Graph.target: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).target},t.prototype.extremities=function(e){var t=this._edges.get(e);if(!t)throw new p.NotFoundGraphError('Graph.extremities: could not find the "'+e+'" edge in the graph.');return[t.source,t.target]},t.prototype.opposite=function(e,t){if(!this.hasNode(e))throw new p.NotFoundGraphError('Graph.opposite: could not find the "'+e+'" node in the graph.');if(!this.hasEdge(t))throw new p.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 p.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 p.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 p.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 p.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,v.isPlainObject)(t))throw new p.InvalidArgumentsGraphError('Graph.addNode: invalid attributes. Expecting an object but got "'+t+'"');if(t=(0,v.assign)({},this._options.defaultNodeAttributes,t),this.hasNode(e))throw new p.UsageGraphError('Graph.addNode: the "'+e+'" node already exist in the graph.');var r={attributes:t};return this.allowSelfLoops&&("undirected"!==this.type&&(r.directedSelfLoops=0),"directed"!==this.type&&(r.undirectedSelfLoops=0)),"undirected"!==this.type&&(r.inDegree=0,r.outDegree=0),"directed"!==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,v.isBunch)(e))throw new p.InvalidArgumentsGraphError('Graph.addNodesFrom: invalid bunch provided ("'+e+'").');return(0,v.overBunch)(e,function(e,r){t.addNode(e,r)}),this},t.prototype.dropNode=function(e){if(!this.hasNode(e))throw new p.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 p.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" source node in the graph.');if(!this.hasNode(r))throw new p.NotFoundGraphError('Graph.dropEdge: could not find the "'+r+'" target node in the graph.');if(!this.hasEdge(t,r))throw new p.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" -> "'+r+'" edge in the graph.');e=(0,v.getMatchingEdge)(this,t,r,this.type)}else if(!this.hasEdge(e))throw new p.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,s=n.undirected,u=void 0!==s&&s,h=this._nodes.get(o),c=this._nodes.get(i);return o===i?h.selfLoops--:u?(h.undirectedDegree--,c.undirectedDegree--):(h.outDegree--,c.inDegree--),d(this,e,n),this.emit("edgeDropped",{key:e,attributes:a,source:o,target:i,undirected:u}),this},t.prototype.dropNodes=function(e){var t=this;if(!arguments.length)return this.clear();if(!(0,v.isBunch)(e))throw new p.InvalidArgumentsGraphError("Graph.dropNodes: invalid bunch.");return(0,v.overBunch)(e,function(e){t.dropNode(e)}),this},t.prototype.dropEdges=function(e){var t=this;if(!arguments.length)return this._edges.clear(),this.clearIndex(),this;if(2===arguments.length){var r=arguments[0],n=arguments[1];e=this.edges(r,n)}if(!(0,v.isBunch)(e))throw new p.InvalidArgumentsGraphError("Graph.dropEdges: invalid bunch.");return(0,v.overBunch)(e,function(e){t.dropEdge(e)}),this},t.prototype.clear=function(){this._edges.clear(),this._nodes.clear();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 p.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,v.isPlainObject)(e))throw new p.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,v.isPlainObject)(e))throw new p.InvalidArgumentsGraphError("Graph.mergeAttributes: provided attributes are not a plain object.");return this._attributes=(0,v.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 p.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 p.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 p.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 p.NotFoundGraphError('Graph.setNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new p.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 p.NotFoundGraphError('Graph.updateNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new p.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 p.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 p.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 p.NotFoundGraphError('Graph.replaceNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,v.isPlainObject)(t))throw new p.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 p.NotFoundGraphError('Graph.mergeNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,v.isPlainObject)(t))throw new p.InvalidArgumentsGraphError("Graph.mergeNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e);return(0,v.assign)(r.attributes,t),this.emit("nodeAttributesUpdated",{key:e,type:"merge",meta:{data:t}}),this},t.prototype.nodes=function(){return(0,v.consumeIterator)(this._nodes.size,this._nodes.keys())},t.prototype.exportNode=function(e){if(!this.hasNode(e))throw new p.NotFoundGraphError('Graph.exportNode: could not find the "'+e+'" node in the graph.');var t=this._nodes.get(e);return(0,y.serializeNode)(e,t)},t.prototype.exportEdge=function(e){if(!this.hasEdge(e))throw new p.NotFoundGraphError('Graph.exportEdge: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return(0,y.serializeEdge)(e,t)},t.prototype.exportNodes=function(e){var t=this,r=[];if(arguments.length){if(!(0,v.isBunch)(e))throw new p.InvalidArgumentsGraphError("Graph.exportNodes: invalid bunch.");(0,v.overBunch)(e,function(e){if(!t.hasNode(e))throw new p.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 u(this,"exportEdges",null,e)},t.prototype.exportDirectedEdges=function(e){var t=this;return u(this,"exportDirectedEdges",function(e){return t.directed(e)},e)},t.prototype.exportUndirectedEdges=function(e){var t=this;return u(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,y.validateSerializedNode)(e);if(r){if("not-object"===r)throw new p.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 p.InvalidArgumentsGraphError("Graph.importNode: no key provided.");if("invalid-attributes"===r)throw new p.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,y.validateSerializedEdge)(e);if(r){if("not-object"===r)throw new p.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 p.InvalidArgumentsGraphError("Graph.importEdge: missing souce.");if("no-target"===r)throw new p.InvalidArgumentsGraphError("Graph.importEdge: missing target");if("invalid-attributes"===r)throw new p.InvalidArgumentsGraphError("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if("invalid-undirected"===r)throw new p.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,s=void 0!==d&&d,u=void 0;return"key"in e?(u=t?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,u.call(this,e.key,n,o,a)):(u=t?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,u.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 p.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 p.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,v.isGraph)(e))return this.import(e.export(),t),this;if(!(0,v.isPlainObject)(e))throw new p.InvalidArgumentsGraphError("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!(0,v.isPlainObject)(e.attributes))throw new p.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.upgradeToMixed=function(){var e=this;return"mixed"===this.type?this:(this._nodes.forEach(function(t){"undirected"===e.type?(t.directedSelfLoops=0,t.inDegree=0,t.outDegree=0):(t.undirectedSelfLoops=0,t.undirectedDegree=0)}),this._options.type="mixed",(0,v.readOnlyProperty)(this,"type",this._options.type),this)},t.prototype.upgradeToMulti=function(){return this.multi?this:(this._options.multi=!0,(0,v.readOnlyProperty)(this,"multi",!0),this._structureIsComputed?((0,c.upgradeStructureIndexToMulti)(this),this):this)},t.prototype.computeIndex=function(){var e=this;if(!this._structureIsComputed)return this._edges.forEach(function(t,r){(0,c.updateStructureIndex)(e,r,t)}),this._structureIsComputed=!0,this},t.prototype.clearIndex=function(){return this._structureIsComputed?((0,c.clearStructureIndex)(this),
this._structureIsComputed=!1,this):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,v.prettyPrint)(this.order)+" node"+(e?"s":"")+", "+(0,v.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,v.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 s(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),null,n,o,i)}:G.prototype[r]=function(n,o,i,a){return s(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,c.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,c.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,c.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,c.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 s=this._edges.get(e);return s.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,c.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 s=this._edges.get(e);return s.attributes[o]=i(s.attributes[o]),this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:s.attributes[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,c.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 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,c.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,c.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e),s=d.attributes;return d.attributes=o,this.emit("edgeAttributesUpdated",{key:e,type:"replace",meta:{before:s,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,c.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,c.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var d=this._edges.get(e);return(0,c.assign)(d.attributes,o),this.emit("edgeAttributesUpdated",{key:e,type:"merge",meta:{data:o}}),this}}function p(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=p;var c=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:s},{name:function(e){return"replace"+e+"Attributes"},attacher:u},{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),s=e._nodes.get(a),u=o?"undirected":"out";if(d[u]=d[u]||Object.create(null),a in d[u]||(d[u][a]=n?new Set:t),n&&d[u][a].add(t),i!==a){var h=o?"undirected":"in";s[h]=s[h]||Object.create(null),i in s[h]||(s[h][i]=d[u][a])}}function o(e,t,r){var n=e.multi,o=r.source,i=r.target,a=r.undirected,d=e._nodes.get(o),s=a?"undirected":"out",u=d[s];if(i in u&&(n?u[i].delete(t):delete u[i]),!n){var h=e._nodes.get(i),p=a?"undirected":"in",c=h[p];delete c[o]}}function i(e){e._nodes.forEach(function(e){delete e.in,delete e.out,delete e.undirected})}function a(e){e._nodes.forEach(function(t,r){if(t.out)for(var n in t.out){var o=new Set;o.add(t.out[n]),t.out[n]=o,e._nodes.get(n).in[r]=o}if(t.undirected)for(var i in t.undirected)if(!(i>r)){var a=new Set;a.add(t.undirected[i]),t.undirected[i]=a,e._nodes.get(i).undirected[r]=a}})}Object.defineProperty(t,"__esModule",{value:!0}),t.updateStructureIndex=n,t.clearEdgeFromStructureIndex=o,t.clearStructureIndex=i,t.upgradeStructureIndexToMulti=a},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,h.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,h.consumeIterator)(t[o].size,t[o].values())):e.push(t[o])}}function o(e,t){if("mixed"===t)return(0,h.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 i(e,t,r,o){e.computeIndex();var i=[],a=e._nodes.get(o);return"undirected"!==t&&("out"!==r&&n(i,a.in),"in"!==r&&n(i,a.out)),"directed"!==t&&n(i,a.undirected),i}function a(e,t,r,o){e.computeIndex();var i=[],a=e._nodes.get(r);return"undirected"!==t&&(n(i,a.in,o),n(i,a.out,o)),"directed"!==t&&n(i,a.undirected,o),i}function d(e,t){var r=t.name,n=t.type,d=t.direction;e.prototype[r]=function(e,t){if("mixed"!==n&&"mixed"!==this.type&&n!==this.type)return[];if(!arguments.length)return o(this,n);if(1===arguments.length){if(!this.hasNode(e))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" node in the graph.');return i(this,n,d,e)}if(2===arguments.length){if(!this.hasNode(e))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" source node in the graph.');if(!this.hasNode(t))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+t+'" target node in the graph.');var s=void 0;return s="undirected"!==n?this.hasDirectedEdge(e,t):this.hasUndirectedEdge(e,t),s?a(this,n,e,t):[]}throw new u.InvalidArgumentsGraphError("Graph."+r+": too many arguments (expecting 0, 1 or 2 and got "+arguments.length+").")}}function s(e){p.forEach(function(t){d(e,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachEdgeIterationMethods=s;var u=r(1),h=r(0),p=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",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();var i=new Set,a=e._nodes.get(o);return"undirected"!==t&&("out"!==r&&n(i,a.in),"in"!==r&&n(i,a.out)),"directed"!==t&&n(i,a.undirected),i}function i(e,t){var r=t.name,n=t.type,i=t.direction;e.prototype[r]=function(e){if("mixed"!==n&&"mixed"!==this.type&&n!==this.type)return[];if(2===arguments.length){var t=arguments[0],a=arguments[1];if(!this.hasNode(t))throw new d.NotFoundGraphError("Graph."+r+': could not find the "'+t+'" node in the graph.');if(!this.hasNode(a))throw new d.NotFoundGraphError("Graph."+r+': could not find the "'+a+'" node in the graph.');var u=o(this,n,i,t);return u.has(a)}if(1===arguments.length){if(!this.hasNode(e))throw new d.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" node in the graph.');var h=o(this,n,i,e);return(0,s.consumeIterator)(h.size,h.values())}throw new d.InvalidArgumentsGraphError("Graph."+r+": invalid number of arguments (expecting 1 or 2 and got "+arguments.length+").")}}function a(e){u.forEach(function(t){i(e,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachNeighborIterationMethods=a;var d=r(1),s=r(0),u=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",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,s,u;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),u=r.slice(),o=u.length,s=0;s<o;s++)u[s].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 s=r(0),u=r(2),h=n(u),p=r(1),c=function(e){function t(r){return o(this,t),i(this,e.call(this,(0,s.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,s.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,s.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,s.assign)({multi:!0,type:"undirected"},r)))}return a(t,e),t}(h.default);d(h.default),d(c),d(f),d(g),d(l),h.default.Graph=h.default,h.default.DirectedGraph=c,h.default.UndirectedGraph=f,h.default.MultiDirectedGraph=g,h.default.MultiUndirectedGraph=l,h.default.InvalidArgumentsGraphError=p.InvalidArgumentsGraphError,h.default.NotFoundGraphError=p.NotFoundGraphError,h.default.UsageGraphError=p.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=4)}([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(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 i(e,t,r,n){var o=e._nodes.get(t);return"mixed"===n?o.out&&o.out[r]||o.undirected&&o.undirected[r]:"directed"===n?o.out&&o.out[r]:o.undirected&&o.undirected[r]}function a(e){return!!e&&"object"===(void 0===e?"undefined":v(e))&&(Array.isArray(e)||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set||!(e instanceof Date)&&!(e instanceof RegExp))}function s(e){return!!e&&"object"===(void 0===e?"undefined":v(e))&&"function"==typeof e.addUndirectedEdgeWithKey&&"function"==typeof e.dropNode}function d(e){return!(!e||"object"!==(void 0===e?"undefined":v(e))||Array.isArray(e)||e instanceof Date||e instanceof RegExp||"function"==typeof Map&&e instanceof Map||"function"==typeof Set&&e instanceof Set)}function u(e,t){if(Array.isArray(e))for(var r=0,n=e.length;r<n;r++)t(e[r],null);else if("function"==typeof e.forEach)for(var o=e.entries(),i=void 0;i=o.next();){var a=i,s=a.value,d=a.done;if(d)break;var u=s[0],h=s[1];h===u?t(h,null):t(u,h)}else for(var p in e){var c=e[p];t(p,c)}}function h(e){for(var t=""+e,r="",n=0,o=t.length;n<o;n++){r=t[o-n-1]+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 c(e,t,r){var n={enumerable:!0,configurable:!0};"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()),b[t]=e>>>((3&t)<<3)&255;return b}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 s="",d=0,u=e.length;0===e[d]&&d<u-1;d++)s+=m[0];for(var h=t.length-1;h>=0;h--)s+=m[t[h]];for(;s.length<22;)s+="0";return s}function y(){return l(g())}Object.defineProperty(t,"__esModule",{value:!0});var v="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.consumeIterator=o,t.getMatchingEdge=i,t.isBunch=a,t.isGraph=s,t.isPlainObject=d,t.overBunch=u,t.prettyPrint=h,t.privateProperty=p,t.readOnlyProperty=c,t.uuid=y;var b=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,r,n,o,i,a,s,d){if(!o&&"undirected"===e.type)throw new u.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 u.UsageGraphError("Graph."+t+": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.");if(d&&!(0,y.isPlainObject)(d))throw new u.InvalidArgumentsGraphError("Graph."+t+': invalid attributes. Expecting an object but got "'+d+'"');a=""+a,s=""+s;var h=!1,c=!1;if(!e._nodes.has(a)){if(!r)throw new u.NotFoundGraphError("Graph."+t+': source node "'+a+'" not found.');h=!0}if(!e._nodes.has(s)){if(!r)throw new u.NotFoundGraphError("Graph."+t+': target node "'+s+'" not found.');c=!0}if(!e.allowSelfLoops&&a===s)throw new u.UsageGraphError("Graph."+t+': source & target are the same ("'+a+"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.");n&&(i=e._options.edgeKeyGenerator({undirected:o,source:a,target:s,attributes:d||{}})),i=""+i;var f=null;if(e._edges.has(i)){if(!r)throw new u.UsageGraphError("Graph."+t+': the "'+i+'" edge already exists in the graph.');f=i}if(!e.multi&&(o?e.hasUndirectedEdge(a,s):e.hasDirectedEdge(a,s))){if(!r)throw new u.UsageGraphError("Graph."+t+': an edge linking "'+a+'" to "'+s+"\" 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,y.getMatchingEdge)(e,a,s,o?"undirected":"directed")}if(d=(0,y.assign)({},e._options.defaultEdgeAttributes,d),f){if(e.source(f)!==a||e.target(f)!==s)throw new u.UsageGraphError("Graph."+t+': inconsitency detected when attempting to merge the "'+i+'" edge with "'+a+'" source & "'+s+'" target vs. ('+e.source(f)+", "+e.target(f)+").");return e.mergeEdgeAttributes(f,d),f}h&&e.addNode(a),c&&e.addNode(s);var g={attributes:d,source:a,target:s};o&&(g.undirected=!0),n&&(g.generatedId=!0),e._edges.set(i,g);var l=e._nodes.get(a),v=e._nodes.get(s);return a===s?o?l.undirectedSelfLoops++:l.directedSelfLoops++:o?(l.undirectedDegree++,v.undirectedDegree++):(l.outDegree++,v.inDegree++),e._structureIsComputed&&(0,p.updateStructureIndex)(e,i,g),e.emit("edgeAdded",{key:i,source:a,target:s,attributes:d,undirected:o}),i}function s(e,t,r,n){var o=[];if(n){if(!(0,y.isBunch)(n))throw new u.InvalidArgumentsGraphError("Graph."+t+": invalid bunch.");(0,y.overBunch)(n,function(n){if(!e.hasEdge(n))throw new u.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,s=o.length;a<s;a++)i[a]=e.exportEdge(o[a]);return i}Object.defineProperty(t,"__esModule",{value:!0});var d=r(10),u=r(1),h=r(7),p=r(5),c=r(3),f=r(6),g=r(8),l=r(9),y=r(0),v=new Set(["directed","undirected","mixed"]),b=new Set(["domain","_events","_eventsCount","_maxListeners"]),m=[{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"}],w={allowSelfLoops:!0,defaultEdgeAttributes:{},defaultNodeAttributes:{},edgeKeyGenerator:y.uuid,multi:!1,type:"mixed"},E=function(e){function t(r){n(this,t);var i=o(this,e.call(this));if(r=(0,y.assign)({},w,r),"function"!=typeof r.edgeKeyGenerator)throw new u.InvalidArgumentsGraphError("Graph.constructor: invalid 'edgeKeyGenerator' option. Expecting a function but got \""+r.edgeKeyGenerator+'".');if("boolean"!=typeof r.multi)throw new u.InvalidArgumentsGraphError("Graph.constructor: invalid 'multi' option. Expecting a boolean but got \""+r.multi+'".');if(!v.has(r.type))throw new u.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 u.InvalidArgumentsGraphError("Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got \""+r.allowSelfLoops+'".');if(!(0,y.isPlainObject)(r.defaultEdgeAttributes))throw new u.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultEdgeAttributes' option. Expecting a plain object but got \""+r.defaultEdgeAttributes+'".');if(!(0,y.isPlainObject)(r.defaultNodeAttributes))throw new u.InvalidArgumentsGraphError("Graph.constructor: invalid 'defaultNodeAttributes' option. Expecting a plain object but got \""+r.defaultNodeAttributes+'".');return(0,y.privateProperty)(i,"_attributes",{}),(0,y.privateProperty)(i,"_nodes",new Map),(0,y.privateProperty)(i,"_edges",new Map),(0,y.privateProperty)(i,"_structureIsComputed",!1),(0,y.privateProperty)(i,"_options",r),b.forEach(function(e){return(0,y.privateProperty)(i,e,i[e])}),(0,y.readOnlyProperty)(i,"order",function(){return i._nodes.size}),(0,y.readOnlyProperty)(i,"size",function(){return i._edges.size}),(0,y.readOnlyProperty)(i,"multi",i._options.multi),(0,y.readOnlyProperty)(i,"type",i._options.type),(0,y.readOnlyProperty)(i,"allowSelfLoops",i._options.allowSelfLoops),i}return i(t,e),t.prototype.hasNode=function(e){return this._nodes.has(""+e)},t.prototype.hasDirectedEdge=function(e,t){if("undirected"===this.type)return!1;if(1===arguments.length){var r=""+e,n=this._edges.get(r);return!!n&&!n.undirected}if(2===arguments.length){if(e=""+e,t=""+t,this.computeIndex(),!this._nodes.has(e)||!this._nodes.has(t))return!1;var o=this._nodes.get(e),i=o.out;if(!i)return!1;var a=i[t];return!!a&&(this.multi?!!a.size:!!a)}throw new u.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("directed"===this.type)return!1;if(1===arguments.length){var r=""+e,n=this._edges.get(r);return!!n&&!!n.undirected}if(2===arguments.length){if(e=""+e,t=""+t,this.computeIndex(),!this._nodes.has(e)||!this._nodes.has(t))return!1;var o=this._nodes.get(e),i=o.undirected,a=void 0;return i&&(a=i[t]),!!a&&(this.multi?!!a.size:!!a)}throw new u.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){if(e=""+e,t=""+t,this.computeIndex(),!this._nodes.has(e)||!this._nodes.has(t))return!1;var n=this._nodes.get(e),o=n.out,i=void 0;return o&&(i=o[t]),i||(o=n.undirected),o&&(i=o[t]),!!i&&(this.multi?!!i.size:!!i)}throw new u.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.directedEdge=function(e,t){if("undirected"!==this.type){if(e=""+e,t=""+t,this.multi)throw new u.UsageGraphError("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");var r=this._nodes.get(e);if(!r)throw new u.NotFoundGraphError('Graph.directedEdge: could not find the "'+e+'" source node in the graph.');if(!this._nodes.has(t))throw new u.NotFoundGraphError('Graph.directedEdge: could not find the "'+t+'" target node in the graph.');return this.computeIndex(),r.out&&r.out[t]||void 0}},t.prototype.undirectedEdge=function(e,t){if("directed"!==this.type){if(e=""+e,t=""+t,this.multi)throw new u.UsageGraphError("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");var r=this._nodes.get(e);if(!r)throw new u.NotFoundGraphError('Graph.undirectedEdge: could not find the "'+e+'" source node in the graph.');if(!this._nodes.has(t))throw new u.NotFoundGraphError('Graph.undirectedEdge: could not find the "'+t+'" target node in the graph.');return this.computeIndex(),r.undirected&&r.undirected[t]||void 0}},t.prototype.edge=function(e,t){if(this.multi)throw new u.UsageGraphError("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;var r=this._nodes.get(e);if(!r)throw new u.NotFoundGraphError('Graph.edge: could not find the "'+e+'" source node in the graph.');if(!this._nodes.has(t))throw new u.NotFoundGraphError('Graph.edge: could not find the "'+t+'" target node in the graph.');return this.computeIndex(),r.out&&r.out[t]||r.undirected&&r.undirected[t]||void 0},t.prototype.inDegree=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("boolean"!=typeof t)throw new u.InvalidArgumentsGraphError('Graph.inDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');e=""+e;var r=this._nodes.get(e);if(!r)throw new u.NotFoundGraphError('Graph.inDegree: could not find the "'+e+'" node in the graph.');if("undirected"===this.type)return 0;var 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 u.InvalidArgumentsGraphError('Graph.outDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');e=""+e;var r=this._nodes.get(e);if(!r)throw new u.NotFoundGraphError('Graph.outDegree: could not find the "'+e+'" node in the graph.');if("undirected"===this.type)return 0;var 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 u.InvalidArgumentsGraphError('Graph.directedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.directedDegree: could not find the "'+e+'" node in the graph.');return"undirected"===this.type?0: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 u.InvalidArgumentsGraphError('Graph.undirectedDegree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.undirectedDegree: could not find the "'+e+'" node in the graph.');if("directed"===this.type)return 0;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 u.InvalidArgumentsGraphError('Graph.degree: Expecting a boolean but got "'+t+'" for the second parameter (allowing self-loops to be counted).');if(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.degree: could not find the "'+e+'" node in the graph.');var r=0;return"undirected"!==this.type&&(r+=this.directedDegree(e,t)),"directed"!==this.type&&(r+=this.undirectedDegree(e,t)),r},t.prototype.source=function(e){if(e=""+e,!this.hasEdge(e))throw new u.NotFoundGraphError('Graph.source: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).source},t.prototype.target=function(e){if(e=""+e,!this.hasEdge(e))throw new u.NotFoundGraphError('Graph.target: could not find the "'+e+'" edge in the graph.');return this._edges.get(e).target},t.prototype.extremities=function(e){e=""+e;var t=this._edges.get(e);if(!t)throw new u.NotFoundGraphError('Graph.extremities: could not find the "'+e+'" edge in the graph.');return[t.source,t.target]},t.prototype.opposite=function(e,t){if(e=""+e,t=""+t,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.opposite: could not find the "'+e+'" node in the graph.');if(!this.hasEdge(t))throw new u.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 u.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(e=""+e,!this.hasEdge(e))throw new u.NotFoundGraphError('Graph.undirected: could not find the "'+e+'" edge in the graph.');return!!this._edges.get(e).undirected},t.prototype.directed=function(e){if(e=""+e,!this.hasEdge(e))throw new u.NotFoundGraphError('Graph.directed: could not find the "'+e+'" edge in the graph.');return!this._edges.get(e).undirected},t.prototype.selfLoop=function(e){if(e=""+e,!this.hasEdge(e))throw new u.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,y.isPlainObject)(t))throw new u.InvalidArgumentsGraphError('Graph.addNode: invalid attributes. Expecting an object but got "'+t+'"');if(e=""+e,t=(0,y.assign)({},this._options.defaultNodeAttributes,t),this.hasNode(e))throw new u.UsageGraphError('Graph.addNode: the "'+e+'" node already exist in the graph.');var r={attributes:t};return this.allowSelfLoops&&("undirected"!==this.type&&(r.directedSelfLoops=0),"directed"!==this.type&&(r.undirectedSelfLoops=0)),"undirected"!==this.type&&(r.inDegree=0,r.outDegree=0),"directed"!==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,y.isBunch)(e))throw new u.InvalidArgumentsGraphError('Graph.addNodesFrom: invalid bunch provided ("'+e+'").');return(0,y.overBunch)(e,function(e,r){t.addNode(e,r)}),this},t.prototype.dropNode=function(e){if(e=""+e,!this.hasNode(e))throw new u.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 u.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" source node in the graph.');if(!this.hasNode(r))throw new u.NotFoundGraphError('Graph.dropEdge: could not find the "'+r+'" target node in the graph.');if(!this.hasEdge(t,r))throw new u.NotFoundGraphError('Graph.dropEdge: could not find the "'+t+'" -> "'+r+'" edge in the graph.');e=(0,y.getMatchingEdge)(this,t,r,this.type)}else if(e=""+e,!this.hasEdge(e))throw new u.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,s=n.undirected,d=void 0!==s&&s,h=this._nodes.get(o),c=this._nodes.get(i);return o===i?h.selfLoops--:d?(h.undirectedDegree--,c.undirectedDegree--):(h.outDegree--,c.inDegree--),this._structureIsComputed&&(0,p.clearEdgeFromStructureIndex)(this,e,n),this.emit("edgeDropped",{key:e,attributes:a,source:o,target:i,undirected:d}),this},t.prototype.dropNodes=function(e){var t=this;if(!arguments.length)return this.clear();if(!(0,y.isBunch)(e))throw new u.InvalidArgumentsGraphError("Graph.dropNodes: invalid bunch.");return(0,y.overBunch)(e,function(e){t.dropNode(e)}),this},t.prototype.dropEdges=function(e){var t=this;if(!arguments.length)return this._edges.clear(),this.clearIndex(),this;if(2===arguments.length){var r=arguments[0],n=arguments[1];e=this.edges(r,n)}if(!(0,y.isBunch)(e))throw new u.InvalidArgumentsGraphError("Graph.dropEdges: invalid bunch.");return(0,y.overBunch)(e,function(e){t.dropEdge(e)}),this},t.prototype.clear=function(){this._edges.clear(),this._nodes.clear();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 u.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,y.isPlainObject)(e))throw new u.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,y.isPlainObject)(e))throw new u.InvalidArgumentsGraphError("Graph.mergeAttributes: provided attributes are not a plain object.");return this._attributes=(0,y.assign)(this._attributes,e),this.emit("attributesUpdated",{type:"merge",meta:{data:this._attributes}}),this},t.prototype.getNodeAttribute=function(e,t){if(e=""+e,!this.hasNode(e))throw new u.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(e=""+e,!this.hasNode(e))throw new u.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(e=""+e,!this.hasNode(e))throw new u.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(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.setNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new u.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(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.updateNodeAttribute: could not find the "'+e+'" node in the graph.');if(arguments.length<3)throw new u.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 u.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(e=""+e,!this.hasNode(e))throw new u.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(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.replaceNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,y.isPlainObject)(t))throw new u.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(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.mergeNodeAttributes: could not find the "'+e+'" node in the graph.');if(!(0,y.isPlainObject)(t))throw new u.InvalidArgumentsGraphError("Graph.mergeNodeAttributes: provided attributes are not a plain object.");var r=this._nodes.get(e);return(0,y.assign)(r.attributes,t),this.emit("nodeAttributesUpdated",{key:e,type:"merge",meta:{data:t}}),this},t.prototype.nodes=function(){return(0,y.consumeIterator)(this._nodes.size,this._nodes.keys())},t.prototype.nodesIterator=function(){var e=this._nodes.keys();return new h.NodesIterator(function(){return e.next()})},t.prototype.exportNode=function(e){if(e=""+e,!this.hasNode(e))throw new u.NotFoundGraphError('Graph.exportNode: could not find the "'+e+'" node in the graph.');var t=this._nodes.get(e);return(0,l.serializeNode)(e,t)},t.prototype.exportEdge=function(e){if(e=""+e,!this.hasEdge(e))throw new u.NotFoundGraphError('Graph.exportEdge: could not find the "'+e+'" edge in the graph.');var t=this._edges.get(e);return(0,l.serializeEdge)(e,t)},t.prototype.exportNodes=function(e){var t=this,r=[];if(arguments.length){if(!(0,y.isBunch)(e))throw new u.InvalidArgumentsGraphError("Graph.exportNodes: invalid bunch.");(0,y.overBunch)(e,function(e){if(!t.hasNode(e))throw new u.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,l.validateSerializedNode)(e);if(r){if("not-object"===r)throw new u.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 u.InvalidArgumentsGraphError("Graph.importNode: no key provided.");if("invalid-attributes"===r)throw new u.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,l.validateSerializedEdge)(e);if(r){if("not-object"===r)throw new u.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 u.InvalidArgumentsGraphError("Graph.importEdge: missing souce.");if("no-target"===r)throw new u.InvalidArgumentsGraphError("Graph.importEdge: missing target");if("invalid-attributes"===r)throw new u.InvalidArgumentsGraphError("Graph.importEdge: invalid attributes. Attributes should be a plain object, null or omitted.");if("invalid-undirected"===r)throw new u.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,s=e.undirected,d=void 0!==s&&s,h=void 0;return"key"in e?(h=t?d?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:d?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,h.call(this,e.key,n,o,a)):(h=t?d?this.mergeUndirectedEdge:this.mergeDirectedEdge:d?this.addUndirectedEdge:this.addDirectedEdge,h.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 u.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 u.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,y.isGraph)(e))return this.import(e.export(),t),this;if(!(0,y.isPlainObject)(e))throw new u.InvalidArgumentsGraphError("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!(0,y.isPlainObject)(e.attributes))throw new u.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.upgradeToMixed=function(){var e=this;return"mixed"===this.type?this:(this._nodes.forEach(function(t){"undirected"===e.type?(t.directedSelfLoops=0,t.inDegree=0,t.outDegree=0):(t.undirectedSelfLoops=0,t.undirectedDegree=0)}),this._options.type="mixed",(0,y.readOnlyProperty)(this,"type",this._options.type),this)},t.prototype.upgradeToMulti=function(){return this.multi?this:(this._options.multi=!0,(0,y.readOnlyProperty)(this,"multi",!0),this._structureIsComputed?((0,p.upgradeStructureIndexToMulti)(this),this):this)},t.prototype.computeIndex=function(){var e=this;if(!this._structureIsComputed)return this._edges.forEach(function(t,r){(0,p.updateStructureIndex)(e,r,t)}),this._structureIsComputed=!0,this},t.prototype.clearIndex=function(){return this._structureIsComputed?((0,p.clearStructureIndex)(this),this._structureIsComputed=!1,this):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,y.prettyPrint)(this.order)+" node"+(e?"s":"")+", "+(0,y.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)&&!b.has(n)&&"function"!=typeof this[n]&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,(0,y.privateProperty)(r,"constructor",this.constructor),r},t}(d.EventEmitter);t.default=E,m.forEach(function(e){["add","merge"].forEach(function(t){var r=e.name(t);e.generateKey?E.prototype[r]=function(n,o,i){return a(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),null,n,o,i)}:E.prototype[r]=function(n,o,i,s){return a(this,r,"merge"===t,e.generateKey,"undirected"===(e.type||this.type),n,o,i,s)}})}),(0,c.attachAttributesMethods)(E),(0,f.attachEdgeIterationMethods)(E),(0,g.attachNeighborIterationMethods)(E)},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,c.getMatchingEdge)(this,i,a,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');return this._edges.get(e).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,c.getMatchingEdge)(this,o,i,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');return this._edges.get(e).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,c.getMatchingEdge)(this,i,a,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');return this._edges.get(e).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,s=""+o;if(o=arguments[2],i=arguments[3],!this[r](a,s))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+s+'").');e=(0,c.getMatchingEdge)(this,a,s,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');return this._edges.get(e).attributes[o]=i,this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:i}}),this}}function s(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,s=""+o;if(o=arguments[2],i=arguments[3],!this[r](a,s))throw new f.NotFoundGraphError("Graph."+t+': could not find an edge for the given path ("'+a+'" - "'+s+'").');e=(0,c.getMatchingEdge)(this,a,s,n)}else e=""+e;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 d=this._edges.get(e);return d.attributes[o]=i(d.attributes[o]),this.emit("edgeAttributesUpdated",{key:e,type:"set",meta:{name:o,value:d.attributes[o]}}),this}}function d(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,c.getMatchingEdge)(this,i,a,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');return delete this._edges.get(e).attributes[o],this.emit("edgeAttributesUpdated",{key:e,type:"remove",meta:{name: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,c.getMatchingEdge)(this,i,a,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,c.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var s=this._edges.get(e),d=s.attributes;return s.attributes=o,this.emit("edgeAttributesUpdated",{key:e,type:"replace",meta:{before:d,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,c.getMatchingEdge)(this,i,a,n)}else e=""+e;if(!this[r](e))throw new f.NotFoundGraphError("Graph."+t+': could not find the "'+e+'" edge in the graph.');if(!(0,c.isPlainObject)(o))throw new f.InvalidArgumentsGraphError("Graph."+t+": provided attributes are not a plain object.");var s=this._edges.get(e);return(0,c.assign)(s.attributes,o),this.emit("edgeAttributesUpdated",{key:e,type:"merge",meta:{data:o}}),this}}function p(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=p;var c=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:s},{name:function(e){return"remove"+e+"Attribute"},attacher:d},{name:function(e){return"replace"+e+"Attributes"},attacher:u},{name:function(e){return"merge"+e+"Attributes"},attacher:h}]},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){e.from=function(t,r){var n=new e(r);return n.import(t),n}}var s=r(0),d=r(2),u=function(e){return e&&e.__esModule?e:{default:e}}(d),h=r(1),p=function(e){function t(r){return n(this,t),o(this,e.call(this,(0,s.assign)({type:"directed"},r)))}return i(t,e),t}(u.default),c=function(e){function t(r){return n(this,t),o(this,e.call(this,(0,s.assign)({type:"undirected"},r)))}return i(t,e),t}(u.default),f=function(e){function t(r){return n(this,t),o(this,e.call(this,(0,s.assign)({multi:!0,type:"directed"},r)))}return i(t,e),t}(u.default),g=function(e){function t(r){return n(this,t),o(this,e.call(this,(0,s.assign)({multi:!0,type:"undirected"},r)))}return i(t,e),t}(u.default);a(u.default),a(p),a(c),a(f),a(g),u.default.Graph=u.default,u.default.DirectedGraph=p,u.default.UndirectedGraph=c,u.default.MultiDirectedGraph=f,u.default.MultiUndirectedGraph=g,u.default.InvalidArgumentsGraphError=h.InvalidArgumentsGraphError,u.default.NotFoundGraphError=h.NotFoundGraphError,u.default.UsageGraphError=h.UsageGraphError,e.exports=u.default},function(e,t,r){"use strict";function n(e,t,r){var n=e.multi,o=r.undirected,i=r.source,a=r.target,s=e._nodes.get(i),d=e._nodes.get(a),u=o?"undirected":"out",h=o?"undirected":"in";void 0===s[u]&&(s[u]={}),void 0===s[u][a]&&(s[u][a]=n?new Set:t),n&&s[u][a].add(t),i!==a&&(void 0===d[h]&&(d[h]={}),void 0===d[h][i]&&(d[h][i]=s[u][a]))}function o(e,t,r){var n=e.multi,o=r.source,i=r.target,a=r.undirected,s=e._nodes.get(o),d=a?"undirected":"out",u=s[d];if(i in u&&(n?u[i].delete(t):delete u[i]),!n){delete e._nodes.get(i)[a?"undirected":"in"][o]}}function i(e){e._nodes.forEach(function(e){delete e.in,delete e.out,delete e.undirected})}function a(e){e._nodes.forEach(function(t,r){if(t.out)for(var n in t.out){var o=new Set;o.add(t.out[n]),t.out[n]=o,e._nodes.get(n).in[r]=o}if(t.undirected)for(var i in t.undirected)if(!(i>r)){var a=new Set;a.add(t.undirected[i]),t.undirected[i]=a,e._nodes.get(i).undirected[r]=a}})}Object.defineProperty(t,"__esModule",{value:!0}),t.updateStructureIndex=n,t.clearEdgeFromStructureIndex=o,t.clearStructureIndex=i,t.upgradeStructureIndexToMulti=a},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,h.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,h.consumeIterator)(t[o].size,t[o].values())):e.push(t[o])}}function o(e,t){if("mixed"===t)return(0,h.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 i(e,t,r,o){e.computeIndex();var i=[],a=e._nodes.get(o);return"undirected"!==t&&("out"!==r&&n(i,a.in),"in"!==r&&n(i,a.out)),"directed"!==t&&n(i,a.undirected),i}function a(e,t,r,o){e.computeIndex();var i=[],a=e._nodes.get(r);return"undirected"!==t&&(n(i,a.in,o),n(i,a.out,o)),"directed"!==t&&n(i,a.undirected,o),i}function s(e,t){var r=t.name,n=t.type,s=t.direction;e.prototype[r]=function(e,t){if("mixed"!==n&&"mixed"!==this.type&&n!==this.type)return[];if(!arguments.length)return o(this,n);if(1===arguments.length){if(e=""+e,!this._nodes.has(e))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" node in the graph.');return i(this,n,s,e)}if(2===arguments.length){if(e=""+e,t=""+t,!this._nodes.has(e))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" source node in the graph.');if(!this._nodes.has(t))throw new u.NotFoundGraphError("Graph."+r+': could not find the "'+t+'" target node in the graph.');var d=void 0;return d="undirected"!==n?this.hasDirectedEdge(e,t):this.hasUndirectedEdge(e,t),d?a(this,n,e,t):[]}throw new u.InvalidArgumentsGraphError("Graph."+r+": too many arguments (expecting 0, 1 or 2 and got "+arguments.length+").")}}function d(e){p.forEach(function(t){s(e,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachEdgeIterationMethods=d;var u=r(1),h=r(0),p=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}]},function(e,t,r){"use strict";function n(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 o(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 i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function e(t){i(this,e),this.next=t};t.NodesIterator=function(e){function t(){return i(this,t),n(this,e.apply(this,arguments))}return o(t,e),t}(a)},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();var i=new Set,a=e._nodes.get(o);return"undirected"!==t&&("out"!==r&&n(i,a.in),"in"!==r&&n(i,a.out)),"directed"!==t&&n(i,a.undirected),i}function i(e,t){var r=t.name,n=t.type,i=t.direction;e.prototype[r]=function(e){if("mixed"!==n&&"mixed"!==this.type&&n!==this.type)return[];if(2===arguments.length){var t=""+arguments[0],a=""+arguments[1];if(!this._nodes.has(t))throw new s.NotFoundGraphError("Graph."+r+': could not find the "'+t+'" node in the graph.');if(!this._nodes.has(a))throw new s.NotFoundGraphError("Graph."+r+': could not find the "'+a+'" node in the graph.');return o(this,n,i,t).has(a)}if(1===arguments.length){if(e=""+e,!this._nodes.has(e))throw new s.NotFoundGraphError("Graph."+r+': could not find the "'+e+'" node in the graph.');var u=o(this,n,i,e);return(0,d.consumeIterator)(u.size,u.values())}throw new s.InvalidArgumentsGraphError("Graph."+r+": invalid number of arguments (expecting 1 or 2 and got "+arguments.length+").")}}function a(e){u.forEach(function(t){i(e,t)})}Object.defineProperty(t,"__esModule",{value:!0}),t.attachNeighborIterationMethods=a;var s=r(1),d=r(0),u=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",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,s.isPlainObject)(e)?"key"in e?"attributes"in e&&(!(0,s.isPlainObject)(e.attributes)||null===e.attributes)?"invalid-attributes":null:"no-key":"not-object"}function a(e){return(0,s.isPlainObject)(e)?"source"in e?"target"in e?"attributes"in e&&(!(0,s.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 s=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,s,d,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])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:s=Array.prototype.slice.call(arguments,1),r.apply(this,s)}else if(i(r))for(s=Array.prototype.slice.call(arguments,1),u=r.slice(),o=u.length,d=0;d<o;d++)u[d].apply(this,s);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>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,s;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(s=a;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=s;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){return 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)}}])});
# Changelog
## 0.8.0
* Adding the `#.nodesIterator` method.
* Performance improvements.
## 0.7.1

@@ -4,0 +9,0 @@

@@ -50,4 +50,4 @@ 'use strict';

var source = element,
target = name;
var source = '' + element,
target = '' + name;

@@ -59,2 +59,4 @@ name = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -100,4 +102,4 @@

var source = element,
target = arguments[1];
var source = '' + element,
target = '' + arguments[1];

@@ -107,2 +109,4 @@ if (!this[checker](source, target)) throw new _errors.NotFoundGraphError('Graph.' + method + ': could not find an edge for the given path ("' + source + '" - "' + target + '").');

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -150,4 +154,4 @@

var source = element,
target = name;
var source = '' + element,
target = '' + name;

@@ -159,2 +163,4 @@ name = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -204,4 +210,4 @@

var source = element,
target = name;
var source = '' + element,
target = '' + name;

@@ -214,2 +220,4 @@ name = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -272,4 +280,4 @@

var source = element,
target = name;
var source = '' + element,
target = '' + name;

@@ -282,2 +290,4 @@ name = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -339,4 +349,4 @@

var source = element,
target = name;
var source = '' + element,
target = '' + name;

@@ -348,2 +358,4 @@ name = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -402,4 +414,4 @@

var source = element,
target = attributes;
var source = '' + element,
target = '' + attributes;

@@ -411,2 +423,4 @@ attributes = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -470,4 +484,4 @@

var source = element,
target = attributes;
var source = '' + element,
target = '' + attributes;

@@ -479,2 +493,4 @@ attributes = arguments[2];

element = (0, _utils.getMatchingEdge)(this, source, target, type);
} else {
element = '' + element;
}

@@ -481,0 +497,0 @@

@@ -39,8 +39,9 @@ 'use strict';

var outKey = undirected ? 'undirected' : 'out';
var outKey = undirected ? 'undirected' : 'out',
inKey = undirected ? 'undirected' : 'in';
// Handling source
sourceData[outKey] = sourceData[outKey] || Object.create(null);
if (typeof sourceData[outKey] === 'undefined') sourceData[outKey] = {};
if (!(target in sourceData[outKey])) sourceData[outKey][target] = multi ? new Set() : edge;
if (typeof sourceData[outKey][target] === 'undefined') sourceData[outKey][target] = multi ? new Set() : edge;

@@ -54,7 +55,5 @@ if (multi) sourceData[outKey][target].add(edge);

// care of with source above)
var inKey = undirected ? 'undirected' : 'in';
if (typeof targetData[inKey] === 'undefined') targetData[inKey] = {};
targetData[inKey] = targetData[inKey] || Object.create(null);
if (!(source in targetData[inKey])) targetData[inKey][source] = sourceData[outKey][target];
if (typeof targetData[inKey][source] === 'undefined') targetData[inKey][source] = sourceData[outKey][target];
}

@@ -61,0 +60,0 @@

@@ -187,4 +187,5 @@ 'use strict';

if (arguments.length === 1) {
source = '' + source;
if (!this.hasNode(source)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + source + '" node in the graph.');
if (!this._nodes.has(source)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + source + '" node in the graph.');

@@ -196,6 +197,9 @@ // Iterating over a node's edges

if (arguments.length === 2) {
if (!this.hasNode(source)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + source + '" source node in the graph.');
source = '' + source;
target = '' + target;
if (!this.hasNode(target)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + target + '" target node in the graph.');
if (!this._nodes.has(source)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + source + '" source node in the graph.');
if (!this._nodes.has(target)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + target + '" target node in the graph.');
// Iterating over the edges between source & target

@@ -202,0 +206,0 @@ var hasEdge = void 0;

@@ -125,8 +125,8 @@ 'use strict';

if (arguments.length === 2) {
var node1 = arguments[0],
node2 = arguments[1];
var node1 = '' + arguments[0],
node2 = '' + arguments[1];
if (!this.hasNode(node1)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node1 + '" node in the graph.');
if (!this._nodes.has(node1)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node1 + '" node in the graph.');
if (!this.hasNode(node2)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node2 + '" node in the graph.');
if (!this._nodes.has(node2)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node2 + '" node in the graph.');

@@ -138,4 +138,5 @@ // Here, we want to assess whether the two given nodes are neighbors

} else if (arguments.length === 1) {
node = '' + node;
if (!this.hasNode(node)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node + '" node in the graph.');
if (!this._nodes.has(node)) throw new _errors.NotFoundGraphError('Graph.' + name + ': could not find the "' + node + '" node in the graph.');

@@ -142,0 +143,0 @@ // Here, we want to iterate over a node's relevant neighbors

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

exports.assign = assign;
exports.createInternalMap = createInternalMap;
exports.consumeIterator = consumeIterator;

@@ -55,33 +54,2 @@ exports.getMatchingEdge = getMatchingEdge;

/**
* Custom Map used internally to coerce keys on vital operations.
*
* @return {Map}
*/
function createInternalMap() {
var map = new Map();
map.set = function (key, value) {
key = '' + key;
return Map.prototype.set.call(this, key, value);
};
map.get = function (key) {
key = '' + key;
return Map.prototype.get.call(this, key);
};
map.has = function (key) {
key = '' + key;
return Map.prototype.has.call(this, key);
};
map.delete = function (key) {
key = '' + key;
return Map.prototype.delete.call(this, key);
};
return map;
}
/**
* Function consuming the given iterator.

@@ -172,5 +140,3 @@ *

for (var i = 0, l = bunch.length; i < l; i++) {
var shouldBreak = callback(bunch[i], null) === false;
if (shouldBreak) break;
callback(bunch[i], null);
}

@@ -183,4 +149,3 @@ }

var _shouldBreak = false,
step = void 0;
var step = void 0;

@@ -199,5 +164,3 @@ while (step = iterator.next()) {

if (v === k) _shouldBreak = callback(v, null) === false;else _shouldBreak = callback(k, v) === false;
if (_shouldBreak) break;
if (v === k) callback(v, null);else callback(k, v);
}

@@ -211,5 +174,3 @@ }

var _shouldBreak2 = callback(key, attributes);
if (_shouldBreak2) break;
callback(key, attributes);
}

@@ -216,0 +177,0 @@ }

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

@@ -57,3 +57,3 @@ "main": "dist/index.js",

"babel-core": "^6.13.2",
"babel-loader": "^6.2.5",
"babel-loader": "^7.0.0",
"babel-plugin-transform-es2015-classes": "^6.9.0",

@@ -60,0 +60,0 @@ "babel-plugin-transform-es2015-destructuring": "^6.9.0",

@@ -24,2 +24,16 @@ 'use strict';

}
},
'#.nodesIterator': {
'it should be possible to create a nodes iterator.': function itShouldBePossibleToCreateANodesIterator() {
var graph = new Graph();
graph.addNodesFrom(['one', 'two', 'three']);
var iterator = graph.nodesIterator();
_assert2.default.strictEqual(iterator.next().value, 'one');
_assert2.default.strictEqual(iterator.next().value, 'two');
_assert2.default.strictEqual(iterator.next().value, 'three');
_assert2.default.strictEqual(iterator.next().done, true);
}
}

@@ -26,0 +40,0 @@ };

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

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