Commit 33f7f0bb authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix doctests

This fixes the expected values for several doctests, after
random_graph() re-factoring.
parent 1f28345e
......@@ -105,23 +105,23 @@ def pagerank(g, damping=0.8, prop=None, epslon=1e-6, max_iter=None,
>>> g = gt.random_graph(100, lambda: (poisson(3), poisson(3)))
>>> pr = gt.pagerank(g)
>>> print pr.a
[ 0.89482844 1.37847566 0.24 1.30716676 0.2 0.70397009
0.40205781 0.74783725 1.37167015 0.66836587 0.5868133 0.47968714
1.52225854 1.07388611 0.76316432 0.39214247 0.9302883 0.86455762
0.77546264 1.87740317 0.25482139 0.29902553 0.2 0.24756383
0.97205301 0.29727392 1.34742309 0.30905457 0.55032542 0.56654712
0.40895463 0.77928729 0.73227413 0.59911926 1.39946277 0.72793699
2.27008393 0.88929335 0.48636962 0.73070609 0.2 0.232
0.96857512 2.97683022 0.58581032 0.80217847 0.37896569 0.93866821
0.27337672 0.98201842 0.48551839 1.22651796 0.73263045 0.43013228
1.00971133 0.72075953 0.66715456 0.58705749 0.74286661 0.37785867
1.8475279 0.26432925 0.33994628 0.97319326 0.78104447 0.2
0.33333761 0.51756267 0.47811583 0.85905246 1.46428623 0.2
1.70687671 1.0107342 0.94504737 1.29858046 2.19707395 0.55931282
0.85129509 1.09493368 1.22168331 0.64108136 0.70690188 0.2
0.31736266 0.42372513 0.79429328 1.44749664 1.20741669 0.65763236
0.40895463 0.62628812 0.32671006 0.85626447 0.59925496 0.3399879
0.81215046 0.71506902 2.25678844 1.04882679]
[ 0.63876901 1.13528868 0.31465963 0.55855277 0.2 0.75605741
0.42628689 0.53066254 0.55004112 0.91717076 0.71164749 0.32015438
0.67275227 1.08207389 1.14412231 0.9049167 1.32002 1.4692142
0.76549771 0.71510277 0.23732927 0.40844911 0.2 0.27912876
0.71309781 0.32015438 1.3376236 0.31352887 0.59346569 0.33381039
0.67300081 0.73318264 0.65812653 0.73409673 0.93051993 0.83241145
1.59816568 0.43979363 0.2512247 1.15663357 0.2 0.35977148
0.72182022 1.01267711 0.76304859 0.49247376 0.49384283 1.8436647
0.64312224 1.00778243 0.62287633 1.15215387 0.56176895 0.7166227
0.56506109 0.67104337 0.95570565 0.27996953 0.79975983 0.33631497
1.09471419 0.33631497 0.2512247 2.09126732 0.68157485 0.2
0.37140185 0.65619459 1.27370737 0.48383225 1.36125161 0.2
0.78300573 1.03427279 0.56904755 1.66077917 1.73302035 0.28749261
0.83143045 1.04969728 0.70090048 0.55991433 0.68440994 0.2
0.34018009 0.45485484 0.28 1.2015438 2.11850885 1.24990775
0.59914308 0.59989185 0.73535564 0.78168417 0.55390281 0.38627667
1.42274704 0.51105348 0.92550979 1.27968065]
References
----------
......@@ -202,23 +202,23 @@ def betweenness(g, vprop=None, eprop=None, weight=None, norm=True):
>>> g = gt.random_graph(100, lambda: (poisson(3), poisson(3)))
>>> vb, eb = gt.betweenness(g)
>>> print vb.a
[ 0.03047981 0.07396685 0.00270882 0.044637 0. 0.03259048
0.0243547 0.04265909 0.06274696 0.01778475 0.03502657 0.02692273
0.05170277 0.05522454 0.02303023 0.0038858 0. 0.04852871
0.02398655 0.00232365 0. 0.01064643 0. 0.01105872
0.03564021 0.0222059 0.05170383 0.00140447 0.03935299 0.02644813
0.01831885 0. 0.0453981 0.04552396 0.1242787 0.04983878
0.07248363 0.04676976 0.03481327 0.04473583 0. 0.0027417
0.01061048 0.0470108 0.01059109 0.05290495 0. 0.02541583
0. 0.04012033 0.02616307 0.09056515 0.01640322 0.01599007
0.02784563 0.05008998 0.03788222 0.03028745 0.01097982 0.00178571
0.05804645 0.01015181 0.0061582 0.0255485 0.05504439 0.
0.00179516 0.03367643 0.00304982 0.02333254 0.00843039 0.
0.05947385 0.01936996 0.0521946 0.04928937 0.03955121 0.01360865
0.02942447 0. 0.05149102 0.01054765 0. 0.
0.00537915 0.01251828 0.01097982 0.06667564 0.04090169 0.02161779
0.02941671 0.01793679 0.02360528 0.02638257 0.0062989 0.00946123
0. 0.02255701 0.05081734 0.04846652]
[ 0.03395047 0.07911989 0.00702948 0.02337119 0. 0.02930099
0.01684377 0.02558675 0.03440095 0.02886187 0.03124262 0.00975953
0.01307953 0.03938858 0.07266505 0.01313647 0. 0.06450598
0.0575418 0.00525468 0.00466089 0.01803829 0. 0.00050161
0.0085034 0.02362432 0.05620574 0.00097157 0.04006816 0.01301474
0.02154916 0. 0.06009194 0.02780363 0.08963522 0.04049657
0.06993559 0.02082698 0.00288318 0.03264322 0. 0.03641759
0.01083859 0.03750864 0.04079359 0.02092599 0. 0.02153655
0. 0.05674631 0.03861911 0.05473282 0.00904367 0.03249097
0.00894043 0.0192741 0.03379204 0.02125998 0.0018321 0.0013495
0.0336502 0.0210088 0.00125318 0.0489189 0.05254974 0.
0.00432189 0.04866168 0.06444727 0.02508525 0.02533085 0.
0.05308703 0.02539854 0.02270809 0.044889 0.04766016 0.0086368
0.01501699 0. 0.03107868 0.0054221 0. 0.
0.00596081 0.01183977 0.00159761 0.11435876 0.03988501 0.05128991
0.04558135 0.02303469 0.05092032 0.04700221 0.00927644 0.00841903
0. 0.03243633 0.04514374 0.05170213]
References
----------
......@@ -283,7 +283,7 @@ def central_point_dominance(g, betweenness):
>>> g = gt.random_graph(100, lambda: (poisson(3), poisson(3)))
>>> vb, eb = gt.betweenness(g)
>>> print gt.central_point_dominance(g, vb)
0.0980212339559
0.0884414811909
References
----------
......@@ -359,31 +359,31 @@ def eigentrust(g, trust_map, vprop=None, norm=False, epslon=1e-6, max_iter=0,
>>> trust.get_array()[:] = random(g.num_edges())*42
>>> t = gt.eigentrust(g, trust, norm=True)
>>> print t.get_array()
[ 1.04935746e-02 2.82745068e-02 0.00000000e+00 1.81121002e-02
0.00000000e+00 3.70898521e-03 1.00108703e-03 1.29620638e-02
1.71874047e-02 7.07523828e-03 8.29873222e-03 1.79259666e-03
4.08925756e-02 1.55855653e-02 2.92256968e-03 1.71520782e-03
5.04335865e-03 1.25678184e-02 1.92903241e-02 2.46642649e-02
1.76431290e-04 1.85066489e-04 0.00000000e+00 4.52686439e-04
7.13943855e-03 2.36002975e-03 1.44366165e-02 4.39632543e-04
7.50316671e-03 8.13521884e-03 3.98083843e-03 1.04883920e-02
7.42099689e-03 2.46651355e-03 2.08148781e-02 8.02104873e-03
2.59366573e-02 2.11125347e-02 7.45781416e-03 6.62338254e-03
0.00000000e+00 0.00000000e+00 1.72521147e-02 4.74346499e-02
8.10593668e-03 2.27229702e-02 2.21525586e-03 6.24223052e-03
2.59753300e-03 9.15181124e-03 3.67310718e-03 1.18998211e-02
1.66177496e-02 6.44748287e-03 8.01978992e-03 1.48621102e-02
6.65606246e-03 3.39887550e-03 1.20188240e-02 3.51012614e-03
2.79661104e-02 7.90103914e-05 1.18015521e-03 8.17179744e-03
1.05694658e-02 0.00000000e+00 4.49123443e-04 9.80728243e-04
2.70933271e-03 1.61865322e-02 2.13504124e-02 0.00000000e+00
1.17773123e-02 4.63490203e-03 1.79331966e-02 1.46366115e-02
3.26856602e-02 4.31126006e-03 1.68787878e-02 2.02752156e-02
1.48203062e-02 1.17346898e-03 7.87933309e-03 0.00000000e+00
1.13274458e-03 2.25418313e-03 1.27966643e-02 2.46154526e-02
7.15248968e-03 8.35660945e-03 3.88259360e-03 5.95428313e-03
1.16751480e-04 5.78637193e-03 6.50575506e-03 1.47111816e-03
1.22855215e-02 1.34294277e-02 4.03141738e-02 2.77313687e-02]
[ 5.51422638e-03 1.12397965e-02 2.34959294e-04 6.32738574e-03
0.00000000e+00 6.34804836e-03 2.67885424e-03 4.02497751e-03
1.67943467e-02 6.46196106e-03 1.92402451e-02 9.04032352e-04
9.70843104e-03 1.40319816e-02 1.04995777e-02 2.86712231e-02
2.47285894e-02 2.38394469e-02 7.06936059e-03 9.45794717e-03
2.09970054e-05 1.64768298e-03 0.00000000e+00 1.19346706e-03
6.88434371e-03 5.36337333e-03 2.08428677e-02 2.85813783e-03
1.10564670e-02 3.16345060e-04 5.25737238e-03 5.43761445e-03
7.98048389e-03 7.95939648e-03 2.23891858e-02 5.68630666e-03
2.09300588e-02 4.28902068e-03 1.70833078e-03 2.37814042e-02
0.00000000e+00 1.20805010e-03 1.29713483e-02 5.73021992e-03
8.71093674e-03 7.77661067e-03 8.76489806e-04 2.38519385e-02
3.53225723e-03 8.46948906e-03 5.09874234e-03 2.44547150e-02
1.32342629e-02 1.80085559e-03 4.37189381e-03 1.18195253e-02
1.62748861e-02 1.83200678e-04 1.09745025e-02 1.47544090e-03
3.34512926e-02 1.58885132e-03 1.13128910e-03 3.04944830e-02
4.22684975e-03 0.00000000e+00 9.89654274e-04 4.25927156e-03
2.34516214e-02 4.91370905e-03 2.29366664e-02 0.00000000e+00
6.83407601e-03 1.60508753e-02 1.62762068e-03 3.94324856e-02
2.84109571e-02 8.81167727e-04 2.16999908e-02 1.28688125e-02
1.10825963e-02 2.64915564e-03 2.88711928e-03 0.00000000e+00
4.24392252e-03 9.38398819e-03 0.00000000e+00 1.74508371e-02
3.26594153e-02 4.07188867e-02 3.20678152e-03 6.35046287e-03
8.07061556e-03 5.08505374e-03 3.27300367e-03 3.30989070e-03
2.30651195e-02 4.20338525e-03 5.04332662e-03 3.58731532e-02]
References
----------
......@@ -477,23 +477,23 @@ def absolute_trust(g, trust_map, source, target = None, vprop=None):
>>> trust.a = random(g.num_edges())
>>> t = gt.absolute_trust(g, trust, source=g.vertex(0))
>>> print t.a
[ 0.05927703 0.06133836 0. 0.05630559 0. 0.03317174
0.03488483 0.15920558 0.16940159 0.09716039 0.1485169 0.0120287
0.03787312 0.37284274 0.00646336 0.0084941 0.0379645 0.07997339
0.10733769 0.10053845 0.00283938 0.05224064 0. 0.16523684
0.0393326 0.25853808 0.14682555 0.03254906 0.12124144 0.0118341
0.18110839 0.18513216 0.05031324 0.04484457 0.17197674 0.08569659
0.17523371 0.22435776 0.33916191 0.07980329 0. 0.
0.09750183 0.09811054 0.14574289 0.0085499 0.34593499 0.03151408
0.083739 0.05409947 0.09161205 0.19921201 0.10647812 0.21597253
0.06266044 0.8738786 0.11239455 0.09493216 0.19073287 0.11968616
0.13409125 0.00626821 0.05857625 0.05917779 0.05673643 0.
0.02682173 0.00355514 0.17475858 0.15113517 0.13247358 0.
0.04003866 0.00997401 0.11126411 0.07400706 0.11247583 0.10125886
0.16028191 0.04300862 0.03259707 0.0225482 0.05538721 0.
0.06715919 0.0701153 0.02999368 0.04675702 0.06310919 0.01722603
0.18455906 0.08034113 0.00376382 0.10041304 0.3437539 0.10530238
0.11654855 0.09495419 0.05317485 0.10727767]
[ 0.16260667 0.04129912 0.13735376 0.19146125 0. 0.09147461
0.10371912 0.12465511 0.24631221 0.0603916 0.2375385 0.06637879
0.08897662 0.0800988 0.05250601 0.66759022 0.09368793 0.08275437
0.13674709 0.15553915 0.01376162 0.417068 0. 0.06096886
0.08746817 0.39380693 0.09215297 0.09575144 0.15594162 0.04008874
0.05483972 0.05691086 0.13571077 0.32376012 0.22477937 0.06347962
0.10445085 0.19447845 0.38007043 0.13810585 0. 0.08451096
0.06648153 0.18479174 0.13003649 0.14850631 0.00320603 0.1074644
0.12088162 0.06792678 0.08472666 0.2002143 0.25963204 0.37838425
0.03089371 0.18389694 0.39420339 0.03348093 0.11483196 0.0656204
0.14206403 0.07066434 0.25168986 0.07040126 0.04870569 0.
0.09861349 0.03882069 0.1105267 0.07951823 0.08748441 0.
0.08393443 0.11121719 0.21903223 0.25529628 0.0414386 0.03695558
0.17664854 0.05143033 0.11735779 0.06525968 0.19600919 0. 0.1220922
0.33330041 0. 0.28595961 0.14526678 0.12514885 0.089524
0.40738962 0.03719195 0.54409979 0.06247424 0.10660136 0.11674385
0.13218144 0.02214988 0.23215937]
"""
if vprop == None:
......
......@@ -112,7 +112,7 @@ def local_clustering(g, prop=None, undirected=False):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> clust = gt.local_clustering(g)
>>> print gt.vertex_average(g, clust)
(0.0054000000000000003, 0.00046091213913282869)
(0.0052816666666666671, 0.00046415526317530143)
References
----------
......@@ -174,7 +174,7 @@ def global_clustering(g):
>>> seed(42)
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> print gt.global_clustering(g)
(0.0091250670960815895, 0.00044046497971164271)
(0.0075696677384780283, 0.00039465997422993533)
References
----------
......@@ -247,11 +247,11 @@ def extended_clustering(g, props=None, max_depth=3, undirected=False):
>>> for i in xrange(0, 5):
... print gt.vertex_average(g, clusts[i])
...
(0.0054000000000000003, 0.00046091213913282869)
(0.027353333333333334, 0.0010353156469835125)
(0.11857833333333334, 0.002002602051082541)
(0.40064, 0.0030508380196631575)
(0.42819166666666664, 0.0030905005774865082)
(0.0052816666666666671, 0.00046415526317530143)
(0.026543333333333332, 0.0010405374199048405)
(0.11648, 0.0019761350156302583)
(0.40672499999999995, 0.0031128844140121867)
(0.42646999999999996, 0.0030644539462829075)
References
----------
......@@ -330,9 +330,10 @@ def motifs(g, k, p=1.0, motif_list=None, undirected=None):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> motifs, counts = gt.motifs(g, 4, undirected=True)
>>> print len(motifs)
13
11
>>> print counts
[114750, 387884, 875, 1004, 2254, 3162, 770, 14, 8, 7, 16, 2, 5]
[115780, 390603, 667, 764, 2666, 1694, 821, 5, 9, 4, 4]
References
----------
......@@ -499,7 +500,7 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
>>> print len(motifs)
12
>>> print zscores
[-0.16076033462706543, -0.16176522339544466, 0.010436730454036206, 0.0944284162896325, 0.20360864249886917, 0.20675511240829708, -0.42478047102781324, -0.10000000000000001, -0.10000000000000001, -0.28000000000000003, -0.14000000000000001, -0.01]
[0.84493166311546375, 0.83875258032645894, 1.2117425659306142, -0.20405718722884647, -0.69886762637118316, -0.68343227667794837, -0.92481997609648403, -0.11, -0.14999999999999999, -0.26000000000000001, -0.14000000000000001, -0.01]
"""
s_ms, counts = motifs(g, k, p, motif_list, undirected)
......
......@@ -105,7 +105,7 @@ def assortativity(g, deg):
>>> g = gt.random_graph(1000, lambda: sample_k(40),
... lambda i,k: 1.0/(1+abs(i-k)), directed=False)
>>> gt.assortativity(g, "out")
(0.14264767490573943, 0.0050939131827104651)
(0.15379786566227244, 0.0052484342042414195)
References
----------
......@@ -174,12 +174,12 @@ def scalar_assortativity(g, deg):
>>> g = gt.random_graph(1000, lambda: sample_k(40), lambda i,k: abs(i-k),
... directed=False)
>>> gt.scalar_assortativity(g, "out")
(-0.47490876200787641, 0.010404791498106225)
(-0.46612545377150078, 0.010365307846181516)
>>> g = gt.random_graph(1000, lambda: sample_k(40),
... lambda i,k: 1.0/(1+abs(i-k)),
... directed=False)
>>> gt.scalar_assortativity(g, "out")
(0.62401111084836425, 0.011049051007488318)
(0.63254355342678503, 0.011015440807502176)
References
----------
......
......@@ -85,44 +85,44 @@ def edmonds_karp_max_flow(g, source, target, capacity, residual=None):
Examples
--------
>>> from numpy.random import seed, random
>>> seed(42)
>>> seed(43)
>>> g = gt.random_graph(100, lambda: (2,2))
>>> c = g.new_edge_property("double")
>>> c.a = random(len(c.a))
>>> res = gt.edmonds_karp_max_flow(g, g.vertex(0), g.vertex(1), c)
>>> res.a = c.a - res.a # the actual flow
>>> print res.a[0:g.num_edges()]
[ 0.39416408 0.72865707 0. 0. 0.02419415 0.05808361
0. 0. 0.70807258 0.02058449 0.02058449 0.
0.21233911 0.18182497 0.01658783 0. 0. 0. 0.
0. 0. 0.11572935 0. 0.1483536 0.5083988
0.19967378 0.02058449 0. 0. 0. 0.11572935
0. 0. 0.47060682 0. 0. 0. 0.
[ 0. 0.24058962 0. 0. 0. 0. 0.
0.05688494 0.39495002 0.03148888 0. 0.05688494 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.03148888
0. 0. 0. 0. 0.52856316 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.3571333 0. 0.
0. 0. 0.11118128 0.0884925 0. 0. 0.
0. 0. 0. 0. 0.14837338 0. 0.
0.0884925 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.
0.20875992 0.46564427 0. 0.02058449 0. 0. 0.
0.23696565 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.13361314 0.
0.03148888 0. 0.13361314 0. 0. 0.
0.10335251 0. 0. 0. 0. 0.
0.03148888 0. 0. 0. 0. 0. 0.
0. 0.80064166 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0.61693698 0.10335251
0.13723711 0. 0. 0.05688494 0. 0. 0.
0. 0. 0. 0. 0.08837382 0. 0.
0. 0. 0. 0. 0.03148888 0. 0.
0. 0. 0. 0. 0. 0. 0.
0.01658783 0. 0. 0. 0. 0. 0.
0. 0.20875992 0. 0.09303057 0. 0.
0.09303057 0.22879817 0. 0. 0. 0. 0.
0. 0.05808361 0. 0.18657006 0. 0.11118128
0. 0. 0. 0. 0. 0.13361314
0. 0.23696565 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0.11572935 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0.12776911 0. 0. 0. 0. 0. 0.
0. 0.02058449 0. 0.11572935 0. 0.32182874
0.18657006 0. 0. 0. 0. 0.31729067
0. 0.14837338 0. 0.11572935 0.09028977 0. 0.
0. 0. 0. 0. 0.01658783 0.08227776
0. 0. 0. 0. 0. 0.14837338
0. 0.20875992 0.11347352 0.09886559 0.65221433 0. 0.
0. 0. 0. 0. 0. 0. 0.
0.05808361 0. 0. 0. 0. 0. 0.
0. ]
0.13361314 0. 0.16872599 0. 0. 0.
0.13361314 0.13723711 0. 0. 0. 0. 0.
0.13723711 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.13361314
0. 0.40569164 0. 0. 0. 0. 0.
0. 0. 0.08837382 0. 0. 0. ]
References
----------
......@@ -177,46 +177,46 @@ def push_relabel_max_flow(g, source, target, capacity, residual=None):
Examples
--------
>>> from numpy.random import seed, random
>>> seed(42)
>>> seed(43)
>>> g = gt.random_graph(100, lambda: (2,2))
>>> c = g.new_edge_property("double")
>>> c.a = random(len(c.a))
>>> res = gt.push_relabel_max_flow(g, g.vertex(0), g.vertex(1), c)
>>> res.a = c.a - res.a # the actual flow
>>> print res.a[0:g.num_edges()]
[ 0.39416408 0.72865707 0. 0. 0.10582673 0. 0.
0. 0.70807258 0.02058449 0.02058449 0. 0.21233911
0.18182497 0.04005893 0. 0. 0.02354897 0.03688695
0. 0.04645041 0.01722617 0.08333736 0.02058449 0.64459363
0.06347894 0.05747144 0. 0.04645041 0. 0.01722617
0.06505159 0. 0.56093603 0. 0.06245346 0.04645041
0. 0. 0.07377389 0.06505159 0. 0.03142919
0. 0.06505159 0.0234711 0.07377389 0. 0.04645041
0.44746251 0.02816465 0.03688695 0.03688695 0. 0.
0.06347894 0.04645041 0.04522729 0. 0.04005893 0. 0.0234711
0. 0.1561659 0.03688695 0.03688695 0.1259324 0.
0.03688695 0. 0.04645041 0. 0.04645041 0. 0.
0. 0.06505159 0. 0. 0.29129661 0.37531506
0. 0.05747144 0.03688695 0.01722617 0. 0.03142919
0.00862975 0.04645041 0. 0.00862975 0.01722617 0.04005893
0. 0. 0.02816465 0. 0. 0.
0.03142919 0.03688695 0.25440966 0.0885227 0.23718349 0. 0.
0.26065459 0.22879817 0. 0. 0. 0.
0.04645041 0. 0.05508016 0. 0.18657006 0.
0.04645041 0. 0.13245284 0. 0.0234711 0.
0.03142919 0. 0. 0. 0.13245284 0.08227776
0.02585591 0.0234711 0. 0. 0. 0.
0.06245346 0. 0. 0.06245346 0.04645041 0. 0.
0.04069727 0.03688695 0.06505159 0.03142919 0. 0.02058449
0.03688695 0.08227776 0. 0.48945276 0.18657006 0.06505159
0. 0. 0.01722617 0.35473057 0. 0.20261631
0. 0.2147306 0.0729211 0.04069727 0.02354897 0.0916777
0.04077514 0.04077514 0. 0.01658783 0.08227776 0. 0.
0. 0. 0. 0.12800126 0. 0.25440966
0.11347352 0.09886559 0.56188512 0. 0.0234711 0.
0.03688695 0. 0.06505159 0. 0. 0.03688695
0.04645041 0. 0. 0.03688695 0. 0.03688695
0.04645041 0.03688695]
[ 0.00508328 0.24058962 0. 0. 0.07640118 0. 0.0149749
0.00476207 0.39495002 0.06036354 0.07755781 0.05688494 0.00984535
0.0149749 0.00984535 0.06594114 0. 0.0149749 0. 0.
0.1383694 0.00984535 0.07755781 0. 0. 0.0149749
0.06036354 0. 0.00512955 0.0702089 0. 0.63637368
0.13988182 0.12852405 0.00476207 0. 0. 0.00512955
0.05247866 0. 0. 0.01940656 0. 0.05159229
0.00984535 0. 0.07755781 0.19097437 0. 0.
0.05159229 0.00984535 0. 0.0227834 0.05247866 0. 0.
0. 0.20608185 0. 0.10979179 0.01073172 0.07755781
0.2159272 0.13988182 0. 0.14805691 0. 0.0227834 0.
0. 0. 0. 0. 0.00984535 0.04127632
0.02525962 0. 0.00984535 0. 0.80064166 0.02416862
0.06440315 0.00508328 0.06372057 0.00512955 0.00508328 0.
0.07755781 0. 0.00984535 0.0149749 0.06232401 0.07755781
0.02525962 0. 0. 0.61693698 0.10335251 0.13723711
0.0447044 0.00508328 0.00476207 0.12852405 0.07755781 0.06277679
0.06232401 0. 0.00476207 0.04093717 0.02183962 0.02057707
0.00476207 0.01802133 0. 0. 0.00730949 0.
0.00476207 0. 0.1383694 0.00476207 0.00730949 0.04851461
0.00476207 0. 0.0149749 0.00984535 0.06036354 0.
0.00476207 0. 0.00984535 0. 0.15790227 0.
0.05582411 0.0149749 0.04023452 0.07755781 0.1383694 0.10352007
0. 0. 0.07755781 0. 0. 0.
0.04127632 0. 0.05247866 0.02596227 0. 0.12408411
0.00512955 0. 0. 0. 0.05247866 0.
0.07755781 0.30420045 0.05247866 0.21471727 0. 0. 0.1139163
0.33016596 0.1445466 0. 0.01802133 0. 0.01715485
0.02416862 0.14962989 0. 0.00508328 0. 0. 0.
0.00730949 0. 0.0227834 0. 0. 0.00476207
0.07755781 0. 0.40569164 0. 0. 0.00476207
0.04874567 0.00512955 0. 0.0227834 0. 0.00730949
0. 0.00730949]
References
----------
......@@ -271,46 +271,46 @@ def kolmogorov_max_flow(g, source, target, capacity, residual=None):
Examples
--------
>>> from numpy.random import seed, random
>>> seed(42)
>>> seed(43)
>>> g = gt.random_graph(100, lambda: (2,2))
>>> c = g.new_edge_property("double")
>>> c.a = random(len(c.a))
>>> res = gt.push_relabel_max_flow(g, g.vertex(0), g.vertex(1), c)
>>> res.a = c.a - res.a # the actual flow
>>> print res.a[0:g.num_edges()]
[ 0.39416408 0.72865707 0. 0. 0.10582673 0. 0.
0. 0.70807258 0.02058449 0.02058449 0. 0.21233911
0.18182497 0.04005893 0. 0. 0.02354897 0.03688695
0. 0.04645041 0.01722617 0.08333736 0.02058449 0.64459363
0.06347894 0.05747144 0. 0.04645041 0. 0.01722617
0.06505159 0. 0.56093603 0. 0.06245346 0.04645041
0. 0. 0.07377389 0.06505159 0. 0.03142919
0. 0.06505159 0.0234711 0.07377389 0. 0.04645041
0.44746251 0.02816465 0.03688695 0.03688695 0. 0.
0.06347894 0.04645041 0.04522729 0. 0.04005893 0. 0.0234711
0. 0.1561659 0.03688695 0.03688695 0.1259324 0.
0.03688695 0. 0.04645041 0. 0.04645041 0. 0.
0. 0.06505159 0. 0. 0.29129661 0.37531506
0. 0.05747144 0.03688695 0.01722617 0. 0.03142919
0.00862975 0.04645041 0. 0.00862975 0.01722617 0.04005893
0. 0. 0.02816465 0. 0. 0.
0.03142919 0.03688695 0.25440966 0.0885227 0.23718349 0. 0.
0.26065459 0.22879817 0. 0. 0. 0.
0.04645041 0. 0.05508016 0. 0.18657006 0.
0.04645041 0. 0.13245284 0. 0.0234711 0.
0.03142919 0. 0. 0. 0.13245284 0.08227776
0.02585591 0.0234711 0. 0. 0. 0.
0.06245346 0. 0. 0.06245346 0.04645041 0. 0.
0.04069727 0.03688695 0.06505159 0.03142919 0. 0.02058449
0.03688695 0.08227776 0. 0.48945276 0.18657006 0.06505159
0. 0. 0.01722617 0.35473057 0. 0.20261631
0. 0.2147306 0.0729211 0.04069727 0.02354897 0.0916777
0.04077514 0.04077514 0. 0.01658783 0.08227776 0. 0.
0. 0. 0. 0.12800126 0. 0.25440966
0.11347352 0.09886559 0.56188512 0. 0.0234711 0.
0.03688695 0. 0.06505159 0. 0. 0.03688695
0.04645041 0. 0. 0.03688695 0. 0.03688695
0.04645041 0.03688695]
[ 0.00508328 0.24058962 0. 0. 0.07640118 0. 0.0149749
0.00476207 0.39495002 0.06036354 0.07755781 0.05688494 0.00984535
0.0149749 0.00984535 0.06594114 0. 0.0149749 0. 0.
0.1383694 0.00984535 0.07755781 0. 0. 0.0149749
0.06036354 0. 0.00512955 0.0702089 0. 0.63637368
0.13988182 0.12852405 0.00476207 0. 0. 0.00512955
0.05247866 0. 0. 0.01940656 0. 0.05159229
0.00984535 0. 0.07755781 0.19097437 0. 0.
0.05159229 0.00984535 0. 0.0227834 0.05247866 0. 0.
0. 0.20608185 0. 0.10979179 0.01073172 0.07755781
0.2159272 0.13988182 0. 0.14805691 0. 0.0227834 0.
0. 0. 0. 0. 0.00984535 0.04127632
0.02525962 0. 0.00984535 0. 0.80064166 0.02416862
0.06440315 0.00508328 0.06372057 0.00512955 0.00508328 0.
0.07755781 0. 0.00984535 0.0149749 0.06232401 0.07755781
0.02525962 0. 0. 0.61693698 0.10335251 0.13723711
0.0447044 0.00508328 0.00476207 0.12852405 0.07755781 0.06277679
0.06232401 0. 0.00476207 0.04093717 0.02183962 0.02057707
0.00476207 0.01802133 0. 0. 0.00730949 0.
0.00476207 0. 0.1383694 0.00476207 0.00730949 0.04851461
0.00476207 0. 0.0149749 0.00984535 0.06036354 0.
0.00476207 0. 0.00984535 0. 0.15790227 0.
0.05582411 0.0149749 0.04023452 0.07755781 0.1383694 0.10352007
0. 0. 0.07755781 0. 0. 0.
0.04127632 0. 0.05247866 0.02596227 0. 0.12408411
0.00512955 0. 0. 0. 0.05247866 0.
0.07755781 0.30420045 0.05247866 0.21471727 0. 0. 0.1139163
0.33016596 0.1445466 0. 0.01802133 0. 0.01715485
0.02416862 0.14962989 0. 0.00508328 0. 0. 0.
0.00730949 0. 0.0227834 0. 0. 0.00476207
0.07755781 0. 0.40569164 0. 0. 0.00476207
0.04874567 0.00512955 0. 0.0227834 0. 0.00730949
0. 0.00730949]
References
----------
......@@ -363,7 +363,7 @@ def max_cardinality_matching(g, match=None):
Examples
--------
>>> from numpy.random import seed, random
>>> seed(42)
>>> seed(43)
>>> g = gt.random_graph(100, lambda: (2,2))
>>> res = gt.max_cardinality_matching(g)
>>> print res[1]
......
......@@ -135,7 +135,7 @@ def random_graph(N, deg_sampler, deg_corr=None, directed=True,
>>> g = gt.random_graph(1000, lambda: sample_k(40),
... lambda i,k: 1.0/(1+abs(i-k)), directed=False)
>>> gt.scalar_assortativity(g, "out")
(0.63243885897121965, 0.011153551018567562)
(0.62318897995178757, 0.011431222500824638)
The following samples an in,out-degree pair from the joint distribution:
......
......@@ -80,11 +80,11 @@ def adjacency(g, sparse=True, weight=None):
>>> g = gt.random_graph(100, lambda: (10,10))
>>> m = gt.adjacency(g)
>>> print m.todense()
[[ 0. 0. 0. ..., 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.]
...,
[ 0. 0. 0. ..., 0. 1. 0.]
[ 0. 0. 0. ..., 0. 1. 1.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]]
......@@ -186,11 +186,11 @@ def laplacian(g, deg="total", normalized=True, sparse=True, weight=None):
>>> g = gt.random_graph(100, lambda: (10,10))
>>> m = gt.laplacian(g)
>>> print m.todense()
[[ 1. 0. 0. ..., 0.05 0. 0. ]
[[ 1. 0. 0. ..., 0. 0. 0. ]
[ 0. 1. 0. ..., 0. 0. 0. ]
[ 0.05 0. 1. ..., 0. 0. 0. ]
[ 0. 0. 1. ..., 0. 0. 0. ]
...,
[ 0. 0. 0. ..., 1. 0.05 0. ]
[ 0. 0. 0. ..., 1. 0.05 0.05]
[ 0. 0. 0. ..., 0. 1. 0. ]
[ 0. 0. 0. ..., 0. 0. 1. ]]
......@@ -274,7 +274,7 @@ def incidence(g, sparse=True):
>>> print m.todense()
[[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 1. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 1.]
...,
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
......
......@@ -158,7 +158,7 @@ def edge_hist(g, eprop, bins=[1], float_count=True):
>>> eprop = g.new_edge_property("double")
>>> eprop.get_array()[:] = random(g.num_edges())
>>> print gt.edge_hist(g, eprop, arange(0, 1, 0.1))
[array([ 525., 504., 502., 502., 467., 499., 531., 471., 520., 479.]), array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])]
[array([ 525., 504., 502., 502., 468., 499., 531., 471., 520., 478.]), array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9])]
"""
......@@ -252,7 +252,7 @@ def edge_average(g, eprop):
>>> eprop = g.new_edge_property("double")
>>> eprop.get_array()[:] = random(g.num_edges())
>>> print gt.edge_average(g, eprop)
(0.49683581007070887, 0.0040956077241228531)
(0.49674035434130187, 0.0040946040690938677)
"""
ret = libgraph_tool_stats.\
......@@ -354,10 +354,10 @@ def distance_histogram(g, weight=None, bins=[1], samples=None,
>>> g = gt.random_graph(100, lambda: (3, 3))
>>> hist = gt.distance_histogram(g)
>>> print hist
[array([ 0., 300., 862., 2147., 3766., 2588., 237.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
[array([ 0., 300., 857., 2186., 3894., 2511., 152.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
>>> hist = gt.distance_histogram(g, samples=10)
>>> print hist
[array([ 0., 30., 84., 210., 375., 264., 27.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
[array([ 0., 30., 88., 222., 384., 251., 15.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
"""
if samples != None:
seed = numpy.random.randint(0, sys.maxint)
......
......@@ -99,7 +99,7 @@ def subgraph_isomorphism(sub, g):
>>> sub = gt.random_graph(10, lambda: (poisson(1.8), poisson(1.9)))
>>> vm, em = gt.subgraph_isomorphism(sub, g)
>>> print len(vm)
46
175
>>> for i in xrange(len(vm)):
... g.set_vertex_filter(None)
... g.set_edge_filter(None)
......@@ -221,20 +221,20 @@ def min_spanning_tree(g, weights=None, root=None, tree_map=None):
>>> g = gt.random_graph(100, lambda: (5, 5))
>>> tree = gt.min_spanning_tree(g)
>>> print tree.a
[0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 0
0 1 1 0 0 0 1 1 0 0 0 0 1 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 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0 0
0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
0 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 1 0 0