You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

js-graph

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-graph - npm Package Compare versions

Comparing version

to
1.2.0-alpha

dist/js-graph.full.js

@@ -57,2 +57,10 @@ (function webpackUniversalModuleDefinition(root, factory) {

module.exports = __webpack_require__(2);
/***/ },
/* 1 */,
/* 2 */
/***/ function(module, exports, __webpack_require__) {
"use strict";

@@ -59,0 +67,0 @@

2

dist/js-graph.min.js

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

(function e(t,r){if(typeof exports==="object"&&typeof module==="object")module.exports=r();else if(typeof define==="function"&&define.amd)define(r);else if(typeof exports==="object")exports["JsGraph"]=r();else t["JsGraph"]=r()})(this,function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={exports:{},id:s,loaded:false};e[s].call(n.exports,n,n.exports,r);n.loaded=true;return n.exports}r.m=e;r.c=t;r.p="";return r(0)}([function(e,t,r){"use strict";var s=function(e,t){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var r=[];for(var s=e[Symbol.iterator](),n;!(n=s.next()).done;){r.push(n.value);if(t&&r.length===t)break}return r}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var n=function(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})};var i=function(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof t)}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(t)e.__proto__=t};var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.configurable=true;if(s.value)s.writable=true;Object.defineProperty(e,s.key,s)}}return function(t,r,s){if(r)e(t.prototype,r);if(s)e(t,s);return t}}();var u=function(){function e(e,t){for(var r in t){var s=t[r];s.configurable=true;if(s.value)s.writable=true}Object.defineProperties(e,t)}return function(t,r,s){if(r)e(t.prototype,r);if(s)e(t,s);return t}}();var o=function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}};var c=function(){function e(){o(this,e);this._callbacks=[]}u(e,{add:{value:function t(e){var t=this;if(this._callbacks.indexOf(e)===-1){this._callbacks.push(e)}return function(){var r=t._callbacks.indexOf(e);if(r!==-1){t._callbacks.splice(r,1)}}}},fire:{value:function r(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++){t[r]=arguments[r]}this._callbacks.forEach(function(e){e.apply(undefined,t)})}}});return e}();var h=function(){function e(){o(this,e);this._vertices={};this._edges={};this._reverseEdges={};this._vertexCount=0;this._edgeCount=0;this._addVertexCallbacks=new c;this._removeVertexCallbacks=new c;this._addEdgeCallbacks=new c;this._removeEdgeCallbacks=new c}a(e,[{key:"onAddVertex",value:function t(e){return this._addVertexCallbacks.add(e)}},{key:"onRemoveVertex",value:function r(e){return this._removeVertexCallbacks.add(e)}},{key:"addNewVertex",value:function n(t,r){if(this.hasVertex(t)){throw new e.VertexExistsError(t,this._vertices[t])}this._vertices[t]=r;this._edges[t]={};this._reverseEdges[t]={};this._vertexCount+=1;this._addVertexCallbacks.fire(t,r)}},{key:"setVertex",value:function i(t,r){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._vertices[t]=r}},{key:"ensureVertex",value:function u(e,t){if(!this.hasVertex(e)){this.addNewVertex(e,t)}}},{key:"addVertex",value:function h(e,t){if(this.hasVertex(e)){this.setVertex(e,t)}else{this.addNewVertex(e,t)}}},{key:"removeExistingVertex",value:function f(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(Object.keys(this._edges[t]).length){throw new e.HasConnectedEdgesError(t)}if(Object.keys(this._reverseEdges[t]).length){throw new e.HasConnectedEdgesError(t)}var r=this._vertices[t];delete this._vertices[t];this._vertexCount-=1;this._removeVertexCallbacks.fire(t,r)}},{key:"destroyExistingVertex",value:function v(t){var r=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this.eachVertexFrom(t,function(e){r.removeEdge(t,e)});this.eachVertexTo(t,function(e){r.removeEdge(e,t)});this.removeExistingVertex(t)}},{key:"removeVertex",value:function d(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function l(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function x(){return this._vertexCount}},{key:"hasVertex",value:function g(e){return e in this._vertices}},{key:"vertexValue",value:function E(e){return this._vertices[e]}},{key:"onAddEdge",value:function k(e){return this._addEdgeCallbacks.add(e)}},{key:"onRemoveEdge",value:function y(e){return this._removeEdgeCallbacks.add(e)}},{key:"addNewEdge",value:function p(t,r,s){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._edges[t][r]=s;this._reverseEdges[r][t]=null;this._edgeCount+=1;this._addEdgeCallbacks.fire(t,r,s)}},{key:"createNewEdge",value:function b(t,r,s){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}this.ensureVertex(t);this.ensureVertex(r);this.addNewEdge(t,r,s)}},{key:"setEdge",value:function w(t,r,s){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}this._edges[t][r]=s}},{key:"spanEdge",value:function V(t,r,s){if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(!this.hasEdge(t,r)){this.addNewEdge(t,r,s)}}},{key:"addEdge",value:function _(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.addNewEdge(e,t,r)}}},{key:"ensureEdge",value:function m(e,t,r){if(!this.hasEdge(e,t)){this.createNewEdge(e,t,r)}}},{key:"createEdge",value:function j(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.createNewEdge(e,t,r)}}},{key:"removeExistingEdge",value:function C(t,r){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}var s=this._edges[t][r];delete this._edges[t][r];delete this._reverseEdges[r][t];this._edgeCount-=1;this._removeEdgeCallbacks.fire(t,r,s)}},{key:"removeEdge",value:function N(e,t){if(this.hasEdge(e,t)){this.removeExistingEdge(e,t)}}},{key:"edgeCount",value:function O(){return this._edgeCount}},{key:"hasEdge",value:function T(e,t){return this.hasVertex(e)&&this.hasVertex(t)&&e in this._edges&&t in this._edges[e]}},{key:"edgeValue",value:function R(e,t){return this.hasEdge(e,t)?this._edges[e][t]:undefined}},{key:"successors",value:function S(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return Object.keys(this._edges[t])}},{key:"predecessors",value:function M(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return Object.keys(this._reverseEdges[t])}},{key:"eachVertex",value:function F(e){var t=this;Object.keys(this._vertices).every(function(r){var s=e(r,t._vertices[r]);return s!==false})}},{key:"eachVertexFrom",value:function A(t,r){var s=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}Object.keys(this._edges[t]).every(function(e){var n=r(e,s.vertexValue(e),s.edgeValue(t,e));return n!==false})}},{key:"eachVertexTo",value:function P(t,r){var s=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}Object.keys(this._reverseEdges[t]).every(function(e){var n=r(e,s.vertexValue(e),s.edgeValue(e,t));return n!==false})}},{key:"eachEdge",value:function H(e){var t=this;Object.keys(this._edges).every(function(r){return Object.keys(t._edges[r]).every(function(s){var n=e(r,s,t._edges[r][s]);return n!==false})})}},{key:"topologically",value:function G(t){var r=this;var s=[];var n={};var i=function(a){s.push(a);var u=s.indexOf(a);if(u!==s.length-1){var o=s.slice(u+1).reverse();throw new e.CycleError(o)}if(!n[a]){r.eachVertexTo(a,i);n[a]={returned:t(a,r.vertexValue(a))}}s.pop()};this.eachVertex(function(e){if(!n[e]){i(e)}})}},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"vertices",value:regeneratorRuntime.mark(function J(){var e=this;var t,r,s,n,i,a;return regeneratorRuntime.wrap(function u(o){while(1)switch(o.prev=o.next){case 0:t=true;r=false;s=undefined;o.prev=3;n=Object.keys(e._vertices)[Symbol.iterator]();case 5:if(t=(i=n.next()).done){o.next=13;break}a=i.value;if(!e.hasVertex(a)){o.next=10;break}o.next=10;return[a,e._vertices[a]];case 10:t=true;o.next=5;break;case 13:o.next=19;break;case 15:o.prev=15;o.t0=o["catch"](3);r=true;s=o.t0;case 19:o.prev=19;o.prev=20;if(!t&&n["return"]){n["return"]()}case 22:o.prev=22;if(!r){o.next=25;break}throw s;case 25:return o.finish(22);case 26:return o.finish(19);case 27:case"end":return o.stop()}},J,this,[[3,15,19,27],[20,,22,26]])})},{key:"edges",value:regeneratorRuntime.mark(function Y(){var e=this;var t,r,s,n,i,a,u,o,c,h,f,v;return regeneratorRuntime.wrap(function d(l){while(1)switch(l.prev=l.next){case 0:t=true;r=false;s=undefined;l.prev=3;n=Object.keys(e._edges)[Symbol.iterator]();case 5:if(t=(i=n.next()).done){l.next=37;break}a=i.value;u=true;o=false;c=undefined;l.prev=10;h=Object.keys(e._edges[a])[Symbol.iterator]();case 12:if(u=(f=h.next()).done){l.next=20;break}v=f.value;if(!e.hasEdge(a,v)){l.next=17;break}l.next=17;return[a,v,e._edges[a][v]];case 17:u=true;l.next=12;break;case 20:l.next=26;break;case 22:l.prev=22;l.t1=l["catch"](10);o=true;c=l.t1;case 26:l.prev=26;l.prev=27;if(!u&&h["return"]){h["return"]()}case 29:l.prev=29;if(!o){l.next=32;break}throw c;case 32:return l.finish(29);case 33:return l.finish(26);case 34:t=true;l.next=5;break;case 37:l.next=43;break;case 39:l.prev=39;l.t2=l["catch"](3);r=true;s=l.t2;case 43:l.prev=43;l.prev=44;if(!t&&n["return"]){n["return"]()}case 46:l.prev=46;if(!r){l.next=49;break}throw s;case 49:return l.finish(46);case 50:return l.finish(43);case 51:case"end":return l.stop()}},Y,this,[[3,39,43,51],[10,22,26,34],[27,,29,33],[44,,46,50]])})},{key:"verticesFrom",value:function I(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesFrom(t)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function q(e){var t=this;var r,s,n,i,a,u;return regeneratorRuntime.wrap(function o(c){while(1)switch(c.prev=c.next){case 0:r=true;s=false;n=undefined;c.prev=3;i=Object.keys(t._edges[e])[Symbol.iterator]();case 5:if(r=(a=i.next()).done){c.next=13;break}u=a.value;if(!t.hasEdge(e,u)){c.next=10;break}c.next=10;return[u,t._vertices[u],t._edges[e][u]];case 10:r=true;c.next=5;break;case 13:c.next=19;break;case 15:c.prev=15;c.t3=c["catch"](3);s=true;n=c.t3;case 19:c.prev=19;c.prev=20;if(!r&&i["return"]){i["return"]()}case 22:c.prev=22;if(!s){c.next=25;break}throw n;case 25:return c.finish(22);case 26:return c.finish(19);case 27:case"end":return c.stop()}},q,this,[[3,15,19,27],[20,,22,26]])})},{key:"verticesTo",value:function z(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesTo(t)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function B(e){var t=this;var r,s,n,i,a,u;return regeneratorRuntime.wrap(function o(c){while(1)switch(c.prev=c.next){case 0:r=true;s=false;n=undefined;c.prev=3;i=Object.keys(t._reverseEdges[e])[Symbol.iterator]();case 5:if(r=(a=i.next()).done){c.next=13;break}u=a.value;if(!t.hasEdge(u,e)){c.next=10;break}c.next=10;return[u,t._vertices[u],t._edges[u][e]];case 10:r=true;c.next=5;break;case 13:c.next=19;break;case 15:c.prev=15;c.t4=c["catch"](3);s=true;n=c.t4;case 19:c.prev=19;c.prev=20;if(!r&&i["return"]){i["return"]()}case 22:c.prev=22;if(!s){c.next=25;break}throw n;case 25:return c.finish(22);case 26:return c.finish(19);case 27:case"end":return c.stop()}},B,this,[[3,15,19,27],[20,,22,26]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function D(){var t=this;var r=regeneratorRuntime.mark(function l(t){var r,u,o,c,h,f,v,d,x;return regeneratorRuntime.wrap(function g(E){while(1)switch(E.prev=E.next){case 0:n.push(t);r=n.indexOf(t);if(!(r!==n.length-1)){E.next=5;break}u=n.slice(r+1).reverse();throw new e.CycleError(u);case 5:if(i[t]){E.next=36;break}o=true;c=false;h=undefined;E.prev=9;f=a.verticesTo(t)[Symbol.iterator]();case 11:if(o=(v=f.next()).done){E.next=18;break}d=s(v.value,1);x=d[0];return E.delegateYield(l(x),"t5",15);case 15:o=true;E.next=11;break;case 18:E.next=24;break;case 20:E.prev=20;E.t6=E["catch"](9);c=true;h=E.t6;case 24:E.prev=24;E.prev=25;if(!o&&f["return"]){f["return"]()}case 27:E.prev=27;if(!c){E.next=30;break}throw h;case 30:return E.finish(27);case 31:return E.finish(24);case 32:if(!a.hasVertex(t)){E.next=35;break}E.next=35;return[t,a._vertices[t]];case 35:i[t]=true;case 36:n.pop();case 37:case"end":return E.stop()}},l,this,[[9,20,24,32],[25,,27,31]])});var n,i,a,u,o,c,h,f,v,d;return regeneratorRuntime.wrap(function x(e){while(1)switch(e.prev=e.next){case 0:n=[];i={};a=t;u=true;o=false;c=undefined;e.prev=6;h=t.vertices()[Symbol.iterator]();case 8:if(u=(f=h.next()).done){e.next=16;break}v=s(f.value,1);d=v[0];if(i[d]){e.next=13;break}return e.delegateYield(r(d),"t7",13);case 13:u=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t8=e["catch"](6);o=true;c=e.t8;case 22:e.prev=22;e.prev=23;if(!u&&h["return"]){h["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw c;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},D,this,[[6,18,22,30],[23,,25,29]])})},{key:"clearEdges",value:function K(){var e=this;this.eachEdge(function(t,r){e.removeEdge(t,r)})}},{key:"clear",value:function L(){var e=this;this.eachVertex(function(t){e.destroyVertex(t)})}},{key:"hasCycle",value:function Q(){var e=this;var t={};var r={};var s=false;var n=function(i){if(t[i]){s=true;return}if(r[i]){return}r[i]=true;t[i]=true;e.eachVertexFrom(i,function(e){n(e);if(s){return false}});t[i]=false};this.eachVertex(function(e){n(e);if(s){return false}});return s}},{key:"hasPath",value:function U(e,t){var r=this;if(!this.hasVertex(e)||!this.hasVertex(t)){return false}var s={};var n=function(e){if(r.hasEdge(e,t)){return true}s[e]=true;var i=false;r.eachVertexFrom(e,function(e){if(!i&&!s[e]&&n(e)){i=true}});delete s[e];return i};return n(e)}},{key:"clone",value:function W(){var t=new e;this.eachVertex(function(e,r){t.addVertex(e,r)});this.eachEdge(function(e,r,s){t.addEdge(e,r,s)});return t}},{key:"transitiveReduction",value:function X(){var e=this.clone();e.eachVertex(function(t){e.eachVertex(function(r){if(e.hasEdge(t,r)){e.eachVertex(function(s){if(e.hasPath(r,s)){e.removeEdge(t,s)}})}})});return e}}]);return e}();e.exports=h;h.VertexExistsError=function(e){function t(e,r){o(this,t);this.vertices={};this.v(e,r)}i(t,e);u(t,{v:{value:function r(e,t){this.vertices[e]=t;this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);h.VertexNotExistsError=function(e){function t(e){o(this,t);this.vertices={};this.v(e)}i(t,e);u(t,{v:{value:function r(e){this.vertices[e]=undefined;this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);h.EdgeExistsError=function(e){function t(e,r,s){o(this,t);this.edges={};this.e(e,r,s)}i(t,e);u(t,{e:{value:function r(e,t,s){this.edges[e]=n({},t,s);this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph has "+r+" "+t.join(", ")}}});return t}(Error);h.EdgeNotExistsError=function(e){function t(e,r){o(this,t);this.edges={};this.e(e,r)}i(t,e);u(t,{e:{value:function r(e,t){this.edges[e]=n({},t,undefined);this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph does not have "+r+" "+t.join(", ")}}});return t}(Error);h.HasConnectedEdgesError=function(e){function t(e){o(this,t);this.message="The '"+e+"' vertex has connected edges";this.key=e}i(t,e);return t}(Error);h.CycleError=function(e){function t(e){o(this,t);this.message="This graph contains a cycle: "+e;this.cycle=e}i(t,e);return t}(Error)}])});
(function e(t,r){if(typeof exports==="object"&&typeof module==="object")module.exports=r();else if(typeof define==="function"&&define.amd)define(r);else if(typeof exports==="object")exports["JsGraph"]=r();else t["JsGraph"]=r()})(this,function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={exports:{},id:s,loaded:false};e[s].call(n.exports,n,n.exports,r);n.loaded=true;return n.exports}r.m=e;r.c=t;r.p="";return r(0)}([function(e,t,r){e.exports=r(2)},,function(e,t,r){"use strict";var s=function(e,t){if(Array.isArray(e)){return e}else if(Symbol.iterator in Object(e)){var r=[];for(var s=e[Symbol.iterator](),n;!(n=s.next()).done;){r.push(n.value);if(t&&r.length===t)break}return r}else{throw new TypeError("Invalid attempt to destructure non-iterable instance")}};var n=function(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})};var i=function(e,t){if(typeof t!=="function"&&t!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof t)}e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}});if(t)e.__proto__=t};var a=function(){function e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.configurable=true;if(s.value)s.writable=true;Object.defineProperty(e,s.key,s)}}return function(t,r,s){if(r)e(t.prototype,r);if(s)e(t,s);return t}}();var u=function(){function e(e,t){for(var r in t){var s=t[r];s.configurable=true;if(s.value)s.writable=true}Object.defineProperties(e,t)}return function(t,r,s){if(r)e(t.prototype,r);if(s)e(t,s);return t}}();var o=function(e,t){if(!(e instanceof t)){throw new TypeError("Cannot call a class as a function")}};var c=function(){function e(){o(this,e);this._callbacks=[]}u(e,{add:{value:function t(e){var t=this;if(this._callbacks.indexOf(e)===-1){this._callbacks.push(e)}return function(){var r=t._callbacks.indexOf(e);if(r!==-1){t._callbacks.splice(r,1)}}}},fire:{value:function r(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++){t[r]=arguments[r]}this._callbacks.forEach(function(e){e.apply(undefined,t)})}}});return e}();var h=function(){function e(){o(this,e);this._vertices={};this._edges={};this._reverseEdges={};this._vertexCount=0;this._edgeCount=0;this._addVertexCallbacks=new c;this._removeVertexCallbacks=new c;this._addEdgeCallbacks=new c;this._removeEdgeCallbacks=new c}a(e,[{key:"onAddVertex",value:function t(e){return this._addVertexCallbacks.add(e)}},{key:"onRemoveVertex",value:function r(e){return this._removeVertexCallbacks.add(e)}},{key:"addNewVertex",value:function n(t,r){if(this.hasVertex(t)){throw new e.VertexExistsError(t,this._vertices[t])}this._vertices[t]=r;this._edges[t]={};this._reverseEdges[t]={};this._vertexCount+=1;this._addVertexCallbacks.fire(t,r)}},{key:"setVertex",value:function i(t,r){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this._vertices[t]=r}},{key:"ensureVertex",value:function u(e,t){if(!this.hasVertex(e)){this.addNewVertex(e,t)}}},{key:"addVertex",value:function h(e,t){if(this.hasVertex(e)){this.setVertex(e,t)}else{this.addNewVertex(e,t)}}},{key:"removeExistingVertex",value:function f(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}if(Object.keys(this._edges[t]).length){throw new e.HasConnectedEdgesError(t)}if(Object.keys(this._reverseEdges[t]).length){throw new e.HasConnectedEdgesError(t)}var r=this._vertices[t];delete this._vertices[t];this._vertexCount-=1;this._removeVertexCallbacks.fire(t,r)}},{key:"destroyExistingVertex",value:function v(t){var r=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}this.eachVertexFrom(t,function(e){r.removeEdge(t,e)});this.eachVertexTo(t,function(e){r.removeEdge(e,t)});this.removeExistingVertex(t)}},{key:"removeVertex",value:function d(e){if(this.hasVertex(e)){this.removeExistingVertex(e)}}},{key:"destroyVertex",value:function l(e){if(this.hasVertex(e)){this.destroyExistingVertex(e)}}},{key:"vertexCount",value:function x(){return this._vertexCount}},{key:"hasVertex",value:function g(e){return e in this._vertices}},{key:"vertexValue",value:function E(e){return this._vertices[e]}},{key:"onAddEdge",value:function k(e){return this._addEdgeCallbacks.add(e)}},{key:"onRemoveEdge",value:function y(e){return this._removeEdgeCallbacks.add(e)}},{key:"addNewEdge",value:function p(t,r,s){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}this._edges[t][r]=s;this._reverseEdges[r][t]=null;this._edgeCount+=1;this._addEdgeCallbacks.fire(t,r,s)}},{key:"createNewEdge",value:function b(t,r,s){if(this.hasEdge(t,r)){throw new e.EdgeExistsError(t,r,this.edgeValue(t,r))}this.ensureVertex(t);this.ensureVertex(r);this.addNewEdge(t,r,s)}},{key:"setEdge",value:function w(t,r,s){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}this._edges[t][r]=s}},{key:"spanEdge",value:function V(t,r,s){if(!this.hasVertex(t)){if(this.hasVertex(r)){throw new e.VertexNotExistsError(t)}else{throw new e.VertexNotExistsError(t).v(r)}}else if(!this.hasVertex(r)){throw new e.VertexNotExistsError(r)}if(!this.hasEdge(t,r)){this.addNewEdge(t,r,s)}}},{key:"addEdge",value:function _(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.addNewEdge(e,t,r)}}},{key:"ensureEdge",value:function m(e,t,r){if(!this.hasEdge(e,t)){this.createNewEdge(e,t,r)}}},{key:"createEdge",value:function j(e,t,r){if(this.hasEdge(e,t)){this.setEdge(e,t,r)}else{this.createNewEdge(e,t,r)}}},{key:"removeExistingEdge",value:function C(t,r){if(!this.hasEdge(t,r)){throw new e.EdgeNotExistsError(t,r)}var s=this._edges[t][r];delete this._edges[t][r];delete this._reverseEdges[r][t];this._edgeCount-=1;this._removeEdgeCallbacks.fire(t,r,s)}},{key:"removeEdge",value:function N(e,t){if(this.hasEdge(e,t)){this.removeExistingEdge(e,t)}}},{key:"edgeCount",value:function O(){return this._edgeCount}},{key:"hasEdge",value:function T(e,t){return this.hasVertex(e)&&this.hasVertex(t)&&e in this._edges&&t in this._edges[e]}},{key:"edgeValue",value:function R(e,t){return this.hasEdge(e,t)?this._edges[e][t]:undefined}},{key:"successors",value:function S(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return Object.keys(this._edges[t])}},{key:"predecessors",value:function M(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return Object.keys(this._reverseEdges[t])}},{key:"eachVertex",value:function F(e){var t=this;Object.keys(this._vertices).every(function(r){var s=e(r,t._vertices[r]);return s!==false})}},{key:"eachVertexFrom",value:function A(t,r){var s=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}Object.keys(this._edges[t]).every(function(e){var n=r(e,s.vertexValue(e),s.edgeValue(t,e));return n!==false})}},{key:"eachVertexTo",value:function P(t,r){var s=this;if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}Object.keys(this._reverseEdges[t]).every(function(e){var n=r(e,s.vertexValue(e),s.edgeValue(e,t));return n!==false})}},{key:"eachEdge",value:function H(e){var t=this;Object.keys(this._edges).every(function(r){return Object.keys(t._edges[r]).every(function(s){var n=e(r,s,t._edges[r][s]);return n!==false})})}},{key:"topologically",value:function G(t){var r=this;var s=[];var n={};var i=function(a){s.push(a);var u=s.indexOf(a);if(u!==s.length-1){var o=s.slice(u+1).reverse();throw new e.CycleError(o)}if(!n[a]){r.eachVertexTo(a,i);n[a]={returned:t(a,r.vertexValue(a))}}s.pop()};this.eachVertex(function(e){if(!n[e]){i(e)}})}},{key:Symbol.iterator,value:function(){return this.vertices()}},{key:"vertices",value:regeneratorRuntime.mark(function J(){var e=this;var t,r,s,n,i,a;return regeneratorRuntime.wrap(function u(o){while(1)switch(o.prev=o.next){case 0:t=true;r=false;s=undefined;o.prev=3;n=Object.keys(e._vertices)[Symbol.iterator]();case 5:if(t=(i=n.next()).done){o.next=13;break}a=i.value;if(!e.hasVertex(a)){o.next=10;break}o.next=10;return[a,e._vertices[a]];case 10:t=true;o.next=5;break;case 13:o.next=19;break;case 15:o.prev=15;o.t0=o["catch"](3);r=true;s=o.t0;case 19:o.prev=19;o.prev=20;if(!t&&n["return"]){n["return"]()}case 22:o.prev=22;if(!r){o.next=25;break}throw s;case 25:return o.finish(22);case 26:return o.finish(19);case 27:case"end":return o.stop()}},J,this,[[3,15,19,27],[20,,22,26]])})},{key:"edges",value:regeneratorRuntime.mark(function Y(){var e=this;var t,r,s,n,i,a,u,o,c,h,f,v;return regeneratorRuntime.wrap(function d(l){while(1)switch(l.prev=l.next){case 0:t=true;r=false;s=undefined;l.prev=3;n=Object.keys(e._edges)[Symbol.iterator]();case 5:if(t=(i=n.next()).done){l.next=37;break}a=i.value;u=true;o=false;c=undefined;l.prev=10;h=Object.keys(e._edges[a])[Symbol.iterator]();case 12:if(u=(f=h.next()).done){l.next=20;break}v=f.value;if(!e.hasEdge(a,v)){l.next=17;break}l.next=17;return[a,v,e._edges[a][v]];case 17:u=true;l.next=12;break;case 20:l.next=26;break;case 22:l.prev=22;l.t1=l["catch"](10);o=true;c=l.t1;case 26:l.prev=26;l.prev=27;if(!u&&h["return"]){h["return"]()}case 29:l.prev=29;if(!o){l.next=32;break}throw c;case 32:return l.finish(29);case 33:return l.finish(26);case 34:t=true;l.next=5;break;case 37:l.next=43;break;case 39:l.prev=39;l.t2=l["catch"](3);r=true;s=l.t2;case 43:l.prev=43;l.prev=44;if(!t&&n["return"]){n["return"]()}case 46:l.prev=46;if(!r){l.next=49;break}throw s;case 49:return l.finish(46);case 50:return l.finish(43);case 51:case"end":return l.stop()}},Y,this,[[3,39,43,51],[10,22,26,34],[27,,29,33],[44,,46,50]])})},{key:"verticesFrom",value:function I(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesFrom(t)}},{key:"_verticesFrom",value:regeneratorRuntime.mark(function q(e){var t=this;var r,s,n,i,a,u;return regeneratorRuntime.wrap(function o(c){while(1)switch(c.prev=c.next){case 0:r=true;s=false;n=undefined;c.prev=3;i=Object.keys(t._edges[e])[Symbol.iterator]();case 5:if(r=(a=i.next()).done){c.next=13;break}u=a.value;if(!t.hasEdge(e,u)){c.next=10;break}c.next=10;return[u,t._vertices[u],t._edges[e][u]];case 10:r=true;c.next=5;break;case 13:c.next=19;break;case 15:c.prev=15;c.t3=c["catch"](3);s=true;n=c.t3;case 19:c.prev=19;c.prev=20;if(!r&&i["return"]){i["return"]()}case 22:c.prev=22;if(!s){c.next=25;break}throw n;case 25:return c.finish(22);case 26:return c.finish(19);case 27:case"end":return c.stop()}},q,this,[[3,15,19,27],[20,,22,26]])})},{key:"verticesTo",value:function z(t){if(!this.hasVertex(t)){throw new e.VertexNotExistsError(t)}return this._verticesTo(t)}},{key:"_verticesTo",value:regeneratorRuntime.mark(function B(e){var t=this;var r,s,n,i,a,u;return regeneratorRuntime.wrap(function o(c){while(1)switch(c.prev=c.next){case 0:r=true;s=false;n=undefined;c.prev=3;i=Object.keys(t._reverseEdges[e])[Symbol.iterator]();case 5:if(r=(a=i.next()).done){c.next=13;break}u=a.value;if(!t.hasEdge(u,e)){c.next=10;break}c.next=10;return[u,t._vertices[u],t._edges[u][e]];case 10:r=true;c.next=5;break;case 13:c.next=19;break;case 15:c.prev=15;c.t4=c["catch"](3);s=true;n=c.t4;case 19:c.prev=19;c.prev=20;if(!r&&i["return"]){i["return"]()}case 22:c.prev=22;if(!s){c.next=25;break}throw n;case 25:return c.finish(22);case 26:return c.finish(19);case 27:case"end":return c.stop()}},B,this,[[3,15,19,27],[20,,22,26]])})},{key:"vertices_topologically",value:regeneratorRuntime.mark(function D(){var t=this;var r=regeneratorRuntime.mark(function l(t){var r,u,o,c,h,f,v,d,x;return regeneratorRuntime.wrap(function g(E){while(1)switch(E.prev=E.next){case 0:n.push(t);r=n.indexOf(t);if(!(r!==n.length-1)){E.next=5;break}u=n.slice(r+1).reverse();throw new e.CycleError(u);case 5:if(i[t]){E.next=36;break}o=true;c=false;h=undefined;E.prev=9;f=a.verticesTo(t)[Symbol.iterator]();case 11:if(o=(v=f.next()).done){E.next=18;break}d=s(v.value,1);x=d[0];return E.delegateYield(l(x),"t5",15);case 15:o=true;E.next=11;break;case 18:E.next=24;break;case 20:E.prev=20;E.t6=E["catch"](9);c=true;h=E.t6;case 24:E.prev=24;E.prev=25;if(!o&&f["return"]){f["return"]()}case 27:E.prev=27;if(!c){E.next=30;break}throw h;case 30:return E.finish(27);case 31:return E.finish(24);case 32:if(!a.hasVertex(t)){E.next=35;break}E.next=35;return[t,a._vertices[t]];case 35:i[t]=true;case 36:n.pop();case 37:case"end":return E.stop()}},l,this,[[9,20,24,32],[25,,27,31]])});var n,i,a,u,o,c,h,f,v,d;return regeneratorRuntime.wrap(function x(e){while(1)switch(e.prev=e.next){case 0:n=[];i={};a=t;u=true;o=false;c=undefined;e.prev=6;h=t.vertices()[Symbol.iterator]();case 8:if(u=(f=h.next()).done){e.next=16;break}v=s(f.value,1);d=v[0];if(i[d]){e.next=13;break}return e.delegateYield(r(d),"t7",13);case 13:u=true;e.next=8;break;case 16:e.next=22;break;case 18:e.prev=18;e.t8=e["catch"](6);o=true;c=e.t8;case 22:e.prev=22;e.prev=23;if(!u&&h["return"]){h["return"]()}case 25:e.prev=25;if(!o){e.next=28;break}throw c;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}},D,this,[[6,18,22,30],[23,,25,29]])})},{key:"clearEdges",value:function K(){var e=this;this.eachEdge(function(t,r){e.removeEdge(t,r)})}},{key:"clear",value:function L(){var e=this;this.eachVertex(function(t){e.destroyVertex(t)})}},{key:"hasCycle",value:function Q(){var e=this;var t={};var r={};var s=false;var n=function(i){if(t[i]){s=true;return}if(r[i]){return}r[i]=true;t[i]=true;e.eachVertexFrom(i,function(e){n(e);if(s){return false}});t[i]=false};this.eachVertex(function(e){n(e);if(s){return false}});return s}},{key:"hasPath",value:function U(e,t){var r=this;if(!this.hasVertex(e)||!this.hasVertex(t)){return false}var s={};var n=function(e){if(r.hasEdge(e,t)){return true}s[e]=true;var i=false;r.eachVertexFrom(e,function(e){if(!i&&!s[e]&&n(e)){i=true}});delete s[e];return i};return n(e)}},{key:"clone",value:function W(){var t=new e;this.eachVertex(function(e,r){t.addVertex(e,r)});this.eachEdge(function(e,r,s){t.addEdge(e,r,s)});return t}},{key:"transitiveReduction",value:function X(){var e=this.clone();e.eachVertex(function(t){e.eachVertex(function(r){if(e.hasEdge(t,r)){e.eachVertex(function(s){if(e.hasPath(r,s)){e.removeEdge(t,s)}})}})});return e}}]);return e}();e.exports=h;h.VertexExistsError=function(e){function t(e,r){o(this,t);this.vertices={};this.v(e,r)}i(t,e);u(t,{v:{value:function r(e,t){this.vertices[e]=t;this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph has "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);h.VertexNotExistsError=function(e){function t(e){o(this,t);this.vertices={};this.v(e)}i(t,e);u(t,{v:{value:function r(e){this.vertices[e]=undefined;this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this.vertices===1?"a vertex":"vertices";this.message="This graph does not have "+e+" '"+Object.keys(this.vertices).join("', '")+"'"}}});return t}(Error);h.EdgeExistsError=function(e){function t(e,r,s){o(this,t);this.edges={};this.e(e,r,s)}i(t,e);u(t,{e:{value:function r(e,t,s){this.edges[e]=n({},t,s);this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph has "+r+" "+t.join(", ")}}});return t}(Error);h.EdgeNotExistsError=function(e){function t(e,r){o(this,t);this.edges={};this.e(e,r)}i(t,e);u(t,{e:{value:function r(e,t){this.edges[e]=n({},t,undefined);this._refreshMessage();return this}},_refreshMessage:{value:function s(){var e=this;var t=[];Object.keys(this.edges).forEach(function(r){Object.keys(e.edges[r]).forEach(function(e){t.push("('"+r+"', '"+e+"')")})});var r=t.length===1?"an edge":"edges";this.message="This graph does not have "+r+" "+t.join(", ")}}});return t}(Error);h.HasConnectedEdgesError=function(e){function t(e){o(this,t);this.message="The '"+e+"' vertex has connected edges";this.key=e}i(t,e);return t}(Error);h.CycleError=function(e){function t(e){o(this,t);this.message="This graph contains a cycle: "+e;this.cycle=e}i(t,e);return t}(Error)}])});
//# sourceMappingURL=dist/js-graph.min.js.map

