Commit c36685bf authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Small documentation changes

parent 63c2cae1
......@@ -154,7 +154,7 @@ In order to iterate through the vertices or edges of the graph, the
for v in g.vertices():
print v
for e in e.vertices():
for e in e.edges():
print e
The code above will print the vertices and edges of the graph in the order they
......@@ -357,13 +357,12 @@ use the :func:`~graph_tool.draw.graph_draw` function.
.. testcode::
g = load_graph("price.xml.gz")
g.remove_vertex_if(lambda v: g.vertex_index[v] >= 1000)
graph_draw(g, size=(10,10), layout="arf", output="price.png")
graph_draw(g, size=(15,15), layout="sfdp", output="price.png")
.. figure:: price.png
:align: center
First 1000 nodes of a price network.
A Price network with :math:`10^5` nodes.
Graph filtering
---------------
......
......@@ -109,23 +109,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.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]
[ 0.87011681 1.73449398 0.47587866 0.4534494 0.2 1.26596887
0.60964865 0.68064477 0.8137542 0.86269096 0.51833002 0.49194604
0.74875795 0.52831993 0.601438 0.63921165 1.32489495 0.68360746
1.02608206 0.90903761 1.1026286 0.56290713 0.2 0.30840086
0.90726785 0.35583967 0.95582862 0.232 0.41090313 0.88734742
0.47424296 0.66138242 1.26313184 0.7459428 0.84110051 0.9497316
1.0589998 0.94412292 0.26433617 0.86197354 0.2 0.25333333
0.65974242 0.69889305 1.02798531 0.77618244 0.57905885 1.12828577
0.232 1.18366748 0.38929224 1.72424164 0.47966878 1.0931673
0.45937603 1.09479766 0.80274459 0.44782081 1.04618114 0.25333333
0.82295953 0.40210109 0.72779393 0.75075946 0.41742276 0.2
0.8984279 0.92941713 0.69682427 0.69340983 1.02679348 0.2
0.67750539 0.85622403 0.77232588 1.09093307 1.14410169 0.59413937
0.54456339 0.64371752 0.40275133 0.72976606 1.40446885 0.2
0.31831299 0.3734494 0.2562224 1.05807688 1.02419007 0.82747632
0.49646186 0.72960178 0.48621114 1.42147072 0.65622314 0.31664379
1.55387576 0.58439879 2.03922765 1.47802266]
References
----------
......@@ -207,23 +207,31 @@ 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.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]
[ 2.65012897e-02 1.04414799e-01 2.73374899e-02 1.52782183e-02
0.00000000e+00 2.74548352e-02 3.54680121e-02 3.72671558e-02
2.39732112e-02 2.34942149e-02 2.97950758e-02 4.08351383e-02
4.31702840e-02 1.90317902e-02 3.66879750e-02 8.65571818e-03
0.00000000e+00 3.74046494e-02 4.22428130e-02 2.10503176e-02
1.39558854e-02 8.40349783e-03 0.00000000e+00 4.45784374e-03
3.38671970e-02 1.72390157e-02 4.82232543e-02 1.03071532e-04
1.42200266e-02 4.82793598e-02 1.82020235e-02 0.00000000e+00
7.04969679e-02 2.31267158e-02 6.42817952e-02 3.71139131e-02
3.81618985e-02 4.06231715e-02 2.16376594e-03 2.44758076e-02
0.00000000e+00 6.86198722e-03 1.36132952e-02 1.73886977e-02
2.30213129e-02 4.44999980e-02 0.00000000e+00 1.40589569e-02
0.00000000e+00 4.74213177e-02 2.65427674e-02 1.05684330e-01
6.30552365e-03 2.86320444e-02 4.50079022e-03 7.76843152e-02
2.88642900e-02 3.52207159e-02 2.01852506e-02 9.26784855e-04
4.35733012e-02 1.84745904e-02 1.35102237e-02 2.69638287e-02
1.88247064e-02 0.00000000e+00 2.03784688e-02 4.14981678e-02
1.79538495e-02 1.12983577e-02 3.23765203e-02 0.00000000e+00
3.99771399e-02 2.85164571e-03 2.18967289e-02 3.96111705e-02
3.40096863e-02 1.72800650e-02 1.36861815e-02 0.00000000e+00
1.19328203e-02 1.71726485e-02 0.00000000e+00 0.00000000e+00
6.33251858e-03 4.64324980e-03 1.33084980e-03 9.89021626e-02
3.52934995e-02 2.96267777e-02 1.73480268e-02 3.07545000e-02
2.47891161e-02 3.32486832e-02 7.45403501e-03 1.46792267e-02
0.00000000e+00 3.35642472e-02 8.78597450e-02 3.94517740e-02]
References
----------
......@@ -289,7 +297,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.0884414811909
0.0813233725942
References
----------
......@@ -365,31 +373,23 @@ 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()
[ 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]
[ 0.01610395 0.03518828 0.00387335 0.00506519 0. 0.02120586
0.00328345 0.00514034 0.00361398 0.01331587 0.00626757 0.00788882
0.01599836 0.00607798 0.00879484 0.01028104 0.01742029 0.00522399
0.0206618 0.0098984 0.00918508 0.01344131 0. 0.00047679
0.01760032 0.00078869 0.01045936 0. 0.00387405 0.01761267
0.00730843 0.00514523 0.01708638 0.0084908 0.01237811 0.01401104
0.0209564 0.0132232 0.00031255 0.01400855 0. 0. 0.0077233
0.00479587 0.01646928 0.01499744 0.01901516 0.00843277 0.
0.01764526 0.00243523 0.01726375 0.01272935 0.0163525 0.00382533
0.02037745 0.00758792 0.00350063 0.01303079 0. 0.02086308
0.00062028 0.00841231 0.00983605 0.00327547 0. 0.01016667
0.0170241 0.00782474 0.00516862 0.02394048 0. 0.00747778
0.00792131 0.01495136 0.01513948 0.02287957 0.00788276 0.0053207
0.00145811 0.00183203 0.0033493 0.01627589 0. 0.00476343
0.00937439 0.00200381 0.01400712 0.02135004 0.00549685 0.00230923
0.01426992 0.01083921 0.03439618 0.00514281 0.00114438 0.02259093
0.00672266 0.02753108 0.01859351]
References
----------
......@@ -483,23 +483,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.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]
[ 0.04096112 0.15271582 0.07130332 0.10597708 0. 0.58940763
0.04233924 0.03619048 0.04137002 0.05926363 0.06584407 0.06315985
0.22301815 0.02671845 0.10566551 0.08018763 0.57668762 0.08440303
0.17612948 0.37579015 0.0415804 0.19919108 0. 0.0141547
0.14901031 0.00910391 0.02680543 0. 0.0887711 0.0296914
0.09800672 0.06421615 0.16420105 0.10226839 0.08667606 0.07944174
0.17174637 0.10932321 0.0137295 0.09342906 0. 0.
0.11065065 0.03725047 0.23554212 0.10971862 0.54564134 0.0462946 0.
0.24820041 0.15281463 0.09449931 0.22419781 0.03108608 0.10964166
0.08642532 0.03495468 0.05656444 0.04045297 0. 0.13789871
0.0197414 0.05512572 0.08297112 0.21448002 0. 0.08649514
0.0718887 0.16546776 0.04108292 0.11710843 0. 0.12518596
0.04797708 0.02275816 0.10413969 0.1294644 0.08656727 0.28371423
0.1036658 0.01575087 0.02023104 0.067158 0. 0.03241519
0.19613692 0.05684533 0.29652909 0.03038526 0.02423028 0.01695595
0.0759531 0.17360708 0.51113999 0.03714076 0.03167552 0.04359062
0.0267188 0.47605313 0.06471942]
"""
if vprop == None:
......
......@@ -115,7 +115,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.0052816666666666671, 0.00046415526317530143)
(0.0057683333333333336, 0.00048270786829210805)
References
----------
......@@ -178,7 +178,7 @@ def global_clustering(g):
>>> seed(42)
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> print gt.global_clustering(g)
(0.0075696677384780283, 0.00039465997422993533)
(0.0093894614473184149, 0.00045618573270753208)
References
----------
......@@ -252,11 +252,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.0052816666666666671, 0.00046415526317530143)
(0.026543333333333332, 0.0010405374199048405)
(0.11648, 0.0019761350156302583)
(0.40672499999999995, 0.0031128844140121867)
(0.42646999999999996, 0.0030644539462829075)
(0.0057683333333333336, 0.00048270786829210805)
(0.025800144927536232, 0.00097643830822805055)
(0.11379500000000001, 0.0019584434515139259)
(0.39734630434782608, 0.0029727349290168477)
(0.43750507246376807, 0.0029440016153056154)
References
----------
......@@ -335,9 +335,9 @@ 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)
11
14
>>> print counts
[115780, 390603, 667, 764, 2666, 1694, 821, 5, 9, 4, 4]
[114808, 388149, 791, 901, 2064, 3266, 780, 6, 14, 16, 8, 9, 12, 13]
References
......@@ -421,7 +421,7 @@ def _graph_sig(g):
def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
threshold=0, undirected=None, self_loops=False,
parallel_edges = False, full_output = False,
parallel_edges=False, full_output=False,
shuffle_strategy= "uncorrelated"):
r"""
Obtain the motif significance profile, for subgraphs with k vertices. A
......@@ -505,9 +505,9 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
>>> g = gt.random_graph(100, lambda: (3,3))
>>> motifs, zscores = gt.motif_significance(g, 3)
>>> print len(motifs)
12
11
>>> print zscores
[0.84493166311546375, 0.83875258032645894, 1.2117425659306142, -0.20405718722884647, -0.69886762637118316, -0.68343227667794837, -0.92481997609648403, -0.11, -0.14999999999999999, -0.26000000000000001, -0.14000000000000001, -0.01]
[-0.77247260114237382, -0.99569269406173944, -0.89282671051270046, 0.3239871430063806, 0.30808421357288784, 0.78512106107239443, 0.53748384988656916, 1.9099999999999999, -0.12, -0.29999999999999999, -0.12]
"""
s_ms, counts = motifs(g, k, p, motif_list, undirected)
......
......@@ -107,7 +107,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.15379786566227244, 0.0052484342042414195)
(0.15254237288135594, 0.005229351128632439)
References
----------
......@@ -176,12 +176,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.46612545377150078, 0.010365307846181516)
(-0.45180067377519767, 0.010346379229268765)
>>> 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.63254355342678503, 0.011015440807502176)
(0.62451825727122212, 0.011132275391353953)
References
----------
......
......@@ -95,37 +95,35 @@ def edmonds_karp_max_flow(g, source, target, capacity, residual=None):
>>> 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. 0.24058962 0. 0. 0. 0. 0.
0.05688494 0.39495002 0.03148888 0. 0.05688494 0. 0.
[ 0.13339096 0.24058962 0. 0. 0. 0. 0.
0. 0.31026953 0. 0. 0. 0. 0.
0.10719866 0. 0. 0. 0. 0. 0.
0. 0.13339096 0. 0. 0. 0.10719866
0. 0. 0. 0. 0.10719866 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.24058962 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0.10719866 0. 0. 0.
0. 0. 0. 0. 0.31026953 0. 0.
0. 0. 0.44366049 0. 0. 0. 0.
0. 0. 0. 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.10719866 0. 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. 0. 0. 0. 0. 0.13361314
0. 0.23696565 0. 0. 0. 0. 0.
0. 0.10719866 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.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. ]
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0.10719866 0. 0. 0.
0. 0.10719866 0. 0.44366049 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0.10719866
0. 0. 0.31026953 0. 0.31026953 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. 0. 0. 0. ]
References
----------
......@@ -188,39 +186,38 @@ def push_relabel_max_flow(g, source, target, capacity, residual=None):
>>> 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.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]
[ 0.13339096 0.24058962 0. 0.01254176 0. 0. 0.
0. 0.31026953 0. 0.00745848 0.00335702 0.03601961
0.01254176 0.0794977 0. 0.00745848 0. 0.06036354
0.01254176 0.00335702 0. 0.14084944 0. 0.03601961
0.00745848 0.08285472 0. 0. 0.06372057 0.
0.10384163 0. 0.00335702 0. 0. 0. 0.
0. 0.02434393 0. 0. 0.02434393 0.2480481 0.
0. 0. 0. 0.0368857 0. 0.06372057
0. 0.03601961 0. 0.00335702 0.01254176 0.02434393
0. 0.10719866 0.04347809 0.01254176 0. 0.01254176
0. 0. 0.00335702 0.31026953 0.03601961 0. 0.
0. 0.45111897 0.00335702 0. 0. 0.
0.00335702 0. 0.00335702 0.06036354 0.00745848 0.01589879
0.0794977 0. 0.06372057 0. 0.00508328 0. 0.
0.06036354 0.06036354 0.03601961 0.0368857 0. 0.
0.00335702 0. 0. 0. 0.03601961 0.01589879
0.01254176 0. 0.01254176 0.03601961 0. 0.0368857
0.03601961 0.01589879 0.03601961 0. 0.03601961 0. 0.
0. 0.00335702 0.01589879 0.0368857 0.03601961 0.03601961
0.01254176 0.01254176 0. 0.00335702 0.02434393 0.00745848
0. 0.03937663 0.06036354 0. 0. 0. 0.
0. 0. 0. 0.02434393 0. 0.03601961
0. 0. 0.11974042 0. 0. 0.03601961
0.01254176 0.11465713 0.09465689 0.46800442 0.03601961 0.
0.00335702 0. 0. 0.03601961 0. 0.
0.00745848 0. 0. 0.03601961 0. 0.
0.09974018 0.00335702 0.01254176 0.00335702 0.01254176 0.
0.01254176 0.10719866 0. 0. 0. 0.31026953
0. 0.31026953 0. 0.01254176 0. 0. 0.
0.02000024 0.0108155 0.03601961 0. 0.03601961 0.03937663
0.00335702 0.01254176 0. 0. 0. 0.01688546
0. 0. 0.06036354 0.03601961 0. 0. ]
References
----------
......@@ -283,39 +280,38 @@ def kolmogorov_max_flow(g, source, target, capacity, residual=None):
>>> 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.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]
[ 0.13339096 0.24058962 0. 0.01254176 0. 0. 0.
0. 0.31026953 0. 0.00745848 0.00335702 0.03601961
0.01254176 0.0794977 0. 0.00745848 0. 0.06036354
0.01254176 0.00335702 0. 0.14084944 0. 0.03601961
0.00745848 0.08285472 0. 0. 0.06372057 0.
0.10384163 0. 0.00335702 0. 0. 0. 0.
0. 0.02434393 0. 0. 0.02434393 0.2480481 0.
0. 0. 0. 0.0368857 0. 0.06372057
0. 0.03601961 0. 0.00335702 0.01254176 0.02434393
0. 0.10719866 0.04347809 0.01254176 0. 0.01254176
0. 0. 0.00335702 0.31026953 0.03601961 0. 0.
0. 0.45111897 0.00335702 0. 0. 0.
0.00335702 0. 0.00335702 0.06036354 0.00745848 0.01589879
0.0794977 0. 0.06372057 0. 0.00508328 0. 0.
0.06036354 0.06036354 0.03601961 0.0368857 0. 0.
0.00335702 0. 0. 0. 0.03601961 0.01589879
0.01254176 0. 0.01254176 0.03601961 0. 0.0368857
0.03601961 0.01589879 0.03601961 0. 0.03601961 0. 0.
0. 0.00335702 0.01589879 0.0368857 0.03601961 0.03601961
0.01254176 0.01254176 0. 0.00335702 0.02434393 0.00745848
0. 0.03937663 0.06036354 0. 0. 0. 0.
0. 0. 0. 0.02434393 0. 0.03601961
0. 0. 0.11974042 0. 0. 0.03601961
0.01254176 0.11465713 0.09465689 0.46800442 0.03601961 0.
0.00335702 0. 0. 0.03601961 0. 0.
0.00745848 0. 0. 0.03601961 0. 0.
0.09974018 0.00335702 0.01254176 0.00335702 0.01254176 0.
0.01254176 0.10719866 0. 0. 0. 0.31026953
0. 0.31026953 0. 0.01254176 0. 0. 0.
0.02000024 0.0108155 0.03601961 0. 0.03601961 0.03937663
0.00335702 0.01254176 0. 0. 0. 0.01688546
0. 0. 0.06036354 0.03601961 0. 0. ]
References
----------
......
......@@ -137,7 +137,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.62318897995178757, 0.011431222500824638)
(0.62986894481988553, 0.011101504846821255)
The following samples an in,out-degree pair from the joint distribution:
......@@ -248,6 +248,7 @@ def random_graph(N, deg_sampler, deg_corr=None, directed=True,
self_loops=self_loops, verbose=verbose)
return g
@_limit_args({"strat": ["erdos", "correlated", "uncorrelated", "probabilistic"]})
def random_rewire(g, strat="uncorrelated", parallel_edges=False,
self_loops=False, deg_corr=None, verbose=False):
......
......@@ -194,9 +194,9 @@ def laplacian(g, deg="total", normalized=True, sparse=True, weight=None):
[ 0. 1. 0. ..., 0. 0. 0. ]
[ 0. 0. 1. ..., 0. 0. 0. ]
...,
[ 0. 0. 0. ..., 1. 0.05 0.05]
[ 0. 0. 0. ..., 1. 0.05 0. ]
[ 0. 0. 0. ..., 0. 1. 0. ]
[ 0. 0. 0. ..., 0. 0. 1. ]]
[ 0. 0.05 0. ..., 0. 0. 1. ]]
References
----------
......@@ -279,7 +279,7 @@ def incidence(g, sparse=True):
>>> print m.todense()
[[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 1.]
[ 0. 0. 0. ..., -1. 0. 0.]
...,
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
......
......@@ -361,10 +361,10 @@ def distance_histogram(g, weight=None, bins=None, samples=None,
>>> g = gt.random_graph(100, lambda: (3, 3))
>>> hist = gt.distance_histogram(g)
>>> print hist
[array([ 0., 300., 857., 2186., 3894., 2511., 152.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
[array([ 0., 300., 868., 2222., 3906., 2463., 141.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
>>> hist = gt.distance_histogram(g, samples=10)
>>> print hist
[array([ 0., 30., 88., 222., 384., 251., 15.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
[array([ 0., 30., 87., 230., 408., 223., 12.]), array([0, 1, 2, 3, 4, 5, 6], dtype=uint64)]
"""
if bins == None:
......
......@@ -105,7 +105,7 @@ def subgraph_isomorphism(sub, g, max_n=0):
>>> sub = gt.random_graph(10, lambda: (poisson(1.8), poisson(1.9)))
>>> vm, em = gt.subgraph_isomorphism(sub, g)
>>> print len(vm)
175
93
>>> for i in xrange(len(vm)):
... g.set_vertex_filter(None)
... g.set_edge_filter(None)
......@@ -229,20 +229,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 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 0
0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1
0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0
1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0
0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1
0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 1 0 0 0 0 1 1 0 1 0 0
1 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 0 0 0 1 0 0 1 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 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 1 0 1 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 1 0 0 0 0 0 0
0 0 0 1 0 1 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 0 0 0 0 0
1 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 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 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0
0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0
1 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 0 0 1
0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1
0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 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 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
0 0 0 1 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 1
0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0
1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 0 0
0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1
0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1]
References
----------
......@@ -310,10 +310,10 @@ def dominator_tree(g, root, dom_map=None):
>>> root = [v for v in g.vertices() if v.in_degree() == 0]
>>> dom = gt.dominator_tree(g, root[0])
>>> print dom.a
[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 0 0 0 0 0 0 0 0 0 0
78 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 0 0
0 0 0 20 0 0 0 0 0 0 0 50 0 0 0 0 0 0 0 0 0 0 0 0 0]
[ 0 0 72 0 0 0 0 0 0 0 0 0 0 0 21 0 0 0 0 0 0 3 0 0 0
0 0 0 0 0 0 41 0 0 0 0 0 0 0 0 0 11 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 3 0 0
0 0 0 0 0 2 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 0]
References
----------
......@@ -355,8 +355,8 @@ def topological_sort(g):
>>> g.set_edge_filter(tree)
>>> sort = gt.topological_sort(g)