Commit 14c0e36f authored by Tiago Peixoto's avatar Tiago Peixoto

Modify docstring tests after RNG update

parent 0f5d1a99
......@@ -600,7 +600,7 @@ def eigenvector(g, weight=None, vprop=None, epsilon=1e-6, max_iter=None):
>>> w.a = np.random.random(len(w.a)) * 42
>>> ee, x = gt.eigenvector(g, w)
>>> print(ee)
729.229595705175
724.3027459221508
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_fill_color=x,
... vertex_size=gt.prop_to_size(x, mi=5, ma=15),
... vcmap=matplotlib.cm.gist_heat,
......
......@@ -121,7 +121,7 @@ def local_clustering(g, prop=None, undirected=True):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> clust = gt.local_clustering(g)
>>> print(gt.vertex_average(g, clust))
(0.007177777777777778, 0.0003966968553716155)
(0.006177777777777778, 0.0003696618407994121)
References
----------
......@@ -182,7 +182,7 @@ def global_clustering(g):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> print(gt.global_clustering(g))
(0.007177777777777778, 0.0003970939493209407)
(0.006177777777777778, 0.0003700318726720911)
References
----------
......@@ -261,11 +261,11 @@ def extended_clustering(g, props=None, max_depth=3, undirected=False):
>>> for i in range(0, 5):
... print(gt.vertex_average(g, clusts[i]))
...
(0.005535, 0.00046266726404860573)
(0.02351, 0.0009395843702876762)
(0.11651833333333333, 0.0019837472110181336)
(0.391765, 0.0030221072114043567)
(0.4439983333333333, 0.0030393922085216675)
(0.00421, 0.00041685103920811916)
(0.027226666666666666, 0.0010073522830778825)
(0.11549166666666667, 0.002081399085417734)
(0.41280666666666666, 0.0029479221231987185)
(0.4205716666666666, 0.003156465741141506)
References
----------
......@@ -347,9 +347,9 @@ def motifs(g, k, p=1.0, motif_list=None, return_maps=False):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> motifs, counts = gt.motifs(gt.GraphView(g, directed=False), 4)
>>> print(len(motifs))
63
52
>>> print(counts)
[28448, 28343, 28929, 29600, 159144, 98111, 98187, 33446, 284, 176, 70, 139, 210, 37, 526, 280, 85, 156, 553, 620, 469, 585, 443, 380, 203, 362, 210, 313, 241, 100, 295, 64, 253, 278, 250, 7, 5, 3, 4, 4, 3, 2, 6, 1, 7, 2, 1, 2, 3, 1, 1, 3, 2, 3, 3, 1, 1, 2, 2, 1, 1, 1, 1]
[29259, 29111, 28420, 28618, 163659, 96696, 96821, 31366, 295, 162, 185, 257, 58, 74, 562, 300, 80, 240, 273, 112, 379, 167, 329, 536, 605, 641, 176, 540, 340, 317, 298, 87, 306, 275, 252, 9, 3, 11, 5, 9, 7, 2, 2, 1, 3, 1, 2, 1, 2, 1, 1, 1]
References
......@@ -521,8 +521,7 @@ def motif_significance(g, k, n_shuffles=100, p=1.0, motif_list=None,
>>> print(len(motifs))
11
>>> print(zscores)
[0.91152284386957971, 0.79611981715847313, 0.75844561796064847, -0.69370586236292986, -0.83494968780939771, -0.58698299759329431, -0.25891660868480709, 0.89, -0.07, -0.29, -0.17]
[0.04162670293683441, 0.046769781223679897, 0.55888261369689918, 0.82906624302416043, -0.41384527710386287, -0.42070845824900477, -1.3262411347517733, 1.82, -0.13, -0.37, -0.22]
"""
s_ms, counts = motifs(g, k, p, motif_list)
......
......@@ -115,7 +115,7 @@ def assortativity(g, deg):
... vertex_corr=lambda i,k: 1.0 / (1 + abs(i - k)), directed=False,
... n_iter=100)
>>> gt.assortativity(g, "out")
(0.1427961503065472, 0.005111874804434137)
(0.1425854833491391, 0.005107908315851484)
References
----------
......@@ -191,13 +191,13 @@ def scalar_assortativity(g, deg):
... vertex_corr=lambda i,k: abs(i-k),
... directed=False, n_iter=100)
>>> gt.scalar_assortativity(g, "out")
(-0.4447873152401369, 0.010434117272182804)
(-0.44147938242732404, 0.01047064816533614)
>>> g = gt.random_graph(1000, lambda: sample_k(40), model="probabilistic",
... vertex_corr=lambda i, k: 1.0 / (1 + abs(i - k)),
... directed=False, n_iter=100)
>>> gt.scalar_assortativity(g, "out")
(0.6014583531475572, 0.011588069772198617)
(0.6216815584946155, 0.011152910837726114)
References
----------
......
......@@ -140,7 +140,7 @@ def edmonds_karp_max_flow(g, source, target, capacity, residual=None):
>>> res.a = cap.a - res.a # the actual flow
>>> max_flow = sum(res[e] for e in tgt.in_edges())
>>> print(max_flow)
44.89059578411614
45.59770256530269
>>> pos = g.vertex_properties["pos"]
>>> gt.graph_draw(g, pos=pos, edge_pen_width=gt.prop_to_size(res, mi=0, ma=5, power=1), output="example-edmonds-karp.pdf")
<...>
......@@ -221,7 +221,7 @@ def push_relabel_max_flow(g, source, target, capacity, residual=None):
>>> res.a = cap.a - res.a # the actual flow
>>> max_flow = sum(res[e] for e in tgt.in_edges())
>>> print(max_flow)
44.89059578411614
45.59770256530269
>>> pos = g.vertex_properties["pos"]
>>> gt.graph_draw(g, pos=pos, edge_pen_width=gt.prop_to_size(res, mi=0, ma=5, power=1), output="example-push-relabel.pdf")
<...>
......@@ -303,7 +303,7 @@ def boykov_kolmogorov_max_flow(g, source, target, capacity, residual=None):
>>> res.a = cap.a - res.a # the actual flow
>>> max_flow = sum(res[e] for e in tgt.in_edges())
>>> print(max_flow)
44.89059578411614
45.59770256530269
>>> pos = g.vertex_properties["pos"]
>>> gt.graph_draw(g, pos=pos, edge_pen_width=gt.prop_to_size(res, mi=0, ma=3, power=1), output="example-kolmogorov.pdf")
<...>
......
......@@ -193,7 +193,7 @@ def random_graph(N, deg_sampler, directed=True,
... vertex_corr=lambda i, k: 1.0 / (1 + abs(i - k)), directed=False,
... n_iter=100)
>>> gt.scalar_assortativity(g, "out")
(0.6321636468713748, 0.01082292099309249)
(0.6377260889137862, 0.010604512511127259)
The following samples an in,out-degree pair from the joint distribution:
......@@ -228,6 +228,7 @@ def random_graph(N, deg_sampler, directed=True,
<...>
>>> ylabel("out-degree")
<...>
>>> tight_layout()
>>> savefig("combined-deg-hist.pdf")
.. testcode::
......@@ -261,9 +262,7 @@ def random_graph(N, deg_sampler, directed=True,
Lets plot the average degree correlations to check.
>>> figure(8, 5)
<...>
>>> axes([0.1,0.15,0.63,0.8])
>>> figure()
<...>
>>> corr = gt.avg_neighbour_corr(g, "in", "in")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
......@@ -281,12 +280,13 @@ def random_graph(N, deg_sampler, directed=True,
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{out}\right>$ vs out")
<...>
>>> legend(bbox_to_anchor=(1.01, 0.5), loc="center left", borderaxespad=0.)
>>> legend(loc="lower right", borderaxespad=0., framealpha=0.8)
<...>
>>> xlabel("Source degree")
<...>
>>> ylabel("Average target degree")
<...>
>>> tight_layout()
>>> savefig("deg-corr-dir.pdf")
.. testcode::
......@@ -617,7 +617,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_orig.png", output_size=(300, 300))
>>> gt.random_rewire(g, "correlated")
641
601
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_corr.pdf", output_size=(300, 300))
<...>
......@@ -628,7 +628,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_corr.png", output_size=(300, 300))
>>> gt.random_rewire(g)
186
215
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_uncorr.pdf", output_size=(300, 300))
<...>
......@@ -639,7 +639,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
gt.graph_draw(g, pos=pos, output="rewire_uncorr.png", output_size=(300, 300))
>>> gt.random_rewire(g, "erdos")
13
16
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_erdos.pdf", output_size=(300, 300))
<...>
......@@ -661,7 +661,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
We can try with larger graphs to get better statistics, as follows.
>>> figure(8, 5)
>>> figure()
<...>
>>> g = gt.random_graph(30000, lambda: sample_k(20), model="probabilistic",
... vertex_corr=lambda i, j: exp(abs(i-j)), directed=False,
......@@ -670,17 +670,17 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label="Original")
<...>
>>> gt.random_rewire(g, "correlated")
230
252
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="*", label="Correlated")
<...>
>>> gt.random_rewire(g)
102
92
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label="Uncorrelated")
<...>
>>> gt.random_rewire(g, "erdos")
18
9
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-", label=r"Erd\H{o}s")
<...>
......@@ -690,6 +690,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
<...>
>>> legend(loc="best")
<...>
>>> tight_layout()
>>> savefig("shuffled-stats.pdf")
.. testcode::
......@@ -713,9 +714,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
... model="probabilistic",
... vertex_corr=lambda a, b: (p.pmf(a[0], b[1]) * p.pmf(a[1], 20 - b[0])),
... n_iter=100)
>>> figure(8, 5)
<...>
>>> axes([0.1,0.15,0.6,0.8])
>>> figure()
<...>
>>> corr = gt.avg_neighbour_corr(g, "in", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
......@@ -726,7 +725,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
... label=r"$\left<\text{i}\right>$ vs o")
<...>
>>> gt.random_rewire(g, "correlated")
4185
4199
>>> corr = gt.avg_neighbour_corr(g, "in", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{o}\right>$ vs i, corr.")
......@@ -736,7 +735,7 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
... label=r"$\left<\text{i}\right>$ vs o, corr.")
<...>
>>> gt.random_rewire(g, "uncorrelated")
161
193
>>> corr = gt.avg_neighbour_corr(g, "in", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{o}\right>$ vs i, uncorr.")
......@@ -745,12 +744,13 @@ def random_rewire(g, model="uncorrelated", n_iter=1, edge_sweep=True,
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="o-",
... label=r"$\left<\text{i}\right>$ vs o, uncorr.")
<...>
>>> legend(bbox_to_anchor=(1.01, 0.5), loc="center left", borderaxespad=0.)
>>> legend(loc="lower right", borderaxespad=0., framealpha=0.8)
<...>
>>> xlabel("Source degree")
<...>
>>> ylabel("Average target degree")
<...>
>>> tight_layout()
>>> savefig("shuffled-deg-corr-dir.pdf")
.. testcode::
......@@ -865,30 +865,25 @@ def line_graph(g):
>>> g = gt.collection.data["lesmis"]
>>> lg, vmap = gt.line_graph(g)
>>> gt.graph_draw(g, pos=g.vp["pos"], output="lesmis.pdf")
<...>
>>> pos = gt.graph_draw(lg, output="lesmis-lg.pdf")
>>> pos = gt.graph_draw(lg, output_size=(300, 300), output="lesmis-lg.pdf")
.. testcode::
:hide:
gt.graph_draw(g, pos=g.vp["pos"], output="lesmis.png")
pos = gt.graph_draw(lg, pos=pos, output="lesmis-lg.png")
gt.graph_draw(lg, pos=pos, output_size=(300, 300), output="lesmis-lg.png")
.. figure:: lesmis.png
:align: left
Coappearances of characters in Victor Hugo's novel "Les Miserables".
.. figure:: lesmis-lg.png
:align: right
:align: center
Line graph of the coappearance network on the left.
Line graph of the coappearance of characters in Victor Hugo's novel "Les
Misérables".
References
----------
.. [line-wiki] http://en.wikipedia.org/wiki/Line_graph
"""
lg = Graph(directed=g.is_directed())
......
......@@ -281,14 +281,14 @@ def bfs_search(g, source, visitor=BFSVisitor()):
--> Carlos has been discovered!
--> Isaac has been discovered!
Eve has been examined...
--> Imothep has been discovered!
--> Carol has been discovered!
--> Imothep has been discovered!
Chuck has been examined...
Carlos has been examined...
--> Alice has been discovered!
Isaac has been examined...
Imothep has been examined...
Carol has been examined...
Imothep has been examined...
Alice has been examined...
--> Oscar has been discovered!
--> Dave has been discovered!
......@@ -488,23 +488,15 @@ def dfs_search(g, source, visitor=DFSVisitor()):
--> Bob has been discovered!
edge (Bob, Eve) has been examined...
--> Eve has been discovered!
edge (Eve, Isaac) has been examined...
--> Isaac has been discovered!
edge (Isaac, Bob) has been examined...
edge (Isaac, Chuck) has been examined...
--> Chuck has been discovered!
edge (Chuck, Eve) has been examined...
edge (Chuck, Isaac) has been examined...
edge (Chuck, Imothep) has been examined...
--> Imothep has been discovered!
edge (Imothep, Carol) has been examined...
edge (Eve, Bob) has been examined...
edge (Eve, Carol) has been examined...
--> Carol has been discovered!
edge (Carol, Eve) has been examined...
edge (Carol, Imothep) has been examined...
--> Imothep has been discovered!
edge (Imothep, Carol) has been examined...
edge (Imothep, Carlos) has been examined...
--> Carlos has been discovered!
edge (Carlos, Eve) has been examined...
edge (Carlos, Imothep) has been examined...
edge (Carlos, Bob) has been examined...
edge (Carlos, Alice) has been examined...
--> Alice has been discovered!
......@@ -513,28 +505,34 @@ def dfs_search(g, source, visitor=DFSVisitor()):
edge (Oscar, Alice) has been examined...
edge (Oscar, Dave) has been examined...
--> Dave has been discovered!
edge (Dave, Oscar) has been examined...
edge (Dave, Alice) has been examined...
edge (Dave, Oscar) has been examined...
edge (Alice, Dave) has been examined...
edge (Alice, Carlos) has been examined...
edge (Carlos, Eve) has been examined...
edge (Carlos, Imothep) has been examined...
edge (Imothep, Chuck) has been examined...
edge (Imothep, Eve) has been examined...
--> Chuck has been discovered!
edge (Chuck, Bob) has been examined...
edge (Chuck, Eve) has been examined...
edge (Chuck, Isaac) has been examined...
--> Isaac has been discovered!
edge (Isaac, Bob) has been examined...
edge (Isaac, Chuck) has been examined...
edge (Isaac, Eve) has been examined...
edge (Eve, Imothep) has been examined...
edge (Eve, Bob) has been examined...
edge (Eve, Carol) has been examined...
edge (Chuck, Imothep) has been examined...
edge (Imothep, Eve) has been examined...
edge (Eve, Carlos) has been examined...
edge (Eve, Chuck) has been examined...
edge (Eve, Isaac) has been examined...
edge (Eve, Imothep) has been examined...
edge (Bob, Chuck) has been examined...
edge (Bob, Carlos) has been examined...
edge (Bob, Isaac) has been examined...
>>> print(time.a)
[0 7 5 6 3 9 1 2 8 4]
[0 5 2 4 8 7 1 9 6 3]
>>> print(pred.a)
[0 3 9 9 7 8 0 6 1 4]
[0 3 6 9 9 8 0 4 1 2]
References
----------
......@@ -746,7 +744,7 @@ def dijkstra_search(g, source, weight, visitor=DijkstraVisitor(), dist_map=None,
>>> time = g.new_vertex_property("int")
>>> dist, pred = gt.dijkstra_search(g, g.vertex(0), weight, VisitorExample(name, time))
--> Bob has been discovered!
--> Bob has been discovered!
edge (Bob, Eve) has been examined...
edge (Bob, Eve) has been relaxed...
--> Eve has been discovered!
......@@ -759,29 +757,29 @@ def dijkstra_search(g, source, weight, visitor=DijkstraVisitor(), dist_map=None,
edge (Bob, Isaac) has been examined...
edge (Bob, Isaac) has been relaxed...
--> Isaac has been discovered!
edge (Eve, Isaac) has been examined...
edge (Eve, Imothep) has been examined...
edge (Eve, Imothep) has been relaxed...
--> Imothep has been discovered!
edge (Eve, Bob) has been examined...
edge (Eve, Carol) has been examined...
edge (Eve, Carol) has been relaxed...
--> Carol has been discovered!
edge (Eve, Carlos) has been examined...
edge (Eve, Chuck) has been examined...
edge (Eve, Isaac) has been examined...
edge (Eve, Imothep) has been examined...
edge (Eve, Imothep) has been relaxed...
--> Imothep has been discovered!
edge (Isaac, Bob) has been examined...
edge (Isaac, Chuck) has been examined...
edge (Isaac, Eve) has been examined...
edge (Chuck, Bob) has been examined...
edge (Chuck, Eve) has been examined...
edge (Chuck, Isaac) has been examined...
edge (Chuck, Imothep) has been examined...
edge (Chuck, Bob) has been examined...
edge (Carlos, Eve) has been examined...
edge (Carlos, Imothep) has been examined...
edge (Carlos, Bob) has been examined...
edge (Carlos, Alice) has been examined...
edge (Carlos, Alice) has been relaxed...
--> Alice has been discovered!
edge (Carlos, Eve) has been examined...
edge (Carlos, Imothep) has been examined...
edge (Imothep, Carol) has been examined...
edge (Imothep, Carlos) has been examined...
edge (Imothep, Chuck) has been examined...
......@@ -797,10 +795,10 @@ def dijkstra_search(g, source, weight, visitor=DijkstraVisitor(), dist_map=None,
edge (Carol, Imothep) has been examined...
edge (Oscar, Alice) has been examined...
edge (Oscar, Dave) has been examined...
edge (Dave, Oscar) has been examined...
edge (Dave, Alice) has been examined...
edge (Dave, Oscar) has been examined...
>>> print(time.a)
[0 7 6 3 2 9 1 4 8 5]
[0 7 5 3 2 9 1 4 8 6]
>>> print(pred.a)
[0 3 6 0 0 1 0 0 1 6]
>>> print(dist.a)
......
......@@ -102,7 +102,7 @@ def adjacency(g, weight=None, index=None):
>>> figure(figsize=(8, 2))
<...>
>>> scatter(real(ew), imag(ew), c=abs(ew))
>>> scatter(real(ew), imag(ew), c=sqrt(abs(ew)), linewidths=0, alpha=0.6)
<...>
>>> xlabel(r"$\operatorname{Re}(\lambda)$")
<...>
......@@ -220,7 +220,7 @@ def laplacian(g, deg="total", normalized=False, weight=None, index=None):
>>> figure(figsize=(8, 2))
<...>
>>> scatter(real(ew), imag(ew), c=abs(ew))
>>> scatter(real(ew), imag(ew), c=sqrt(abs(ew)), linewidths=0, alpha=0.6)
<...>
>>> xlabel(r"$\operatorname{Re}(\lambda)$")
<...>
......@@ -244,7 +244,7 @@ def laplacian(g, deg="total", normalized=False, weight=None, index=None):
>>> figure(figsize=(8, 2))
<...>
>>> scatter(real(ew), imag(ew), c=abs(ew))
>>> scatter(real(ew), imag(ew), c=sqrt(abs(ew)), linewidths=0, alpha=0.6)
<...>
>>> xlabel(r"$\operatorname{Re}(\lambda)$")
<...>
......@@ -359,7 +359,7 @@ def incidence(g, vindex=None, eindex=None):
...,
[ 0. 0. -1. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 1. 0. 0.]]
[ 0. 0. 0. ..., 0. 0. 0.]]
References
----------
......@@ -440,7 +440,7 @@ def transition(g, weight=None, index=None):
>>> figure(figsize=(8, 2))
<...>
>>> scatter(real(ew), imag(ew), c=abs(ew))
>>> scatter(real(ew), imag(ew), c=sqrt(abs(ew)), linewidths=0, alpha=0.6)
<...>
>>> xlabel(r"$\operatorname{Re}(\lambda)$")
<...>
......@@ -537,7 +537,7 @@ def modularity_matrix(g, weight=None, index=None):
>>> figure(figsize=(8, 2))
<...>
>>> scatter(real(ew), imag(ew), c=abs(ew))
>>> scatter(real(ew), imag(ew), c=sqrt(abs(ew)), linewidths=0, alpha=0.6)
<...>
>>> xlabel(r"$\operatorname{Re}(\lambda)$")
<...>
......
......@@ -113,8 +113,8 @@ def vertex_hist(g, deg, bins=[0, 1], float_count=True):
>>> from numpy.random import poisson
>>> g = gt.random_graph(1000, lambda: (poisson(5), poisson(5)))
>>> print(gt.vertex_hist(g, "out"))
[array([ 10., 36., 90., 147., 164., 165., 142., 109., 70.,
31., 28., 7., 1.]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], dtype=uint64)]
[array([ 7., 33., 91., 145., 165., 164., 152., 115., 62.,
29., 28., 6., 1., 1., 0., 1.]), array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], dtype=uint64)]
"""
ret = libgraph_tool_stats.\
......@@ -177,7 +177,7 @@ def edge_hist(g, eprop, bins=[0, 1], float_count=True):
>>> eprop = g.new_edge_property("double")
>>> eprop.get_array()[:] = random(g.num_edges())
>>> print(gt.edge_hist(g, eprop, linspace(0, 1, 11)))
[array([ 483., 462., 467., 493., 498., 486., 515., 552., 496., 548.]), array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])]
[array([ 501., 441., 478., 480., 506., 494., 507., 535., 499., 559.]), array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])]
"""
......@@ -231,7 +231,7 @@ def vertex_average(g, deg):
>>> from numpy.random import poisson
>>> g = gt.random_graph(1000, lambda: (poisson(5), poisson(5)))
>>> print(gt.vertex_average(g, "in"))
(4.982, 0.06855418295042251)
(4.975, 0.0686758691244603)
"""
ret = libgraph_tool_stats.\
......@@ -284,7 +284,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.49849732125677476, 0.004086182531863621)
(0.4989741369720412, 0.004101065927783255)
"""
ret = libgraph_tool_stats.\
......@@ -408,10 +408,10 @@ def distance_histogram(g, weight=None, bins=[0, 1], samples=None,
>>> g = gt.random_graph(100, lambda: (3, 3))
>>> hist = gt.distance_histogram(g)
>>> print(hist)
[array([ 0., 300., 866., 2206., 3893., 2476., 159.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)]
[array([ 0., 300., 865., 2214., 3857., 2480., 184.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)]
>>> hist = gt.distance_histogram(g, samples=10)
>>> print(hist)
[array([ 0., 30., 84., 217., 385., 249., 25.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)]
[array([ 0., 30., 88., 226., 391., 240., 15.]), array([0, 1, 2, 3, 4, 5, 6, 7], dtype=uint64)]
"""
if samples != None:
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment