forked from fkling/JSNetworkX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsnetworkx-node.js
More file actions
133 lines (133 loc) · 63.6 KB
/
jsnetworkx-node.js
File metadata and controls
133 lines (133 loc) · 63.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
(function(global, factory) { function extractNS(){ var g = {}; return factory.call(g, global),g.jsnx;} if(typeof define === 'function' && define.amd){ /*AMD*/ define(extractNS); } else if (typeof module !== 'undefined' && module.exports){ /*node*/ module.exports = extractNS(); } else { factory.call(global, global); } }(this, function(window) {function h(a){throw a;}var ba=void 0,k=!0,l=null,m=!1;function ca(a){return function(){return a}}var p,da=this;
function r(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function s(a){return a!==ba}function ea(a){return"array"==r(a)}function t(a){var b=r(a);return"array"==b||"object"==b&&"number"==typeof a.length}function u(a){return"string"==typeof a}function fa(a){return"boolean"==typeof a}function ga(a){return"number"==typeof a}function ha(a){var b=typeof a;return"object"==b&&a!=l||"function"==b}var ia="closure_uid_"+(1E9*Math.random()>>>0),ja=0;
function ka(a,b,c){return a.call.apply(a.bind,arguments)}function la(a,b,c){a||h(Error());if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function ma(a,b,c){ma=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?ka:la;return ma.apply(l,arguments)}
function v(a,b){var c=a.split("."),d=da;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&s(b)?d[e]=b:d=d[e]?d[e]:d[e]={}}function na(a,b){function c(){}c.prototype=b.prototype;a.Qa=b.prototype;a.prototype=new c;a.prototype.constructor=a};var w=Array.prototype,oa=w.indexOf?function(a,b,c){return w.indexOf.call(a,b,c)}:function(a,b,c){c=c==l?0:0>c?Math.max(0,a.length+c):c;if(u(a))return!u(b)||1!=b.length?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},x=w.forEach?function(a,b,c){w.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=u(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},pa=w.filter?function(a,b,c){return w.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,g=u(a)?a.split(""):
a,n=0;n<d;n++)if(n in g){var q=g[n];b.call(c,q,n,a)&&(e[f++]=q)}return e},y=w.map?function(a,b,c){return w.map.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=Array(d),f=u(a)?a.split(""):a,g=0;g<d;g++)g in f&&(e[g]=b.call(c,f[g],g,a));return e};function qa(a,b){if(a.reduce)return a.reduce(b,0);var c=0;x(a,function(d,e){c=b.call(ba,c,d,e,a)});return c}
function ra(a,b){var c;a:{c=a.length;for(var d=u(a)?a.split(""):a,e=0;e<c;e++)if(e in d&&b.call(ba,d[e],e,a)){c=e;break a}c=-1}return 0>c?l:u(a)?a.charAt(c):a[c]}function sa(a){return w.concat.apply(w,arguments)}function ua(a){var b=a.length;if(0<b){for(var c=Array(b),d=0;d<b;d++)c[d]=a[d];return c}return[]}function va(a,b,c,d){w.splice.apply(a,wa(arguments,1))}function wa(a,b,c){return 2>=arguments.length?w.slice.call(a,b):w.slice.call(a,b,c)}
function xa(a,b,c){if(!t(a)||!t(b)||a.length!=b.length)return m;var d=a.length;c=c||ya;for(var e=0;e<d;e++)if(!c(a[e],b[e]))return m;return k}function Aa(a,b){return a>b?1:a<b?-1:0}function ya(a,b){return a===b}function Ba(a){for(var b=[],c=0;c<a;c++)b[c]=0;return b}function Ca(a){if(!arguments.length)return[];for(var b=[],c=0;;c++){for(var d=[],e=0;e<arguments.length;e++){var f=arguments[e];if(c>=f.length)return b;d.push(f[c])}b.push(d)}};var z="StopIteration"in da?da.StopIteration:Error("StopIteration");function A(){}A.prototype.next=function(){h(z)};A.prototype.B=function(){return this};function Ea(a){if(a instanceof A)return a;if("function"==typeof a.B)return a.B(m);if(t(a)){var b=0,c=new A;c.next=function(){for(;;){b>=a.length&&h(z);if(b in a)return a[b++];b++}};return c}h(Error("Not implemented"))}
function B(a,b,c){if(t(a))try{x(a,b,c)}catch(d){d!==z&&h(d)}else{a=Ea(a);try{for(;;)b.call(c,a.next(),ba,a)}catch(e){e!==z&&h(e)}}}function C(a,b,c){var d=Ea(a);a=new A;a.next=function(){for(;;){var a=d.next();return b.call(c,a,ba,d)}};return a}function Fa(a,b){var c={};B(a,function(a){c=b.call(ba,c,a)});return c}function F(a){if(t(a))return ua(a);a=Ea(a);var b=[];B(a,function(a){b.push(a)});return b}function Ga(a,b){try{return Ea(a).next()}catch(c){return c!=z&&h(c),b}};function G(a,b,c){for(var d in a)b.call(c,a[d],d,a)}function Ha(a,b,c){var d={},e;for(e in a)d[e]=b.call(c,a[e],e,a);return d}function H(a){var b=0,c;for(c in a)b++;return b}function Ia(a){for(var b in a)return b}function Ja(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function I(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}function Ka(a){for(var b in a)return m;return k}function La(a){for(var b in a)delete a[b]}function J(a,b){b in a&&delete a[b]}function K(a,b,c){return b in a?a[b]:c}
function Ma(a){var b={},c;for(c in a)b[c]=a[c];return b}var Na="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function L(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<Na.length;f++)c=Na[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}}
function Oa(a){var b=arguments.length;if(1==b&&ea(arguments[0]))return Oa.apply(l,arguments[0]);b%2&&h(Error("Uneven number of arguments"));for(var c={},d=0;d<b;d+=2)c[arguments[d]]=arguments[d+1];return c};function Pa(a){if("function"==typeof a.w)return a.w();if(u(a))return a.split("");if(t(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return Ja(a)};function Qa(a,b){this.h={};this.j=[];var c=arguments.length;if(1<c){c%2&&h(Error("Uneven number of arguments"));for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else a&&this.W(a)}p=Qa.prototype;p.t=0;p.Q=0;p.e=function(){return this.t};p.w=function(){Ra(this);for(var a=[],b=0;b<this.j.length;b++)a.push(this.h[this.j[b]]);return a};p.L=function(){return 0==this.t};p.clear=function(){this.h={};this.Q=this.t=this.j.length=0};
p.remove=function(a){return Object.prototype.hasOwnProperty.call(this.h,a)?(delete this.h[a],this.t--,this.Q++,this.j.length>2*this.t&&Ra(this),k):m};function Ra(a){if(a.t!=a.j.length){for(var b=0,c=0;b<a.j.length;){var d=a.j[b];Object.prototype.hasOwnProperty.call(a.h,d)&&(a.j[c++]=d);b++}a.j.length=c}if(a.t!=a.j.length){for(var e={},c=b=0;b<a.j.length;)d=a.j[b],Object.prototype.hasOwnProperty.call(e,d)||(a.j[c++]=d,e[d]=1),b++;a.j.length=c}}
p.set=function(a,b){Object.prototype.hasOwnProperty.call(this.h,a)||(this.t++,this.j.push(a),this.Q++);this.h[a]=b};p.W=function(a){var b;a instanceof Qa?(Ra(a),b=a.j.concat(),a=a.w()):(b=I(a),a=Ja(a));for(var c=0;c<b.length;c++)this.set(b[c],a[c])};p.R=function(){return new Qa(this)};
p.B=function(a){Ra(this);var b=0,c=this.j,d=this.h,e=this.Q,f=this,g=new A;g.next=function(){for(;;){e!=f.Q&&h(Error("The map has changed since the iterator was created"));b>=c.length&&h(z);var g=c[b++];return a?g:d[g]}};return g};function M(a){this.h=new Qa;a&&this.W(a)}function Sa(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+(a[ia]||(a[ia]=++ja)):b.substr(0,1)+a}p=M.prototype;p.e=function(){return this.h.e()};p.add=function(a){this.h.set(Sa(a),a)};p.W=function(a){a=Pa(a);for(var b=a.length,c=0;c<b;c++)this.add(a[c])};p.remove=function(a){return this.h.remove(Sa(a))};p.clear=function(){this.h.clear()};p.L=function(){return this.h.L()};
p.contains=function(a){a=Sa(a);return Object.prototype.hasOwnProperty.call(this.h.h,a)};function Ta(a,b){for(var c=new M,d=Pa(b),e=0;e<d.length;e++){var f=d[e];a.contains(f)&&c.add(f)}return c}function Ua(a,b){for(var c=a.R(),d=Pa(b),e=d.length,f=0;f<e;f++)c.remove(d[f]);return c}p.w=function(){return this.h.w()};p.R=function(){return new M(this)};p.B=function(){return this.h.B(m)};function Va(a){if(a!=l)try{a.clear()}catch(b){h(Error("Input graph is not a jsnx graph type"))}else a=new N;return a}
function Wa(a,b,c){var d=l;if(a.hasOwnProperty("adj"))try{return d=Xa(a.adj,b,a.i()),"graph"in a&&"object"===r(a.graph)&&(d.graph=Ma(a.graph)),"node"in a&&"object"===r(a.node)&&(d.node=Ha(a.node,function(a){return Ma(a)})),d}catch(e){h(Error("Input is not a correct jsnx graph"))}if("object"===r(a))try{return Xa(a,b,c)}catch(f){try{return Ya(a,b)}catch(g){h(Error("Input is not known type."))}}if(t(a))try{return Za(a,b)}catch(n){h(Error("Input is not valid edge list"))}return d}
v("jsnx.to_networkx_graph",Wa);v("jsnx.convert_to_undirected",function(a){return a.H()});v("jsnx.convert_to_undirected",function(a){return a.v()});v("jsnx.to_dict_of_lists",function(a,b){function c(a){return 0<=oa(b,a)}var d={};b!=l?b=O(b):(b=a,c=function(a){return b.n(a)});P(b,function(b){d[b]=pa(a.D(b),c)});return d});
function Ya(a,b){var c=Va(b);c.g(a);if(c.i()&&!c.c()){var d={};G(a,function(a,b){x(a,function(a){a in d||c.a(b,a)});d[b]=1})}else{var e=[];G(a,function(a,b){x(a,function(a){e.push([b,a])})});c.b(e)}return c}
function Xa(a,b,c){var d=Va(b),e,f;d.g(a);c?d.c()?(d.i()?(e=[],G(a,function(a,b){t(a)&&h(Error());G(a,function(a,c){G(a,function(a,d){e.push([b,c,d,a])})})})):(e=[],G(a,function(a,b){t(a)&&h(Error());G(a,function(a,c){G(a,function(a){e.push([b,c,a])})})})),d.b(e)):d.i()?(f=new M,G(a,function(a,b){t(a)&&h(Error());G(a,function(a,c){f.contains([b,c].toString())||(e=[],G(a,function(a,d){e.push([b,c,d,a])}),d.b(e),f.add([c,b].toString()))})})):(f=new M,G(a,function(a,b){t(a)&&h(Error());G(a,function(a,
c){f.contains([b,c].toString())||(e=[],G(a,function(a){e.push([b,c,a])}),d.b(e),f.add([c,b].toString()))})})):d.i()&&!d.c()?(f=new M,G(a,function(a,b){t(a)&&h(Error());G(a,function(a,c){f.contains([b,c].toString())||(d.a(b,c,a),f.add([c,b].toString()))})})):(e=[],G(a,function(a,b){t(a)&&h(Error());G(a,function(a,c){e.push([b,c,a])})}),d.b(e));return d}function Za(a,b){var c=Va(b);c.b(a);return c};function $a(a){this.name="JSNetworkXException";this.message=a}$a.prototype=Error();$a.prototype.constructor=$a;v("jsnx.JSNetworkXException",$a);function Q(a){$a.call(this,a);this.name="JSNetworkXError"}na(Q,$a);v("jsnx.JSNetworkXError",Q);function ab(a){$a.call(this,a);this.name="JSNetworkXPointlessConcept"}na(ab,$a);v("jsnx.JSNetworkXPointlessConcept",ab);function bb(a){$a.call(this,a);this.name="JSNetworkXAlgorithmError"}na(bb,$a);v("jsnx.JSNetworkXAlgorithmError",bb);
function cb(a){bb.call(this,a);this.name="JSNetworkXUnfeasible"}na(cb,bb);v("jsnx.JSNetworkXUnfeasible",cb);function db(a){cb.call(this,a);this.name="JSNetworkXNoPath"}na(db,cb);v("jsnx.JSNetworkXNoPath",db);function fb(a){bb.call(this,a);this.name="JSNetworkXUnbounded"}na(fb,bb);v("jsnx.JSNetworkXUnbounded",fb);function gb(a){return Fa(R(a),function(a,c){a[c[0]]=c[1];return a})}function hb(a){return a instanceof A||"function"==r(a.B)}function ib(a){if(a instanceof N)return a.G();if(u(a)||t(a))return a.length;if(jb(a))return H(a);h(new TypeError)}function P(a,b,c,d){fa(c)&&(d=c,c=l);if(d){var e=b;b=function(a){e.apply(this,a)}}a instanceof N?B(R(a),b,c):hb(a)?B(a,b,c):t(a)||u(a)?x(a,b,c):ha(a)&&P(I(a),b,c)}v("jsnx.forEach",P);
function S(a,b,c){if(a instanceof N)return S(R(a),b,c);if(t(a))return y(a,b,c);if(hb(a))return C(a,b,c);if(ha(a))return Ha(a,b,c);h(new TypeError)}function kb(a){var b=arguments,c=b[0];if(t(c))return Ca.apply(l,b);if(hb(c)){var c=new A,d=b.length;c.next=function(){for(var a=[],c=0;c<d;c++)a.push(b[c].next());return a};return c}if(ha(c))return Ca.apply(l,y(b,I));h(new TypeError)}function lb(a,b){a="function"==r(b)?O(S(a,function(){return b.apply(l,arguments)})):O(a);return Math.max.apply(l,a)}
function T(a,b,c){if(0===arguments.length)return Ea([]);1===arguments.length?(b=a,a=0,c=1):2===arguments.length?c=1:3===arguments.length&&0===arguments[2]&&h("range() step argument must not be zero");var d=new A,e=0>c,f=a,g;d.next=function(){(e&&f<=b||!e&&f>=b)&&h(z);g=f;f+=c;return g};return d}
function mb(a){var b=O(a),c=b.length;if(2>c)return new A;var d=O(T(2));a=new A;a.next=function(){var a=y(d,function(a){return b[a]});this.next=function(){var a=m,e;for(e=2;e--;)if(d[e]!=e+c-2){a=k;break}a||h(z);d[e]+=1;for(a=e+1;2>a;a++)d[a]=d[a-1]+1;return y(d,function(a){return b[a]})};return a};return a}
function nb(a){var b=O(a),c=b.length,d=ga(2)?2:c;if(d>c)return new A;var e=O(T(c)),f=O(T(c,c-d,-1));a=new A;var g=new A,n,q=k;a.next=function(){this.next=n.next;return y(e.slice(0,d),function(a){return b[a]})};g.next=function(){return q};n=U(g,function(a){a||h(z);q=m;return T(d-1,-1,-1)},function(a){if(!q)if(f[a]-=1,0===f[a])e.splice.apply(e,[a,e.length].concat(e.slice(a+1).concat([e[a]]))),f[a]=c-a;else{var g=f[a],n=e[a];e[a]=e[e.length-g];e[e.length-g]=n;q=k;return R([y(e.slice(0,d),function(a){return b[a]})])}},
function(a){return a});return a}function O(a){if(a instanceof N)return O(R(a));if(t(a))return ua(a);if(hb(a))return F(a);if(ha(a))return I(a);h(new TypeError)}v("jsnx.toArray",O);function ob(a){var b=[];G(a,function(a,d){b.push([d,a])});return b}function V(a){var b=new A,c=Ea(I(a));b.next=function(){var b=c.next();return[b,a[b]]};return b}function R(a){if(a instanceof N)return R(a.adj);"object"===r(a)&&(!t(a)&&!hb(a))&&(a=I(a));return Ea(a)}
function U(a,b){var c=new A,d=wa(arguments,1);if(0===d.length)return a;try{a=Ea(a)}catch(e){return c.next=function(){"Not implemented"===e.message&&h(new TypeError)},c}var f=l;c.next=function(){var b,e;try{for(;!s(b);)b=f.next()}catch(q){for(;!s(e)||!s(b);)e=a.next(),b=d[0](e);if(hb(b))return f=U.apply(l,sa([b],wa(d,1))),c.next();f=l}return b};return c}v("jsnx.sentinelIterator",function(a,b){var c=new A;c.next=function(){return Ga(a,b)};return c});
function jb(a){var b=Object.prototype.hasOwnProperty;if(!a||"object"!==r(a)||a.nodeType||a==a.window)return m;try{if(a.constructor&&!b.call(a,"constructor")&&!b.call(a.constructor.prototype,"isPrototypeOf"))return m}catch(c){return m}for(var d in a);return d===ba||b.call(a,d)}
function W(a,b){b=b||[];var c=r(a);if("object"==c&&jb(a)||"array"==c){var d=ra(b,function(b){return a===b[0]});if(d!==l)return d[1];if(a.R)return d=[a,a.R()],b.push(d),d[1];c="array"==c?[]:{};d=[a,c];b.push(d);for(var e in a)c[e]=W(a[e],b);return c}return a}function pb(a){function b(){}var c={},d;b.prototype=a.constructor.prototype;for(d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);c=W(c);a=new b;for(d in c)a[d]=c[d];return a}var rb=function qb(b,c){return 0===c?b:qb(c,b%c)};function sb(a){var b=[];tb(new ub,a,b);return b.join("")}function ub(){this.V=ba}
function tb(a,b,c){switch(typeof b){case "string":vb(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==l){c.push("null");break}if(ea(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],tb(a,a.V?a.V.call(b,String(f),e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),vb(f,c),c.push(":"),
tb(a,a.V?a.V.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:h(Error("Unknown type: "+typeof b))}}var wb={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},xb=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function vb(a,b){b.push('"',a.replace(xb,function(a){if(a in wb)return wb[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return wb[a]=e+b.toString(16)}),'"')};var X={La:function(a){return Math.floor(Math.random()*a)},Ra:function(a,b){return a+Math.random()*(b-a)},Fa:function(a,b,c){return Math.min(Math.max(a,b),c)},va:function(a,b){var c=a%b;return 0>c*b?c+b:c},Ia:function(a,b,c){return a+c*(b-a)},Ka:function(a,b,c){return Math.abs(a-b)<=(c||1E-6)},Z:function(a){return X.va(a,360)},ha:function(a){return a*Math.PI/180},Aa:function(a){return 180*a/Math.PI},Da:function(a,b){return b*Math.cos(X.ha(a))},Ea:function(a,b){return b*Math.sin(X.ha(a))},Ba:function(a,
b,c,d){return X.Z(X.Aa(Math.atan2(d-b,c-a)))},Ca:function(a,b){var c=X.Z(b)-X.Z(a);180<c?c-=360:-180>=c&&(c=360+c);return c},Oa:function(a){return 0==a?0:0>a?-1:1},Ja:function(a,b,c,d){c=c||function(a,b){return a==b};d=d||function(b){return a[b]};for(var e=a.length,f=b.length,g=[],n=0;n<e+1;n++)g[n]=[],g[n][0]=0;for(var q=0;q<f+1;q++)g[0][q]=0;for(n=1;n<=e;n++)for(q=1;q<=e;q++)c(a[n-1],b[q-1])?g[n][q]=g[n-1][q-1]+1:g[n][q]=Math.max(g[n-1][q],g[n][q-1]);for(var D=[],n=e,q=f;0<n&&0<q;)c(a[n-1],b[q-
1])?(D.unshift(d(n-1,q-1)),n--,q--):g[n-1][q]>g[n][q-1]?n--:q--;return D},o:function(a){return qa(arguments,function(a,c){return a+c})},oa:function(a){return X.o.apply(l,arguments)/arguments.length},Pa:function(a){var b=arguments.length;if(2>b)return 0;var c=X.oa.apply(l,arguments),b=X.o.apply(l,y(arguments,function(a){return Math.pow(a-c,2)}))/(b-1);return Math.sqrt(b)},Ha:function(a){return isFinite(a)&&0==a%1},Ga:function(a){return isFinite(a)&&!isNaN(a)},Na:function(a,b){return Math.floor(a+(b||
2E-15))},Ma:function(a,b){return Math.ceil(a-(b||2E-15))}};function N(a,b){if(!(this instanceof N))return new N(a,b);this.graph={};this.node={};this.adj={};a!=l&&Wa(a,this);L(this.graph,b||{});this.edge=this.adj}v("jsnx.classes.Graph",N);v("jsnx.Graph",N);N.__name__="Graph";N.prototype.sa=l;N.prototype.graph=N.prototype.sa;N.prototype.da=l;N.prototype.node=N.prototype.da;N.prototype.ma=l;N.prototype.adj=N.prototype.ma;N.prototype.qa=l;N.prototype.edge=N.prototype.qa;
N.prototype.name=function(a){if(s(a))this.graph.name=a.toString();else return this.graph.name||""};N.prototype.name=N.prototype.name;N.prototype.toString=function(){return this.name()};N.prototype.toString=N.prototype.toString;N.prototype.f=function(a){a in this.adj||h({name:"KeyError",message:"Graph does not contain node "+a+"."});return this.adj[a]};N.prototype.get_node=N.prototype.f;
N.prototype.C=function(a,b){b!=l||(b={});"object"!==r(b)&&h(new Q("The attr_dict argument must be an object."));a in this.adj?L(this.node[a],b||{}):(this.adj[a]={},this.node[a]=b||{})};N.prototype.add_node=N.prototype.C;N.prototype.g=function(a,b){var c,d,e,f,g;b!=l||(b={});P(a,function(a){c=!(a in this.adj);ea(a)?(d=a[0],e=a[1],d in this.adj?(g=this.node[d],L(g,b,e)):(this.adj[d]={},f=Ma(b),L(f,e),this.node[d]=f)):c?(this.adj[a]={},this.node[a]=Ma(b)):L(this.node[a],b)},this)};
N.prototype.add_nodes_from=N.prototype.g;N.prototype.O=function(a){var b=this.adj,c;a in this.node||h(new Q("The node "+a+" is not in the graph"));c=I(b[a]);J(this.node,a);x(c,function(c){J(b[c],a)});J(b,a)};N.prototype.remove_node=N.prototype.O;N.prototype.U=function(a){var b=this.adj;P(a,function(a){try{J(this.node,a),G(b[a],function(d,f){J(b[f],a)}),J(b,a)}catch(d){}},this)};N.prototype.remove_nodes_from=N.prototype.U;N.prototype.z=function(a){return a?V(this.node):R(I(this.adj))};
N.prototype.nodes_iter=N.prototype.z;N.prototype.nodes=function(a){return F(this.z(a))};N.prototype.nodes=N.prototype.nodes;N.prototype.G=function(){return H(this.adj)};N.prototype.number_of_nodes=N.prototype.G;N.prototype.u=function(){return H(this.adj)};N.prototype.order=N.prototype.u;N.prototype.n=function(a){return!ea(a)&&a in this.adj};N.prototype.has_node=N.prototype.n;
N.prototype.a=function(a,b,c){c=c||{};"object"!==r(c)&&h(new Q("The attr_dict argument must be an object."));a in this.adj||(this.adj[a]={},this.node[a]={});b in this.adj||(this.adj[b]={},this.node[b]={});var d=K(this.adj[a],b+"",{});L(d,c);this.adj[a][b]=d;this.adj[b][a]=d};N.prototype.add_edge=N.prototype.a;
N.prototype.b=function(a,b){b=b||{};"object"!==r(b)&&h(new Q("The attr_dict argument must be an object."));P(a,function(a){var d=ib(a),e,f,g;3===d?(e=a[0],f=a[1],g=a[2]):2===d?(e=a[0],f=a[1],g={}):h(new Q("Edge tuple "+a.toString()+" must be a 2-tuple or 3-tuple."));e in this.adj||(this.adj[e]={},this.node[e]={});f in this.adj||(this.adj[f]={},this.node[f]={});a=K(this.adj[e],f,{});L(a,b,g);this.adj[e][f]=a;this.adj[f][e]=a},this)};N.prototype.add_edges_from=N.prototype.b;
N.prototype.la=function(a,b,c){c=c||{};u(b)||(c=b,b="weight");this.b(S(a,function(a){var c={};c[b]=a[2];s(c[b])||h(new TypeError("Values must consist of three elements: "+sb(a)));return[a[0],a[1],c]}),c)};N.prototype.add_weighted_edges_from=N.prototype.la;N.prototype.r=function(a,b){try{J(this.adj[a],b),a!=b&&J(this.adj[b],a)}catch(c){c instanceof TypeError&&h(new Q("The edge "+a+"-"+b+" is not in the graph")),h(c)}};N.prototype.remove_edge=N.prototype.r;
N.prototype.A=function(a){P(a,function(a){var c=a[0];a=a[1];c in this.adj&&a in this.adj[c]&&(J(this.adj[c],a),c!=a&&J(this.adj[a],c))},this)};N.prototype.remove_edges_from=N.prototype.A;N.prototype.S=function(a,b){return a in this.adj&&b in this.adj[a]};N.prototype.has_edge=N.prototype.S;N.prototype.D=function(a){a in this.adj||h(new Q("The node "+a+" is not in the graph."));return O(this.adj[a])};N.prototype.neighbors=N.prototype.D;
N.prototype.M=function(a){a in this.adj||h(new Q("The node "+a+" is not in the graph."));return R(this.adj[a])};N.prototype.neighbors_iter=N.prototype.M;N.prototype.q=function(a,b){return F(this.k(a,b))};N.prototype.edges=N.prototype.q;
N.prototype.k=function(a,b){fa(a)&&(b=a,a=l);var c={},d,e;d=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):V(this.adj);return b?U(d,function(a){e=a[0];var b=new A,d=V(a[1]);b.next=function(){try{return d.next()}catch(a){a===z&&(c[e]=1),h(a)}};return b},function(a){if(!(a[0]in c))return[e,a[0],a[1]]}):U(d,function(a){e=a[0];var b=new A,d=R(a[1]);b.next=function(){try{return d.next()}catch(a){a===z&&(c[e]=1),h(a)}};return b},function(a){if(!(a in c))return[e,a]})};
N.prototype.edges_iter=N.prototype.k;N.prototype.X=function(a,b,c){s(c)||(c=l);return a in this.adj?K(this.adj[a],b.toString(),c):c};N.prototype.get_edge_data=N.prototype.X;N.prototype.na=function(){return O(S(this.p(),function(a){return I(a[1])}))};N.prototype.adjacency_list=N.prototype.na;N.prototype.p=function(){return V(this.adj)};N.prototype.adjacency_iter=N.prototype.p;N.prototype.l=function(a,b){return a!=l&&this.n(a)?this.m(a,b).next()[1]:gb(F(this.m(a,b)))};N.prototype.degree=N.prototype.l;
N.prototype.m=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):V(this.adj);return b?S(c,function(a){var c=a[0];a=a[1];var f=0,g;for(g in a)f+=+K(a[g],b,1);f+=+(c in a&&K(a[c],b,1));return[c,f]}):S(c,function(a){return[a[0],H(a[1])+ +(a[0]in a[1])]})};N.prototype.degree_iter=N.prototype.m;N.prototype.clear=function(){this.name("");La(this.adj);La(this.node);La(this.graph)};N.prototype.clear=N.prototype.clear;N.prototype.copy=function(){return pb(this)};
N.prototype.copy=N.prototype.copy;N.prototype.i=ca(m);N.prototype.is_multigraph=N.prototype.i;N.prototype.c=ca(m);N.prototype.is_directed=N.prototype.c;N.prototype.v=function(){var a=new Y;a.name(this.name());a.g(this);a.b(function(){var a;return U(this.p(),function(c){a=c[0];return V(c[1])},function(c){return[a,c[0],W(c[1])]})}.call(this));a.graph=W(this.graph);a.node=W(this.node);return a};N.prototype.to_directed=N.prototype.v;N.prototype.H=function(){return pb(this)};
N.prototype.to_undirected=N.prototype.H;N.prototype.s=function(a){a=this.d(a);var b=new this.constructor,c=b.adj,d=this.adj;P(a,function(a){var b={};c[a]=b;G(d[a],function(d,n){n in c&&(b[n]=d,c[n][a]=d)})});P(b,function(a){b.node[a]=this.node[a]},this);b.graph=this.graph;return b};N.prototype.subgraph=N.prototype.s;N.prototype.xa=function(){return y(pa(ob(this.adj),function(a){return a[0]in a[1]}),function(a){return a[0]})};N.prototype.nodes_with_selfloops=N.prototype.xa;
N.prototype.P=function(a){return a?y(pa(ob(this.adj),function(a){return a[0]in a[1]}),function(a){var c=a[0];return[c,c,a[1][c]]}):y(pa(ob(this.adj),function(a){return a[0]in a[1]}),function(a){return[a[0],a[0]]})};N.prototype.selfloop_edges=N.prototype.P;N.prototype.ya=function(){return this.P().length};N.prototype.number_of_selfloops=N.prototype.ya;N.prototype.size=function(a){var b=X.o.apply(l,Ja(this.l(l,a)))/2;return a!=l?b:Math.floor(b)};N.prototype.size=N.prototype.size;
N.prototype.F=function(a,b){return a==l?Math.floor(this.size()):b in this.adj[a]?1:0};N.prototype.number_of_edges=N.prototype.F;N.prototype.ka=function(a,b){var c=O(a),d=c[0],c=S(wa(c,1),function(a){return[d,a]});this.b(c,b)};N.prototype.add_star=N.prototype.ka;N.prototype.ja=function(a,b){var c=O(a),c=Ca(wa(c,0,c.length-1),wa(c,1));this.b(c,b)};N.prototype.add_path=N.prototype.ja;N.prototype.ia=function(a,b){var c=O(a),c=Ca(c,sa(wa(c,1),[c[0]]));this.b(c,b)};N.prototype.add_cycle=N.prototype.ia;
N.prototype.d=function(a){return a!=l?this.n(a)?R([a.toString()]):function(a,c){var d=new A,e=U(a,function(a){if(a in c)return a.toString()});d.next=function(){try{return e.next()}catch(a){a instanceof TypeError&&h(new Q("nbunch is not a node or a sequence of nodes")),h(a)}};return d}(a,this.adj):R(this.adj)};N.prototype.nbunch_iter=N.prototype.d;function Y(a,b){if(!(this instanceof Y))return new Y(a,b);this.graph={};this.node={};this.adj={};this.pred={};this.succ=this.adj;a!=l&&Wa(a,this);L(this.graph,b||{});this.edge=this.adj}v("jsnx.classes.DiGraph",Y);v("jsnx.DiGraph",Y);na(Y,N);Y.__name__="DiGraph";Y.prototype.C=function(a,b){b!=l||(b={});"object"!==r(b)&&h(new Q("The attr_dict argument must be an object."));a in this.succ?L(this.node[a],b):(this.succ[a]={},this.pred[a]={},this.node[a]=b)};Y.prototype.add_node=Y.prototype.C;
Y.prototype.g=function(a,b){var c,d,e,f,g;b!=l||(b={});P(R(a),function(a){c=!(a in this.succ);ea(a)?(d=a[0],e=a[1],d in this.succ?(g=this.node[d],L(g,b,e)):(this.succ[d]={},this.pred[d]={},f=Ma(b),L(f,e),this.node[d]=f)):c?(this.succ[a]={},this.pred[a]={},this.node[a]=Ma(b)):L(this.node[a],b)},this)};Y.prototype.add_nodes_from=Y.prototype.g;
Y.prototype.O=function(a){a in this.node||h(new Q("The node "+a+" is not in the graph"));var b=this.succ[a];J(this.node,a);G(b,function(b,d){J(this.pred[d],a)},this);J(this.succ,a);G(this.pred[a],function(b,d){J(this.succ[d],a)},this);J(this.pred,a)};Y.prototype.remove_node=Y.prototype.O;
Y.prototype.U=function(a){var b;P(a,function(a){a in this.succ&&(b=this.succ[a],J(this.node,a),G(b,function(b,e){J(this.pred[e],a)},this),J(this.succ,a),G(this.pred[a],function(b,e){J(this.succ[e],a)},this),J(this.pred,a))},this)};Y.prototype.remove_nodes_from=Y.prototype.U;
Y.prototype.a=function(a,b,c){c=c||{};"object"!==r(c)&&h(new Q("The attr_dict argument must be an object."));a in this.succ||(this.succ[a]={},this.pred[a]={},this.node[a]={});b in this.succ||(this.succ[b]={},this.pred[b]={},this.node[b]={});var d=K(this.adj[a],""+b,{});L(d,c);this.succ[a][b]=d;this.pred[b][a]=d};Y.prototype.add_edge=Y.prototype.a;
Y.prototype.b=function(a,b){b=b||{};"object"!==r(b)&&h(new Q("The attr_dict argument must be an object."));P(a,function(a){var d=ib(a),e,f,g;3===d?(e=a[0],f=a[1],g=a[2]):2===d?(e=a[0],f=a[1],g={}):h(new Q("Edge tuple "+a.toString()+" must be a 2-tuple or 3-tuple."));e in this.succ||(this.succ[e]={},this.pred[e]={},this.node[e]={});f in this.succ||(this.succ[f]={},this.pred[f]={},this.node[f]={});a=K(this.adj[e],f,{});L(a,b,g);this.succ[e][f]=a;this.pred[f][e]=a},this)};
Y.prototype.add_edges_from=Y.prototype.b;Y.prototype.r=function(a,b){try{J(this.succ[a],b),J(this.pred[b],a)}catch(c){c instanceof TypeError&&h(new Q("The edge "+a+"-"+b+" is not in the graph")),h(c)}};Y.prototype.remove_edge=Y.prototype.r;Y.prototype.A=function(a){P(a,function(a){var c=a[0];a=a[1];c in this.succ&&a in this.succ[c]&&(J(this.succ[c],a),J(this.pred[a],c))},this)};Y.prototype.remove_edges_from=Y.prototype.A;Y.prototype.ua=function(a,b){return a in this.succ&&b in this.succ[a]};
Y.prototype.has_successor=Y.prototype.ua;Y.prototype.ta=function(a,b){return a in this.pred&&b in this.pred[a]};Y.prototype.has_predecessor=Y.prototype.ta;Y.prototype.$=function(a){a in this.succ||h(new Q("The node "+a+" is not in the digraph."));return R(this.succ[a])};Y.prototype.successors_iter=Y.prototype.$;Y.prototype.fa=function(a){a in this.pred||h(new Q("The node "+a+" is not in the digraph."));return R(this.pred[a])};Y.prototype.predecessors_iter=Y.prototype.fa;
Y.prototype.ga=function(a){a in this.succ||h(new Q("The node "+a+" is not in the digraph."));return O(this.succ[a])};Y.prototype.successors=Y.prototype.ga;Y.prototype.za=function(a){a in this.succ||h(new Q("The node "+a+" is not in the digraph."));return O(this.pred[a])};Y.prototype.predecessors=Y.prototype.za;Y.prototype.D=Y.prototype.ga;Y.prototype.neighbors=Y.prototype.D;Y.prototype.M=Y.prototype.$;Y.prototype.neighbors_iter=Y.prototype.M;
Y.prototype.k=function(a,b){fa(a)&&(b=a,a=l);var c,d,e;c=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):ob(this.adj);return b?U(c,function(a){d=a[0];e=a[1];return V(e)},function(a){return[d,a[0],a[1]]}):U(c,function(a){d=a[0];e=a[1];return V(e)},function(a){return[d,a[0]]})};Y.prototype.edges_iter=Y.prototype.k;Y.prototype.T=Y.prototype.k;Y.prototype.out_edges_iter=Y.prototype.T;Y.prototype.Y=N.prototype.q;Y.prototype.out_edges=Y.prototype.Y;
Y.prototype.K=function(a,b){fa(a)&&(b=a,a=l);var c,d;c=a!=l?S(this.d(a),function(a){return[a,this.pred[a]]},this):ob(this.pred);return b?U(c,function(a){d=a[0];return V(a[1])},function(a){return[a[0],d,a[1]]}):U(c,function(a){d=a[0];return V(a[1])},function(a){return[a[0],d]})};Y.prototype.in_edges_iter=Y.prototype.K;Y.prototype.J=function(a,b){return O(this.K(a,b))};Y.prototype.in_edges=Y.prototype.J;
Y.prototype.m=function(a,b){var c;c=a!=l?kb(S(this.d(a),function(a){return[a,this.succ[a]]},this),S(this.d(a),function(a){return[a,this.pred[a]]},this)):kb(V(this.succ),V(this.pred));return u(b)?S(c,function(a){var c=a[0][1],f=a[1][1],g=0,n;for(n in c)g+=+K(c[n],b,1);for(n in f)g+=+K(f[n],b,1);return[a[0][0],g]}):S(c,function(a){return[a[0][0],ib(a[0][1])+ib(a[1][1])]})};Y.prototype.degree_iter=Y.prototype.m;
Y.prototype.I=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.pred[a]]},this):V(this.pred);return b!=l?S(c,function(a){var c=0,f=a[1],g;for(g in f)c+=+K(f[g],b,1);return[a[0],c]}):S(c,function(a){return[a[0],H(a[1])]})};Y.prototype.in_degree_iter=Y.prototype.I;
Y.prototype.N=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.succ[a]]},this):V(this.succ);return b!=l?S(c,function(a){var c=0,f=a[1],g;for(g in f)c+=+K(f[g],b,1);return[a[0],c]}):S(c,function(a){return[a[0],H(a[1])]})};Y.prototype.out_degree_iter=Y.prototype.N;Y.prototype.ba=function(a,b){return a!=l&&this.n(a)?this.I(a,b).next()[1]:gb(this.I(a,b))};Y.prototype.in_degree=Y.prototype.ba;Y.prototype.ea=function(a,b){return a!=l&&this.n(a)?this.N(a,b).next()[1]:gb(this.N(a,b))};
Y.prototype.out_degree=Y.prototype.ea;Y.prototype.clear=function(){La(this.succ);La(this.pred);La(this.node);La(this.graph)};Y.prototype.clear=Y.prototype.clear;Y.prototype.i=ca(m);Y.prototype.is_multigraph=Y.prototype.i;Y.prototype.c=ca(k);Y.prototype.is_directed=Y.prototype.c;Y.prototype.v=function(){return pb(this)};Y.prototype.to_directed=Y.prototype.v;
Y.prototype.H=function(a){var b=new N;b.name(this.name());b.g(this);var c=this.pred,d;a?b.b(U(this.p(),function(a){d=a[0];return V(a[1])},function(a){if(a[0]in c[d])return[d,a[0],W(a[1])]})):b.b(U(this.p(),function(a){d=a[0];return V(a[1])},function(a){return[d,a[0],W(a[1])]}));b.graph=W(this.graph);b.node=W(this.node);return b};Y.prototype.to_undirected=Y.prototype.H;
Y.prototype.reverse=function(a){(a=!s(a)||a)?(a=new this.constructor(l,{name:"Reverse of ("+this.name()+")"}),a.g(this),a.b(S(this.k(l,k),function(a){return[a[1],a[0],W(a[2])]})),a.graph=W(this.graph),a.node=W(this.node)):(a=this.succ,this.succ=this.pred,this.pred=a,this.adj=this.succ,a=this);return a};Y.prototype.reverse=Y.prototype.reverse;
Y.prototype.s=function(a){a=this.d(a);var b=new this.constructor,c=b.succ,d=b.pred,e=this.succ;P(a,function(a){c[a]={};d[a]={}});P(c,function(a){var b=c[a];G(e[a],function(e,q){q in c&&(b[q]=e,d[q][a]=e)})});P(b,function(a){b.node[a]=this.node[a]},this);b.graph=this.graph;return b};Y.prototype.subgraph=Y.prototype.s;function yb(a,b){var c=T(a),d,e,f=new A;try{e=[c.next()]}catch(g){return g!==z&&h(g),f}f.next=function(){0===e.length&&h(z);return e.splice(0,1)[0]};return U(f,function(a){d=a;return T(b)},function(){try{var a=c.next();e.push(a);return[d,a]}catch(b){b!==z&&h(b)}})}function zb(a,b,c){c=Ab(b,c);c.b(yb(b,a));return c}v("jsnx.generators.classic.full_rary_tree",zb);v("jsnx.full_rary_tree",zb);function Bb(a,b,c){b=1===a?2:Math.floor((1-Math.pow(a,b+1))/(1-a));c=Ab(b,c);c.b(yb(b,a));return c}
v("jsnx.generators.classic.balanced_tree",Bb);v("jsnx.balanced_tree",Bb);function Cb(a,b){var c=Ab(a,b);c.name("complete_graph("+a+")");1<a&&c.b(c.c()?nb(T(a)):mb(T(a)));return c}v("jsnx.generators.classic.complete_graph",Cb);v("jsnx.complete_graph",Cb);function Db(a,b){var c=Eb(a,b);c.name("cycle_graph("+a+")");1<a&&c.a(a-1,0);return c}v("jsnx.generators.classic.cycle_graph",Db);v("jsnx.cycle_graph",Db);
function Ab(a,b){a instanceof N&&(b=a,a=l);a!=l||(a=0);var c;b!=l?(c=b,c.clear()):c=new N;c.g(T(a));c.name("empty_graph("+a+")");return c}v("jsnx.generators.classic.empty_graph",Ab);v("jsnx.empty_graph",Ab);
function Fb(a,b,c,d){var e=Ab(0,d);e.name("grid_2d_graph");d=F(T(a));var f=F(T(b));x(d,function(a){x(f,function(b){e.C([a,b].toString())})});B(T(1,a),function(a){x(f,function(b){e.a([a,b].toString(),[a-1,b].toString())})});x(d,function(a){B(T(1,b),function(b){e.a([a,b].toString(),[a,b-1].toString())})});e.c()&&(B(T(0,a-1),function(a){x(f,function(b){e.a([a,b].toString(),[a+1,b].toString())})}),x(d,function(a){B(T(0,b-1),function(b){e.a([a,b].toString(),[a,b+1].toString())})}));c&&(2<b&&(x(d,function(a){e.a([a,
0].toString(),[a,b-1].toString())}),e.c()&&x(d,function(a){e.a([a,b-1].toString(),[a,0].toString())})),2<a&&(x(f,function(b){e.a([0,b].toString(),[a-1,b].toString())}),e.c()&&x(f,function(b){e.a([a-1,b].toString(),[0,b].toString())})),e.name("periodic_grid_2d_graph("+a+","+b+")"));return e}v("jsnx.generators.classic.grid_2d_graph",Fb);v("jsnx.grid_2d_graph",Fb);function Gb(a){a=Ab(0,a);a.name("null_graph()");return a}v("jsnx.generators.classic.null_graph",Gb);v("jsnx.null_graph",Gb);
function Eb(a,b){var c=Ab(a,b);c.name("path_graph("+a+")");c.b(C(T(a-1),function(a){return[a,a+1]}));return c}v("jsnx.generators.classic.path_graph",Eb);v("jsnx.path_graph",Eb);function Hb(a){a=Ab(1,a);a.name("null_graph()");return a}v("jsnx.generators.classic.trivial_graph",Hb);v("jsnx.trivial_graph",Hb);v("jsnx.fast_gnp_random_graph",function(a,b,c){c!=l||(c=m);var d=Ab(a);d.name("fast_gnp_random_graph("+a+","+b+")");if(0>=b||1<=b)return Jb(a,b,c);var e=1,f=-1;b=Math.log(1-b);if(c)for(d=new Y(d);e<a;){c=Math.log(1-Math.random());f=f+1+Math.floor(c/b);for(e===f&&(f+=1);f>=a&&e<a;)f-=a,e+=1,e==f&&(f+=1);e<a&&d.a(e,f)}else for(;e<a;){c=Math.log(1-Math.random());for(f=f+1+Math.floor(c/b);f>=e&&e<a;)f-=e,e+=1;e<a&&d.a(e,f)}return d});
function Jb(a,b,c){var d;d=c?new Y:new N;d.g(T(a));d.name("gnp_random_graph("+a+","+b+")");if(0>=b)return d;if(1<=b)return Cb(a,d);a=d.c()?nb(T(a)):mb(T(a));B(a,function(a){Math.random()<b&&d.a(a[0],a[1])});return d}v("jsnx.gnp_random_graph",Jb);v("jsnx.binomial_graph",Jb);v("jsnx.erdos_renyi_graph",Jb);v("jsnx.havel_hakimi_graph",function(a,b){Kb(a)||h(new Q("Invalid degree sequence"));b!=l&&(b.c()&&h(new Q("Directed Graph not supported")),b.i()&&h(new Q("Havel-Hakimi requires simple graph")));var c=a.length,d=Ab(c,b);if(0===c||0===Math.max.apply(l,a))return d;for(c=F(S(d,function(b){return[a[b],b]}));0<c.length;){c.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:+a[1]-+b[1]});if(0>c[0][0])return m;var e=c.pop();if(0===e[0])break;if(e[0]>c.length)return m;for(var f=c.length,g=f-e[0];g<f;g++)d.a(e[1],
c[g][1]),c[g][0]-=1}d.name("havel_hakimi_graph "+d.u()+" nodes "+d.size()+" edges");return d});function Lb(){var a=new N;a.g(T(34));a.name("Zachary's Karate Club");var b=0;x("0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0;1 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0;1 1 0 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 0;1 1 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1;1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 0;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1;0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1;0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 1;0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1;1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 1;0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 1;0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 0".split(";"),
function(c){P(c.split(" "),function(c,e){"1"===c&&a.a(b,e)});b+=1});return a}v("jsnx.generators.social.karate_club_graph",Lb);v("jsnx.karate_club_graph",Lb);
function Mb(){var a=new N;a.g("Evelyn Jefferson;Laura Mandeville;Theresa Anderson;Brenda Rogers;Charlotte McDowd;Frances Anderson;Eleanor Nye;Pearl Oglethorpe;Ruth DeSand;Verne Sanderson;Myra Liddel;Katherina Rogers;Sylvia Avondale;Nora Fayette;Helen Lloyd;Dorothy Murchison;Olivia Carleton;Flora Price".split(";"),{pa:0});a.g("E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14".split(" "),{pa:1});a.b([["Evelyn Jefferson","E1"],["Evelyn Jefferson","E2"],["Evelyn Jefferson","E3"],["Evelyn Jefferson","E4"],
["Evelyn Jefferson","E5"],["Evelyn Jefferson","E6"],["Evelyn Jefferson","E8"],["Evelyn Jefferson","E9"],["Laura Mandeville","E1"],["Laura Mandeville","E2"],["Laura Mandeville","E3"],["Laura Mandeville","E5"],["Laura Mandeville","E6"],["Laura Mandeville","E7"],["Laura Mandeville","E8"],["Theresa Anderson","E2"],["Theresa Anderson","E3"],["Theresa Anderson","E4"],["Theresa Anderson","E5"],["Theresa Anderson","E6"],["Theresa Anderson","E7"],["Theresa Anderson","E8"],["Theresa Anderson","E9"],["Brenda Rogers",
"E1"],["Brenda Rogers","E3"],["Brenda Rogers","E4"],["Brenda Rogers","E5"],["Brenda Rogers","E6"],["Brenda Rogers","E7"],["Brenda Rogers","E8"],["Charlotte McDowd","E3"],["Charlotte McDowd","E4"],["Charlotte McDowd","E5"],["Charlotte McDowd","E7"],["Frances Anderson","E3"],["Frances Anderson","E5"],["Frances Anderson","E6"],["Frances Anderson","E8"],["Eleanor Nye","E5"],["Eleanor Nye","E6"],["Eleanor Nye","E7"],["Eleanor Nye","E8"],["Pearl Oglethorpe","E6"],["Pearl Oglethorpe","E8"],["Pearl Oglethorpe",
"E9"],["Ruth DeSand","E5"],["Ruth DeSand","E7"],["Ruth DeSand","E8"],["Ruth DeSand","E9"],["Verne Sanderson","E7"],["Verne Sanderson","E8"],["Verne Sanderson","E9"],["Verne Sanderson","E12"],["Myra Liddel","E8"],["Myra Liddel","E9"],["Myra Liddel","E10"],["Myra Liddel","E12"],["Katherina Rogers","E8"],["Katherina Rogers","E9"],["Katherina Rogers","E10"],["Katherina Rogers","E12"],["Katherina Rogers","E13"],["Katherina Rogers","E14"],["Sylvia Avondale","E7"],["Sylvia Avondale","E8"],["Sylvia Avondale",
"E9"],["Sylvia Avondale","E10"],["Sylvia Avondale","E12"],["Sylvia Avondale","E13"],["Sylvia Avondale","E14"],["Nora Fayette","E6"],["Nora Fayette","E7"],["Nora Fayette","E9"],["Nora Fayette","E10"],["Nora Fayette","E11"],["Nora Fayette","E12"],["Nora Fayette","E13"],["Nora Fayette","E14"],["Helen Lloyd","E7"],["Helen Lloyd","E8"],["Helen Lloyd","E10"],["Helen Lloyd","E11"],["Helen Lloyd","E12"],["Dorothy Murchison","E8"],["Dorothy Murchison","E9"],["Olivia Carleton","E9"],["Olivia Carleton","E11"],
["Flora Price","E9"],["Flora Price","E11"]]);return a}v("jsnx.generators.social.davis_southern_women_graph",Mb);v("jsnx.davis_southern_women_graph",Mb);
function Nb(){var a=new N;a.a("Acciaiuoli","Medici");a.a("Castellani","Peruzzi");a.a("Castellani","Strozzi");a.a("Castellani","Barbadori");a.a("Medici","Barbadori");a.a("Medici","Ridolfi");a.a("Medici","Tornabuoni");a.a("Medici","Albizzi");a.a("Medici","Salviati");a.a("Salviati","Pazzi");a.a("Peruzzi","Strozzi");a.a("Peruzzi","Bischeri");a.a("Strozzi","Ridolfi");a.a("Strozzi","Bischeri");a.a("Ridolfi","Tornabuoni");a.a("Tornabuoni","Guadagni");a.a("Albizzi","Ginori");a.a("Albizzi","Guadagni");a.a("Bischeri",
"Guadagni");a.a("Guadagni","Lamberteschi");return a}v("jsnx.generators.social.florentine_families_graph",Nb);v("jsnx.florentine_families_graph",Nb);function Ob(a,b){a.c()&&h(new Q("triangles() is not defined for directed graphs."));if(b!=l&&a.n(b))return Math.floor(Pb(a,b).next()[2]/2);var c={};B(Pb(a,b),function(a){c[a[0]]=Math.floor(a[2]/2)});return c}v("jsnx.triangles",Ob);
function Pb(a,b){a.i()&&h(new Q("Not defined for multigraphs."));var c;c=b!=l?U(a.d(b),function(b){return[b,a.f(b)]}):V(a.adj);return C(c,function(b){var c=new M(I(b[1])),f=0;c.remove(b[0]);B(c,function(b){var d=new M(I(a.f(b)));d.remove(b);f+=Ta(c,d).e()});return[b[0],c.e(),f]})}
function Qb(a,b,c){a.i()&&h(new Q("Not defined for multigraphs."));u(c)||(c="weight");var d;d=0===a.q().length?1:lb(a.q(k),function(a){return K(a[2],c,1)});b=b!=l?U(a.d(b),function(b){return[b,a.f(b)]}):V(a.adj);return C(b,function(b){var f=b[0],g=new M(I(b[1]));g.remove(f);var n=0,q=new M;B(g,function(b){var e=K(a.f(f)[b],c,1)/d;q.add(b);var aa=Ua(new M(I(a.f(b))),q);B(Ta(g,aa),function(g){var q=K(a.f(b)[g],c,1)/d;g=K(a.f(f)[g],c,1)/d;n+=Math.pow(e*q*g,1/3)})});return[f,g.e(),2*n]})}
v("jsnx.average_clustering",function(a,b,c,d){2===arguments.length?u(b)?(c=b,b=l):fa(b)&&(d=b,b=l):3===arguments.length&&fa(c)&&(d=c,c=l);d!=l||(d=k);var e=Ja(Rb(a,b,c));d||(e=pa(e,function(a){return 0<a}));return X.o.apply(X,e)/e.length});function Rb(a,b,c){a.c()&&h(new Q("Clustering algorithms are not defined for directed graphs."));c=c!=l?Qb(a,b,c):Pb(a,b);var d={};B(c,function(a){d[a[0]]=0===a[2]?0:a[2]/(a[1]*(a[1]-1))});return b!=l&&a.n(b)?Ja(d)[0]:d}v("jsnx.clustering",Rb);
v("jsnx.transitivity",function(a){var b=0,c=0;B(Pb(a),function(a){c+=a[1]*(a[1]-1);b+=a[2]});return 0===b?0:b/c});v("jsnx.square_clustering",function(a,b){var c=b==l?R(a):a.d(b),d={};B(c,function(b){var c=d[b]=0;B(mb(I(a.f(b))),function(g){var n=g[0];g=g[1];var q=Ta(new M(I(a.f(n))),I(a.f(g)));q.remove(b);q=q.e();d[b]+=q;var D=q+1,E=a.f(n);g in E&&(D+=1);c+=(H(a.f(n))-D)*(H(a.f(g))-D)+q});0<c&&(d[b]/=c)});return b!=l&&a.n(b)?Ja(d)[0]:d});function Sb(a){var b=-1,c={},d=new M;B(a.p(),function(a){var e=new M(I(a[1]));e.remove(a[0]);var f=e.e();f>b?(c[a[0]]=d=e,b=f):c[a[0]]=e});var e=new M(I(c)),f=Ua(e,d),g=new M,n=[],q=[];a=new A;a.next=function(){0===f.e()&&0===n.length&&h(z);var a,E;if(0<f.e())a=Ea(f).next(),f.remove(a);else{var aa=n.pop();e=aa[0];g=aa[1];f=aa[2];q.pop();return this.next()}q.push(a);e.remove(a);g.add(a);var ta=c[a],aa=Ta(e,ta),ta=Ta(g,ta);if(0===aa.e()&&(0===ta.e()&&(E=ua(q)),q.pop(),E))return E;if(0===ta.e()&&1===
aa.e())return E=sa(q,aa.w()),q.pop(),E;var eb=aa.e(),Da=-1,Ib,za;for(E=Ea(ta);(a=Ga(E,l))!==l&&!(a=Ta(aa,c[a]),za=a.e(),za>Da&&(Ib=a,Da=za,Da===eb)););if(Da===eb)return q.pop(),this.next();b=-1;for(E=Ea(aa);(a=Ga(E,l))!==l&&!(a=Ta(aa,c[a]),za=a.e(),za>b&&(d=a,b=za,b===eb-1)););Da>b&&(d=Ib);n.push([e,g,f]);e=aa;g=ta;f=Ua(e,d);return this.next()};return a}v("jsnx.find_cliques",Sb);
v("jsnx.find_cliques_recursive",function(a){var b={};B(a.p(),function(a){var c=new M(I(a[1]));c.remove(a[0]);b[a[0]]=c});if(Ka(b))return[];a=new M(I(b));var c=new M,d=[];Tb(b,a,c,[],d);return d});
function Tb(a,b,c,d,e){var f=-1,g=b.e(),n,q,D,E;for(q=Ea(c);(D=Ga(q,l))!==l;)if(D=Ta(b,a[D]),E=D.e(),E>f&&(n=D,f=E,E===g))return;B(b,function(c){c=Ta(b,a[c]);var d=c.e();d>f&&(n=c,f=d)});g=Ua(b,n);B(g,function(f){b.remove(f);d.push(f);var g=a[f];f=Ta(b,g);g=Ta(c,g);f.L()&&g.L()?e.push(ua(d)):g.L()&&1===f.e()?e.push(sa(d,f.w())):Tb(a,f,g,d,e);c.add(d.pop())})}v("jsnx.graph_clique_number",function(a,b){b!=l||(b=Sb(a));var c=0;P(b,function(a){c=a.length>c?a.length:c});return c});
v("jsnx.graph_number_of_cliques",function(a,b){b!=l||(b=Sb(a));return O(b).length});function Ub(a,b,c){c=c!=l?F(c):F(Sb(a));b!=l||(b=a.nodes());var d;if(ea(b))d={},x(b,function(a){d[a]=pa(c,function(b){return 0<=oa(b,a)||0<=oa(b,a+"")}).length});else{var e=b;d=pa(c,function(a){return 0<=oa(a,e)||0<=oa(a,e+"")}).length}return d}v("jsnx.number_of_cliques",Ub);function Vb(a,b){if(a.u()!=b.u())return m;var c,d=a.l(),e=Ob(a),f=Ub(a),g=[];for(c in d)g.push([d[c],e[c],f[c]]);g.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:a[1]!==b[1]?a[1]-b[1]:a[2]-b[2]});var d=b.l(),e=Ob(b),f=Ub(b),n=[];for(c in d)n.push([d[c],e[c],f[c]]);n.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:a[1]!==b[1]?a[1]-b[1]:a[2]-b[2]});return!xa(g,n,function(a,b){return xa(a,b)})?m:k}v("jsnx.algorithms.isomorphism.could_be_isomorphic",Vb);v("jsnx.could_be_isomorphic",Vb);
function Wb(a,b){if(a.u()!=b.u())return m;var c,d=a.l(),e=Ob(a),f=[];for(c in d)f.push([d[c],e[c]]);f.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:a[1]-b[1]});var d=b.l(),e=Ob(b),g=[];for(c in d)g.push([d[c],e[c]]);g.sort(function(a,b){return a[0]!==b[0]?a[0]-b[0]:a[1]-b[1]});return!xa(f,g,function(a,b){return xa(a,b)})?m:k}v("jsnx.algorithms.isomorphism.fast_could_be_isomorphic",Wb);v("jsnx.fast_could_be_isomorphic",Wb);
function Xb(a,b){if(a.u()!=b.u())return m;var c=Ja(a.l());c.sort();var d=Ja(b.l());d.sort();return!xa(c,d)?m:k}v("jsnx.algorithms.isomorphism.faster_could_be_isomorphic",Xb);v("jsnx.faster_could_be_isomorphic",Xb);function Yb(){}Yb.aa=function(){return Yb.ca?Yb.ca:Yb.ca=new Yb};Yb.prototype.wa=0;Yb.aa();function Zb(a){if(!t(a))return m;for(var b=0,c=a.length;b<c;b++)if(window.isNaN(a[b]))return m;return k}v("jsnx.utils.is_list_of_ints",Zb);v("jsnx.utils.cumulative_sum",function(a){var b=0;return C(a,function(a){return b+=a})});v("jsnx.utils.generate_unique_node",function(){return":"+(Yb.aa().wa++).toString(36)});function Kb(a,b){if("eg"===b)return $b(a);if(b==l||"hh"===b)return ac(a);h(new $a("`opt_method` must be 'eg' or 'hh'"))}v("jsnx.is_valid_degree_sequence",Kb);function ac(a){if(0===a.length)return k;if(!Zb(a)||0>Math.min.apply(l,a)||0!==X.o.apply(l,a)%2)return m;for(a=ua(a);0<a.length;){w.sort.call(a,Aa);if(0>a[0])break;var b=a.pop();if(0===b)return k;if(b>a.length)break;for(var c=a.length-1,b=a.length-(b+1);c>b;c--)a[c]-=1}return m}v("jsnx.is_valid_degree_sequence_havel_hakimi",ac);
function $b(a){if(0===a.length)return k;if(!Zb(a)||0>Math.min.apply(l,a)||0!==X.o.apply(l,a)%2)return m;var b=a.length,c=ua(a).sort(function(a,b){return b-a}),d=[],e;e=1;for(a=c.length;e<a;e++)c[e]<c[e-1]&&d.push(e);var f,g;e=0;for(a=d.length;e<a;e++)if(f=X.o.apply(l,c.slice(0,d[e])),g=d[e]*(d[e]-1)+X.o.apply(l,F(C(T(d[e],b),function(a){return Math.min(d[e],c[a])}))),f>g)return m;return k}v("jsnx.is_valid_degree_sequence_erdos_gallai",$b);function bc(a){try{return cc(a),k}catch(b){if(b instanceof cb)return m;h(b)}}v("jsnx.algorithms.dag.is_directed_acyclic_graph",bc);v("jsnx.is_directed_acyclic_graph",bc);
function cc(a,b){a.c()||h(new Q("Topological sort not defined on undirected graphs."));var c={},d=[],e={};b!=l||(b=a.z());P(b,function(b){if(!(b in e))for(b=[b];0<b.length;){var g=b[b.length-1];if(g in e)b.pop();else{c[g]=k;var n=[];G(a.f(g),function(a,b){b in e||(b in c&&h(new cb("Graph contains a cycle")),n.push(b))});0<n.length?b.push.apply(b,n):(e[g]=k,va(d,ba,0,g.toString()))}}});return d}v("jsnx.algorithms.dag.topological_sort",cc);v("jsnx.topological_sort",cc);
function dc(a,b){function c(a,b,d,e){b.add(e);G(a.f(e),function(e,q){if(b.contains(q))b.contains(q)&&!(0<=oa(d,q))&&h(new cb("Graph contains a cycle"));else if(!c(a,b,d,q))return m});va(d,ba,0,e.toString());return k}a.c()||h(new Q("Topological sort not defined on undirected graphs."));var d=new M,e=[];b!=l||(b=a.z());P(b,function(b){!(0<=oa(e,b))&&!c(a,d,e,b)&&h(new cb("Graph contains a cycle"))});return e}v("jsnx.algorithms.dag.topological_sort_recursive",dc);
v("jsnx.topological_sort_recursive",dc);var fc=function ec(b){b.c()||h(new Q("is_aperiodic not defined for undirected graphs."));var c=b.z().next(),d={};d[c]=0;for(var c=[c],e=0,f=1;0<c.length;){var g=[];x(c,function(c){G(b.f(c),function(b,D){D in d?e=rb(e,d[c]-d[D]+1):(g.push(D),d[D]=f)})});c=g;f+=1}return ib(d)===ib(b)?1===e:1===e&&ec(b.s(Ua(new M(b.nodes()),I(d))))};v("jsnx.algorithms.dag.is_aperiodic",fc);v("jsnx.is_aperiodic",fc);function gc(a,b,c){var d={},e=0,f={};for(f[b]=1;0<H(f);){b=f;f={};G(b,function(b,c){c in d||(d[c]=e,L(f,a.f(c)))});if(ga(c)&&c<=e)break;e+=1}return d}v("jsnx.algorithms.shortest_paths.unweighted.single_source_shortest_path_length",gc);v("jsnx.single_source_shortest_path_length",gc);function hc(a,b){var c={};P(a,function(d){c[d]=gc(a,d,b)});return c}v("jsnx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path_length",hc);v("jsnx.all_pairs_shortest_path_length",hc);
function ic(a,b,c){b=b.toString();c=c.toString();c=jc(a,b,c);a=c[0];b=c[1];c=c[2];for(var d=[];c!=l;)d.push(c),c=b[c];for(c=a[d[0]];c!=l;)d.unshift(c),c=a[c];return d}v("jsnx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path",ic);v("jsnx.bidirectional_shortest_path",ic);
function jc(a,b,c){(!s(b)||!s(c))&&h(new $a("Bidirectional shortest path called without source or target"));var d={},e={};if(c===b)return d[c]=l,e[b]=l,[d,e,b];var f,g;a.c()?(f=a.fa,g=a.$):g=f=a.M;d[b]=l;e[c]=l;for(var n=[b],q=[c],D,E;0<n.length&&0<q.length&&!E;)n.length<=q.length?(D=n,n=[],x(D,function(b){E||B(g.call(a,b),function(a){E||(a in d||(n.push(a),d[a]=b),a in e&&(E=[d,e,a]))})})):(D=q,q=[],x(D,function(b){E||B(f.call(a,b),function(a){E||(a in e||(e[a]=b,q.push(a)),a in d&&(E=[d,e,a]))})}));
if(E)return E;h(new db("No path between "+b+" and "+c+"."))}function kc(a,b,c){b=b.toString();var d=0,e={};e[b]=1;var f={};f[b]=[b];if(0===c)return f;for(;0<H(e)&&!(b=e,e={},G(b,function(b,c){G(a.f(c),function(a,b){b in f||(f[b]=f[c].concat([b]),e[b]=1)})}),d+=1,s(c)&&c<=d););return f}v("jsnx.algorithms.shortest_paths.unweighted.single_source_shortest_path",kc);v("jsnx.single_source_shortest_path",kc);function lc(a,b){var c={};P(a,function(d){c[d]=kc(a,d,b)});return c}
v("jsnx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path",lc);v("jsnx.all_pairs_shortest_path",lc);function mc(a,b,c,d,e){b=b.toString();var f=0,g=[b],n={};n[b]=f;var q={};for(q[b]=[];0<g.length&&!(f+=1,b=g,g=[],x(b,function(b){G(a.f(b),function(a,c){c in n?n[c]===f&&q[c].push(b):(q[c]=[b],n[c]=f,g.push(c))})}),d!=l&&d<=f););return c!=l?(c=c.toString(),e?!(c in q)?[[],-1]:[q[c],n[c]]:!(c in q)?[]:q[c]):e?[q,n]:q}v("jsnx.algorithms.shortest_paths.unweighted.predecessor",mc);
v("jsnx.predecessor",mc);function nc(a,b,c){var d=b;"function"==r(b)&&(d={},B(a.z(),function(a){d[a]=b(a)}));return!s(c)||c?oc(a,d):pc(a,d)}v("jsnx.relabel_nodes",nc);
function pc(a,b){var c=new M(I(b)),d;if(0<Ta(c,b).e()){c=new Y(ob(b));c.A(c.P());try{d=cc(c)}catch(e){e instanceof cb&&h(new cb("The node label sets are overlapping and no ordering can resolve the mapping. Use copy=True."))}d.reverse()}else d=c;var f=a.i(),g=a.c(),n;B(d,function(c){var d;c in b&&(d=b[c],a.n(c)||h(new Q("Node "+c+" is not in the graph.")),a.C(d,a.node[c]),f?(n=y(a.q(c,k,k),function(a){return[d,a[1],a[2],a[3]]}),g&&(n=sa(n,y(a.J(c,k,k),function(a){return[a[0],d,a[2],a[3]]})))):(n=y(a.q(c,
k),function(a){return[d,a[1],a[2]]}),g&&(n=sa(n,y(a.J(c,k),function(a){return[a[0],d,a[2]]})))),a.O(c),a.b(n))});return a}function oc(a,b){var c=new a.constructor;c.name("("+a.name()+")");a.i()?c.b(C(a.k(l,k,k),function(a){return[K(b,a[0],a[0]),K(b,a[1],a[1]),a[2],Ma(a[3])]})):c.b(C(a.k(l,k),function(a){return[K(b,a[0],a[0]),K(b,a[1],a[1]),Ma(a[2])]}));c.g(C(R(a),function(a){return K(b,a,a)}));var d={},e;for(e in a.node)d[K(b,e,e)]=Ma(a.node[e]);L(c.node,d);L(c.graph,Ma(a.graph));return c}
v("jsnx.convert_node_labels_to_integers",function(a,b,c,d){3===arguments.length&&fa(c)?(d=c,c=l):2===arguments.length&&(fa(b)?(d=b,b=l):u(b)&&(c=b,b=l));b!=l||(b=0);c!=l||(c="default");d!=l||(d=k);var e={},f,g,n,q;if("default"===c){f=a.nodes();g=0;n=b;for(q=f.length;g<q;g++,n++)e[f[g]]=n}else if("sorted"===c){f=a.nodes();f.sort();g=0;n=b;for(q=f.length;g<q;g++,n++)e[f[g]]=n}else if("increasing degree"===c){f=F(a.m());f.sort(function(a,b){return a[1]-b[1]});g=0;n=b;for(q=f.length;g<q;g++,n++)e[f[g][0]]=
n}else if("decreasing degree"===c){f=F(a.m());f.sort(function(a,b){return b[1]-a[1]});g=0;n=b;for(q=f.length;g<q;g++,n++)e[f[g][0]]=n}else h(new Q("Unkown node ordering: "+c));g=nc(a,e);g.name("("+a.name()+")_with_int_labels");d||(g.node_labels=e);return g});function Z(a,b){if(!(this instanceof Z))return new Z(a,b);N.call(this,a,b)}na(Z,N);v("jsnx.classes.MultiGraph",Z);v("jsnx.MultiGraph",Z);Z.__name__="MultiGraph";
Z.prototype.a=function(a,b,c,d){var e,f;c!=l&&(!u(c)&&!ga(c))&&(d=c,c=l);d=d||{};"object"!==r(d)&&h(new Q("The attr_dict argument must be an object."));a in this.adj||(this.adj[a]={},this.node[a]={});b in this.adj||(this.adj[b]={},this.node[b]={});if(b in this.adj[a]){f=this.adj[a][b];if(c==l)for(c=H(f);c in f;)c+=1;e=K(f,""+c,{});L(e,d);f[c]=e}else c!=l||(c=0),e={},L(e,d),f=Oa(c,e),this.adj[a][b]=f,this.adj[b][a]=f};Z.prototype.add_edge=Z.prototype.a;
Z.prototype.b=function(a,b){b=b||{};"object"!==r(b)&&h(new Q("The attr_dict argument must be an object."));P(a,function(a){var d=ib(a),e,f,g=l,n={};4===d?(e=a[0],f=a[1],g=a[2],n=a[3]):3===d?(e=a[0],f=a[1],n=a[2]):2===d?(e=a[0],f=a[1]):h(new Q("Edge tuple "+sb(a)+" must be a 2-tuple, 3-tuple or 4-tuple."));a=e in this.adj?K(this.adj[e],f,{}):{};if(g==l)for(g=H(a);g in a;)g+=1;a=K(a,g,{});L(a,b,n);this.a(e,f,g,a)},this)};Z.prototype.add_edges_from=Z.prototype.b;
Z.prototype.r=function(a,b,c){(!(a in this.adj)||!(b in this.adj[a]))&&h(new Q("The edge "+a+"-"+b+" is not in the graph"));var d=this.adj[a][b];c!=l?(c in d||h(new Q("The edge "+a+"-"+b+" with key "+c+" is not in the graph")),J(d,c)):J(d,Ia(d));0===H(d)&&(J(this.adj[a],b),a!=b&&J(this.adj[b],a))};Z.prototype.remove_edge=Z.prototype.r;Z.prototype.A=function(a){P(a,function(a){try{this.r(a[0],a[1],a[2])}catch(c){c instanceof Q||h(c)}},this)};Z.prototype.remove_edges_from=Z.prototype.A;
Z.prototype.S=function(a,b,c){return c!=l?a in this.adj&&b in this.adj[a]&&c in this.adj[a][b]:a in this.adj&&b in this.adj[a]};Z.prototype.has_edge=Z.prototype.S;Z.prototype.q=function(a,b,c){return F(this.k(a,b,c))};Z.prototype.edges=Z.prototype.q;
Z.prototype.k=function(a,b,c){fa(a)&&(fa(b)&&(c=b),b=a,a=l);var d={},e,f;a=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):V(this.adj);return b?U(a,function(a){e=a[0];var b=new A,c=V(a[1]);b.next=function(){try{return c.next()}catch(a){a===z&&(d[e]=1),h(a)}};return b},function(a){f=a[0];if(!(f in d))return V(a[1])},function(a){return c?[e,f,a[0],a[1]]:[e,f,a[1]]}):U(a,function(a){e=a[0];var b=new A,c=V(a[1]);b.next=function(){try{return c.next()}catch(a){a===z&&(d[e]=1),h(a)}};return b},
function(a){f=a[0];if(!(f in d))return V(a[1])},function(a){return c?[e,f,a[0]]:[e,f]})};Z.prototype.edges_iter=Z.prototype.k;Z.prototype.X=function(a,b,c,d){s(d)||(d=l);return a in this.adj&&b in this.adj[a]?c!=l?K(this.adj[a][b],""+c,d):this.adj[a][b]:d};Z.prototype.get_edge_data=Z.prototype.X;
Z.prototype.m=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):V(this.adj);return b!=l?C(c,function(a){var c=a[0];a=a[1];var f=0;G(a,function(a){G(a,function(a){f+=K(a,b,1)})});c in a&&G(a[c],function(a){f+=K(a,b,1)});return[c,f]}):C(c,function(a){var b=a[0];a=a[1];var c=0;G(a,function(a){c+=H(a)});return[b,c+ +(b in a&&H(a[b]))]})};Z.prototype.degree_iter=Z.prototype.m;Z.prototype.i=ca(k);Z.prototype.is_multigraph=Z.prototype.i;Z.prototype.c=ca(m);
Z.prototype.is_directed=Z.prototype.c;Z.prototype.v=function(){var a=new $;a.g(this);a.b(function(){var a,c;return U(this.p(),function(c){a=c[0];return V(c[1])},function(a){c=a[0];return V(a[1])},function(d){return[a,c,d[0],W(d[1])]})}.call(this));a.graph=W(this.graph);a.node=W(this.node);return a};Z.prototype.to_directed=Z.prototype.v;
Z.prototype.P=function(a,b){var c=[];a?b?G(this.adj,function(a,b){b in a&&G(a[b],function(a,d){c.push([b,b,d,a])})}):G(this.adj,function(a,b){b in a&&G(a[b],function(a){c.push([b,b,a])})}):b?G(this.adj,function(a,b){b in a&&G(a[b],function(a,d){c.push([b,b,d])})}):G(this.adj,function(a,b){b in a&&G(a[b],function(){c.push([b,b])})});return c};Z.prototype.selfloop_edges=Z.prototype.P;Z.prototype.F=function(a,b){return a==l?this.size():a in this.adj&&b in this.adj[a]?H(this.adj[a][b]):0};
Z.prototype.number_of_edges=Z.prototype.F;Z.prototype.s=function(a){a=this.d(a);var b=new this.constructor,c=b.adj,d=this.adj;B(a,function(a){var b={};c[a]=b;G(d[a],function(d,n){if(n in c){var q=Ma(d);b[n]=q;c[n][a]=q}})});G(this.node,function(a,c){b.node[c]=a});b.graph=this.graph;return b};Z.prototype.subgraph=Z.prototype.s;function $(a,b){if(!(this instanceof $))return new $(a,b);Y.call(this,a,b)}na($,Y);var qc=$.prototype,rc=Z.prototype,sc;for(sc in rc)rc.hasOwnProperty(sc)&&"constructor"!==sc&&(qc[sc]=rc[sc]);v("jsnx.classes.MultiDiGraph",$);v("jsnx.MultiDiGraph",$);$.__name__="MultiDiGraph";
$.prototype.a=function(a,b,c,d){var e,f;c!=l&&(!u(c)&&!ga(c))&&(d=c,c=l);d=d||{};"object"!==r(d)&&h(new Q("The attr_dict argument must be an object."));a in this.succ||(this.succ[a]={},this.pred[a]={},this.node[a]={});b in this.succ||(this.succ[b]={},this.pred[b]={},this.node[b]={});if(b in this.succ[a]){f=this.adj[a][b];if(c==l)for(c=H(f);c in f;)c+=1;e=K(f,c.toString(),{});L(e,d);f[c]=e}else c!=l||(c=0),e={},L(e,d),f=Oa(c,e),this.succ[a][b]=f,this.pred[b][a]=f};$.prototype.add_edge=$.prototype.a;
$.prototype.r=function(a,b,c){(!(a in this.adj)||!(b in this.adj[a]))&&h(new Q("The edge "+a+"-"+b+" is not in the graph"));var d=this.adj[a][b];c!=l?(c in d||h(new Q("The edge "+a+"-"+b+" with key "+c+" is not in the graph")),J(d,c)):J(d,Ia(d));0===H(d)&&(J(this.succ[a],b),J(this.pred[b],a))};$.prototype.remove_edge=$.prototype.r;
$.prototype.k=function(a,b,c){fa(a)&&(fa(b)&&(c=b),b=a,a=l);var d,e;a=a!=l?S(this.d(a),function(a){return[a,this.adj[a]]},this):ob(this.adj);return b?U(a,function(a){d=a[0];return V(a[1])},function(a){e=a[0];return V(a[1])},function(a){return c?[d,e,a[0],a[1]]:[d,e,a[1]]}):U(a,function(a){d=a[0];return V(a[1])},function(a){e=a[0];return V(a[1])},function(a){return c?[d,e,a[0]]:[d,e]})};$.prototype.edges_iter=$.prototype.k;$.prototype.T=$.prototype.k;$.prototype.out_edges_iter=$.prototype.T;
$.prototype.Y=function(a,b,c){return F(this.T(a,b,c))};$.prototype.out_edges=$.prototype.Y;$.prototype.K=function(a,b,c){fa(a)&&(b=a,a=l);var d,e;a=a!=l?S(this.d(a),function(a){return[a,this.pred[a]]},this):ob(this.pred);return b?U(a,function(a){d=a[0];return V(a[1])},function(a){e=a[0];return V(a[1])},function(a){return c?[e,d,a[0],a[1]]:[e,d,a[1]]}):U(a,function(a){d=a[0];return V(a[1])},function(a){e=a[0];return V(a[1])},function(a){return c?[e,d,a[0]]:[e,d]})};$.prototype.in_edges_iter=$.prototype.K;
$.prototype.J=function(a,b,c){return F(this.K(a,b,c))};$.prototype.in_edges=$.prototype.J;
$.prototype.m=function(a,b){var c;c=a!=l?kb(C(this.d(a),function(a){return[a,this.succ[a]]},this),C(this.d(a),function(a){return[a,this.pred[a]]},this)):kb(V(this.succ),V(this.pred));return b!=l?S(c,function(a){var c=a[0][1],f=0;G(a[1][1],function(a){G(a,function(a){f+=+K(a,b,1)})});G(c,function(a){G(a,function(a){f+=+K(a,b,1)})});return[a[0][0],f]}):S(c,function(a){var b=0,c=0;G(a[1][1],function(a){b+=ib(a)});G(a[0][1],function(a){c+=ib(a)});return[a[0][0],b+c]})};$.prototype.degree_iter=$.prototype.m;
$.prototype.I=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.pred[a]]},this):V(this.pred);return b!=l?S(c,function(a){var c=0;G(a[1],function(a){G(a,function(a){c+=+K(a,b,1)})});return[a[0][0],c]}):S(c,function(a){var b=0;G(a[1],function(a){b+=H(a)});return[a[0],b]})};$.prototype.in_degree_iter=$.prototype.I;
$.prototype.N=function(a,b){var c;c=a!=l?S(this.d(a),function(a){return[a,this.succ[a]]},this):V(this.succ);return b!=l?S(c,function(a){var c=0;G(a[1],function(a){G(a,function(a){c+=+K(a,b,1)})});return[a[0][0],c]}):S(c,function(a){var b=0;G(a[1],function(a){b+=H(a)});return[a[0],b]})};$.prototype.out_degree_iter=$.prototype.N;$.prototype.i=ca(k);$.prototype.is_multigraph=$.prototype.i;$.prototype.c=ca(k);$.prototype.is_directed=$.prototype.c;$.prototype.v=function(){return pb(this)};
$.prototype.to_directed=$.prototype.v;$.prototype.H=function(a){var b=new Z;b.name(this.name());b.g(this);var c,d;a?b.b(U(this.p(),function(a){c=a[0];return V(a[1])},function(a){d=a[0];return V(a[1])},ma(function(a){if(this.S(d,c,a[0]))return[c,d,a[0],W(a[1])]},this))):b.b(U(this.p(),function(a){c=a[0];return V(a[1])},function(a){d=a[0];return V(a[1])},function(a){return[c,d,a[0],W(a[1])]}));b.graph=W(this.graph);b.node=W(this.node);return b};$.prototype.to_undirected=$.prototype.H;
$.prototype.s=function(a){a=this.d(a);var b=new this.constructor,c=b.succ,d=b.pred,e=this.succ;B(a,function(a){c[a]={};d[a]={}});P(c,function(a){var b=c[a];G(e[a],function(e,q){if(q in c){var D=Ma(e);b[q]=D;d[q][a]=D}})});P(b,function(a){b.node[a]=this.node[a]},this);b.graph=this.graph;return b};$.prototype.subgraph=$.prototype.s;
$.prototype.reverse=function(a){(a=!s(a)||a)?(a=new this.constructor(l,{name:"Reverse of ("+this.name()+")"}),a.g(this),a.b(C(this.k(l,k,k),function(a){return[a[1],a[0],a[2],W(a[3])]})),a.graph=W(this.graph),a.node=W(this.node)):(a=this.succ,this.succ=this.pred,this.pred=a,this.adj=this.succ,a=this);return a};$.prototype.reverse=$.prototype.reverse;v("jsnx.nodes",function(a){return a.nodes()});v("jsnx.nodes_iter",function(a){return a.z()});v("jsnx.edges",function(a,b){return a.q(b)});v("jsnx.edges_iter",function(a,b){return a.k(b)});v("jsnx.degree",function(a,b,c){return a.l(b,c)});v("jsnx.neighbors",function(a,b){return a.D(b)});v("jsnx.number_of_nodes",function(a){return a.G()});v("jsnx.number_of_edges",function(a){return a.F()});v("jsnx.density",function(a){var b=a.G(),c=a.F();return 0===c?0:a.c()?c/(b*(b-1)):2*c/(b*(b-1))});
v("jsnx.degree_histogram",function(a){a=Ja(a.l());var b=Math.max.apply(Math,a)+1,c=Ba(b);x(a,function(a){c[a]+=1});return c});v("jsnx.is_directed",function(a){return a.c()});v("jsnx.freeze",function(a){function b(){h(new Q("Frozen graph can't be modified"))}a.C=b;a.g=b;a.O=b;a.U=b;a.a=b;a.b=b;a.r=b;a.A=b;a.clear=b;a.ra=k;return a});v("jsnx.is_frozen",function(a){return!!a.ra});v("jsnx.subgraph",function(a,b){return a.s(b)});
v("jsnx.create_empty_copy",function(a,b){s(b)||(b=k);var c=new a.constructor;b&&c.g(a);return c});
v("jsnx.info",function(a,b){var c="";if(b!=l)a.n(b)||h(new Q("node "+b+" not in graph")),c=c+("Node "+b+" has the following properties:\n")+("Degree: "+a.l(b)+"\n"),c+="Neighbors: "+a.D(b).join(" ");else{var c=c+("Name: "+a.name()+"\n"),c=c+("Type: "+a.constructor.__name__+"\n"),c=c+("Number of nodes: "+a.G()+"\n"),c=c+("Number of edges: "+a.F()+"\n"),d=a.G();if(0<d)if(a.c())c+="Average in degree: "+(X.o.apply(l,Ja(a.ba()))/d).toFixed(4)+"\n",c+="Average out degree: "+(X.o.apply(l,Ja(a.ea()))/d).toFixed(4);
else var e=X.o.apply(l,Ja(a.l())),c=c+("Average degree: "+(e/d).toFixed(4))}return c});v("jsnx.set_node_attributes",function(a,b,c){G(c,function(c,e){a.node[e][b]=c})});v("jsnx.get_node_attributes",function(a,b){var c={};G(a.da,function(a,e){b in a&&(c[e]=a[b])});return c});v("jsnx.set_edge_attributes",function(a,b,c){G(c,function(b,c){c=c.split(",");a.f(c[0])[c[1]]=b})});v("jsnx.get_edge_attributes",function(a,b){var c={};G(a.q(l,k),function(a){b in a[2]&&(c[[a[0],a[1]]]=a[2][b])});return c});}));