@@ -16,3 +16,3 @@ module.exports = {

'./node_modules/phantomjs-polyfill/bind-polyfill.js',
'./node_modules/babel/browser-polyfill.js',
//'./node_modules/babel/browser-polyfill.js',
'./test/test.js'

@@ -19,0 +19,0 @@ ],

{
"name": "js-graph",
"version": "1.1.2-alpha",
"version": "1.2.0-alpha",
"title": "Javascript Graph Datastructure",

@@ -33,3 +33,5 @@ "homepage": "https://github.com/mhelvens/js-graph",

],
"dependencies": {},
"dependencies": {
"babel": "~4"
},
"devDependencies": {

@@ -58,3 +60,3 @@ "babel": "~4",

"scripts": {
"build": "mkdir -p dist && cp src/js-graph.es6.js dist && webpack && uglifyjs dist/js-graph.js -mo dist/js-graph.min.js --in-source-map dist/js-graph.js.map --source-map dist/js-graph.min.js.map",
"build": "mkdir -p dist && cp src/js-graph.es6.js dist && webpack && uglifyjs dist/js-graph.js -mo dist/js-graph.min.js --in-source-map dist/js-graph.js.map --source-map dist/js-graph.min.js.map && uglifyjs dist/js-graph.full.js -mo dist/js-graph.full.min.js --in-source-map dist/js-graph.full.js.map --source-map dist/js-graph.full.min.js.map",
"test": "karma start",

@@ -61,0 +63,0 @@ "test-ci": "karma start ./karma.ci.conf.js"

@@ -16,1 +16,18 @@ js-graph

Feedback of any kind (questions, issues, pull requests) is greatly appreciated.
Files
-----
The `dist` directory offers different files for use in different circumstances.
Use the following table to determine which file to use in your situation.
| File | Description | File-size |
| ---------------------- | ------------------------------------------------------------------------------ | ---------:|
| `js-graph.es6.js` | For use in an ECMAScript 6 context, e.g., a modern browser or transpiler | 14.8 kB |
| `js-graph.js` | Requires you to first load `babel/polyfill.js` or `babel/polyfill-browser.js` | 36.0 kB |
| `js-graph.min.js` | Same as above, but minified | 16.2 kB |
| `js-graph.full.js` | Already includes `babel/polyfill.js`; ready for use in any context | 124.3 kB |
| `js-graph.full.min.js` | Same as above, but minified | 43.9 kB |
If you don't know which one you need, you probably want `js-graph.full.min.js`.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet