Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tiago Peixoto
graph-tool
Commits
45f28a19
Commit
45f28a19
authored
Nov 15, 2013
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docstrings
parent
26cdde1e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
38 deletions
+37
-38
src/graph_tool/__init__.py
src/graph_tool/__init__.py
+1
-1
src/graph_tool/centrality/__init__.py
src/graph_tool/centrality/__init__.py
+1
-1
src/graph_tool/clustering/__init__.py
src/graph_tool/clustering/__init__.py
+2
-2
src/graph_tool/community/blockmodel.py
src/graph_tool/community/blockmodel.py
+2
-2
src/graph_tool/community/nested_blockmodel.py
src/graph_tool/community/nested_blockmodel.py
+1
-1
src/graph_tool/correlations/__init__.py
src/graph_tool/correlations/__init__.py
+3
-3
src/graph_tool/generation/__init__.py
src/graph_tool/generation/__init__.py
+9
-9
src/graph_tool/topology/__init__.py
src/graph_tool/topology/__init__.py
+18
-19
No files found.
src/graph_tool/__init__.py
View file @
45f28a19
...
...
@@ -1485,8 +1485,8 @@ class Graph(object):
>>> g.graph_properties["gnat"] = g.new_graph_property("string", "hi there!")
>>> g.list_properties()
gnat (graph) (type: string, val: hi there!)
foo (vertex) (type: double)
bar (vertex) (type: python::object)
foo (vertex) (type: double)
foo (edge) (type: vector<double>)
"""
...
...
src/graph_tool/centrality/__init__.py
View file @
45f28a19
...
...
@@ -695,7 +695,7 @@ def katz(g, alpha=0.01, beta=None, weight=None, vprop=None, epsilon=1e-6,
>>> g = gt.collection.data["polblogs"]
>>> g = gt.GraphView(g, vfilt=gt.label_largest_component(g))
>>> w = g.new_edge_property("double")
>>> w.a = np.random.random(len(w.a))
* 42
>>> w.a = np.random.random(len(w.a))
>>> x = gt.katz(g, weight=w)
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_fill_color=x,
... vertex_size=gt.prop_to_size(x, mi=5, ma=15),
...
...
src/graph_tool/clustering/__init__.py
View file @
45f28a19
...
...
@@ -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.007
2, 0.00039746045691969764
)
(0.007
177777777777778, 0.0003966968553716155
)
References
----------
...
...
@@ -182,7 +182,7 @@ def global_clustering(g):
>>> g = gt.random_graph(1000, lambda: (5,5))
>>> print(gt.global_clustering(g))
(0.0071
82172103638073, 0.0003970213508956326
)
(0.0071
77777777777778, 0.0003970939493209407
)
References
----------
...
...
src/graph_tool/community/blockmodel.py
View file @
45f28a19
...
...
@@ -1870,7 +1870,7 @@ def collect_edge_marginals(state, p=None):
... ds, nmoves = gt.mcmc_sweep(state)
... pe = gt.collect_edge_marginals(state, pe)
>>> gt.bethe_entropy(state, pe)[0]
1
6.3194777448721
5
1
7.44308984281812
5
"""
if
p
is
None
:
...
...
@@ -1922,7 +1922,7 @@ def collect_vertex_marginals(state, p=None):
... ds, nmoves = gt.mcmc_sweep(state)
... pv = gt.collect_vertex_marginals(state, pv)
>>> gt.mf_entropy(state, pv)
1
8.34876135251492
7
1
9.9495552894271
7
>>> gt.graph_draw(g, pos=g.vp["pos"], vertex_shape="pie", vertex_pie_fractions=pv, output="polbooks_blocks_soft_B4.pdf")
<...>
...
...
src/graph_tool/community/nested_blockmodel.py
View file @
45f28a19
...
...
@@ -328,7 +328,7 @@ def nested_mcmc_sweep(state, beta=1., random_move=False, c=1., sequential=True,
>>> state = gt.NestedBlockState(g, Bs=[10, 5, 3, 2, 1], deg_corr=True)
>>> ret = gt.nested_mcmc_sweep(state)
>>> print(ret)
[(-0.
2394348601378746
3, 5
7
), (-
0.017558577944127587
,
2
), (0.0, 0), (-0.00
12759602078996138
, 1), (0.0, 0)]
[(-0.
1188139406173872
3, 5
8
), (-
1.2855474804244876e-05
,
1
), (0.0, 0), (-0.00
3488958656098635
, 1), (0.0, 0)]
References
----------
...
...
src/graph_tool/correlations/__init__.py
View file @
45f28a19
...
...
@@ -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.1
3903518011375607, 0.005051876804786422
)
(0.1
419534824769149, 0.005098622437085927
)
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.4
4070158356400696, 0.010592022444678
63
2
)
(-0.4
5182410730944034, 0.010288182870044
63
9
)
>>> 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.6
007430887839058, 0.011569809783643956
)
(0.6
421210898147616, 0.010632143985746339
)
References
----------
...
...
src/graph_tool/generation/__init__.py
View file @
45f28a19
...
...
@@ -189,7 +189,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.6
285094791115295, 0.010745128857935755
)
(0.6
197157767573332, 0.010781011616659146
)
The following samples an in,out-degree pair from the joint distribution:
...
...
@@ -584,7 +584,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")
189
212
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_corr.pdf", output_size=(300, 300))
<...>
...
...
@@ -595,7 +595,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)
19
7
20
7
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_uncorr.pdf", output_size=(300, 300))
<...>
...
...
@@ -606,7 +606,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")
2
6
2
1
>>> pos = gt.arf_layout(g)
>>> gt.graph_draw(g, pos=pos, output="rewire_erdos.pdf", output_size=(300, 300))
<...>
...
...
@@ -637,17 +637,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")
2
06
2
12
>>> corr = gt.avg_neighbour_corr(g, "out", "out")
>>> errorbar(corr[2][:-1], corr[0], yerr=corr[1], fmt="*", label="Correlated")
<...>
>>> gt.random_rewire(g)
10
9
1
2
0
>>> 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")
13
20
>>> 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")
<...>
...
...
@@ -693,7 +693,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")
4
323
4
130
>>> 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.")
...
...
@@ -703,7 +703,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")
1
53
1
94
>>> 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.")
...
...
src/graph_tool/topology/__init__.py
View file @
45f28a19
...
...
@@ -797,12 +797,12 @@ def label_largest_component(g, directed=None):
>>> g = gt.random_graph(100, lambda: poisson(1), directed=False)
>>> l = gt.label_largest_component(g)
>>> print(l.a)
[1 0 0 0 0
1
0 0 0 0 0
1
0 0 0 0
1
0 0 0 0 0 0 0 0 0
0
0 0 1 0 0 0 0 0
1
0
0 0 0 0 0 0 0 0 1 0 0 0
1 0 1 1 1
0 0 0 0 0 0 0 0 0 1 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
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
1
0 0
1 1
0 0 1 0 0 0 0 0
0
0
0 0
1 0 0 0
0 0 0 0 0 0 1 0
1
0 0 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 1 0 0 0 0 0 0 0
1
0 0
1 0 1
0 0 0
1 1 1 0
]
>>> u = gt.GraphView(g, vfilt=l) # extract the largest component as a graph
>>> print(u.num_vertices())
1
6
1
8
"""
label
=
g
.
new_vertex_property
(
"bool"
)
...
...
@@ -848,18 +848,18 @@ def label_out_component(g, root):
>>> g = gt.random_graph(100, lambda: poisson(2.2), directed=False)
>>> l = gt.label_out_component(g, g.vertex(2))
>>> print(l.a)
[1 1 1 1
0 1 1 1 1 1 1 0 1 1 0
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 1 0
1 1 0
0
1 1 0 1 1
0 0
1 1 1 1
0
1 0
0
1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1 1 1 1
1
1 1 1 0 1 1 1 0 1 1
0
0]
[1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 0
0 0 1 1 1 0
1 1 0 1 1 0 1 1
1 1
1 1 1 1
1 1
1 0
1
1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1
1 1 0 1 1 1 1 1 1 1 1 1 1
0
1 1 1 0 1 1 1 0 1 1
1
0]
The in-component can be obtained by reversing the graph.
>>> l = gt.label_out_component(gt.GraphView(g, reversed=True, directed=True),
... g.vertex(1))
>>> print(l.a)
[1 1 1 0 0
1 1
0
1
0 0 0 0 1 0 0 0
1
0 0
1
1 0 0
1
0 1 0 0 0 0 0 0
1 1
0 0
0 1 0 0
0
1 0
1
1 0 0 0 0
1 1
0 0 0 0 1
0
0
0
1 1
0
1 0 0 0
1
0 0
1 1
0
1
1
0 0 0 0 1
1
0 1 1 0 1
1 1
0 0
1
0 0 0 0 0 1 0 0 0]
[
0
1 1 1 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 0 0 0
0
0 0
0 1 0 0 1 0
0
1 0 0 0 0
0 0 0
0 0 0 0 1
1
0 1 1 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 1
0
0 0
0
0 0 0 0 0 1 0 0 0]
"""
label
=
g
.
new_vertex_property
(
"bool"
)
...
...
@@ -931,18 +931,17 @@ def label_biconnected_components(g, eprop=None, vprop=None):
>>> g = gt.random_graph(100, lambda: poisson(2), directed=False)
>>> comp, art, hist = gt.label_biconnected_components(g)
>>> print(comp.a)
[
51 51 51 51 51 51 11 52 51 51 44 42 41 45 49 23 19 51 51 32 38 51 24 37 51
51 51 10 8 51 20 43 51 51 51 51 51 47 46 51 51 13 14 51 51 51 51 33 30 51
1 21 51 51 51 35 36 6 51 26 27 7 12 4 3 29 28 51 51 51 31 51 51 0
3
9
51 51 51 34 40 51 51 9 17 51 51 18 15 22 2 16 50 5 48 51 51 53 51 51
2
5
]
[
35 23 35 35 32 32 35 35 1 37 32 28 32 35 32 2 32 29 35 35 13 14 34 12 17
35 35 35 35 35 3 35 35 35 35 35 35 28 28 35 33 35 19 35 35 35 35 6 35 35
24 39 35 31 35 10 9 22 32 35 4 25 26 35 35 7 35 35 35 35 35 35 36 35
3
5
35 32 35 0 35 35 35 32 35 28 32 35 20 30 27 18 38 16 5 15 11 28 35 8
2
1
]
>>> print(art.a)
[1 0
1
0 0
1
0 0
1
1 0 0 1
1
0 0
0
0 0 0 1
0
0 0 1 0
1
0 0 0 1 0 0
0 1 1
0
0 1 0 0
1 1
0 1
1
0 0 0
1 1
0 1
1
0 0 0 1 0 0 1 0 1 0 0 1 1 0 0 0 0 0 1
1
1 0 1 1 0
1
0
1
1 0 0
0
0 1
0
1 0 0 0
1
0 0 0 1 0 0]
[1 0
0
0 0
0
0 0
0
1 0 0 1 0 0
1
0
1
0 0 1
1
0 0 1 0
0
0 0 0 1 0 0
1 0 0
0
0 1 0 0
0 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 1
0
1 0 1 1 0
0
0
0
1 0 0
1
0 1
1
1 0 0 0
0
0 0 0 1 0 0]
>>> print(hist)
[ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 47 1 1]
1 1 1 5 1 1 1 10 1 1 48 1 1 1 1]
"""
if
vprop
is
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment