Commit 46d7b30a authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Cosmetic documentation improvements

parent 82b9ccc0
...@@ -471,27 +471,31 @@ def graph_draw(g, pos=None, vprops=None, eprops=None, vorder=None, eorder=None, ...@@ -471,27 +471,31 @@ def graph_draw(g, pos=None, vprops=None, eprops=None, vorder=None, eorder=None,
-------- --------
>>> from numpy import * >>> from numpy import *
>>> from numpy.random import seed, zipf >>> from numpy.random import seed, zipf
>>> seed(42) >>> seed(43)
>>> g = gt.random_graph(1000, lambda: min(zipf(2.4), 40), >>> g = gt.price_network(1500)
... lambda i, j: exp(abs(i - j)), directed=False) >>> deg = g.degree_property_map("in")
>>> # extract largest component >>> deg.a = 4 * (sqrt(deg.a) * 0.5 + 0.4)
>>> g = gt.GraphView(g, vfilt=gt.label_largest_component(g))
>>> deg = g.degree_property_map("out")
>>> deg.a = 2 * (sqrt(deg.a) * 0.5 + 0.4)
>>> ebet = gt.betweenness(g)[1] >>> ebet = gt.betweenness(g)[1]
>>> ebet.a /= ebet.a.max() / 10. >>> ebet.a /= ebet.a.max() / 10.
>>> gt.graph_draw(g, vertex_size=deg, vertex_fill_color=deg, vorder=deg, >>> eorder = ebet.copy()
... edge_color=ebet, eorder=ebet, edge_pen_width=ebet, >>> eorder.a *= -1
>>> pos = gt.sfdp_layout(g)
>>> control = g.new_edge_property("vector<double>")
>>> for e in g.edges():
... d = sqrt(sum((pos[e.source()].a - pos[e.target()].a) ** 2)) / 5
... control[e] = [0.3, d, 0.7, d]
>>> gt.graph_draw(g, pos=pos, vertex_size=deg, vertex_fill_color=deg, vorder=deg,
... edge_color=ebet, eorder=eorder, edge_pen_width=ebet,
... edge_control_points=control, # some curvy edges
... output="graph-draw.pdf") ... output="graph-draw.pdf")
<...> <...>
.. figure:: graph-draw.* .. figure:: graph-draw.*
:align: center :align: center
SFDP force-directed layout of a graph with a power-law degree SFDP force-directed layout of a Price network with 1500 nodes. The
distribution, and dissortative degree correlation. The vertex size and vertex size and color indicate the degree, and the edge color and width
color indicate the degree, and the edge color and width the edge the edge betweeness centrality.
betweeness centrality.
""" """
......
...@@ -256,27 +256,20 @@ def graphviz_draw(g, pos=None, size=(15, 15), pin=False, layout=None, ...@@ -256,27 +256,20 @@ def graphviz_draw(g, pos=None, size=(15, 15), pin=False, layout=None,
>>> from numpy import * >>> from numpy import *
>>> from numpy.random import seed, zipf >>> from numpy.random import seed, zipf
>>> seed(42) >>> seed(42)
>>> g = gt.random_graph(1000, lambda: min(zipf(2.4), 40), >>> g = gt.price_network(1500)
... lambda i, j: exp(abs(i - j)), directed=False) >>> deg = g.degree_property_map("in")
>>> # extract largest component
>>> g = gt.GraphView(g, vfilt=gt.label_largest_component(g))
>>> deg = g.degree_property_map("out")
>>> deg.a = 2 * (sqrt(deg.a) * 0.5 + 0.4) >>> deg.a = 2 * (sqrt(deg.a) * 0.5 + 0.4)
>>> ebet = gt.betweenness(g)[1] >>> ebet = gt.betweenness(g)[1]
>>> ebet.a *= 4000 >>> gt.graphviz_draw(g, vcolor=deg, vorder=deg, elen=10,
>>> ebet.a += 10 ... ecolor=ebet, eorder=ebet, output="graphviz-draw.pdf")
>>> gt.graphviz_draw(g, vsize=deg, vcolor=deg, vorder=deg, elen=10,
... ecolor=ebet, eorder=ebet, penwidth=ebet,
... overlap="prism", output="graphviz-draw.pdf")
<...> <...>
.. figure:: graphviz-draw.* .. figure:: graphviz-draw.*
:align: center :align: center
Kamada-Kawai force-directed layout of a graph with a power-law degree Kamada-Kawai force-directed layout of a Price network with 1500
distribution, and dissortative degree correlation. The vertex size and nodes. The vertex size and color indicate the degree, and the edge color
color indicate the degree, and the edge color and width the edge corresponds to the edge betweeness centrality
betweeness centrality.
References References
---------- ----------
......
...@@ -1295,7 +1295,7 @@ def edge_reciprocity(g): ...@@ -1295,7 +1295,7 @@ def edge_reciprocity(g):
---------- ----------
.. [reciprocity] S. Wasserman and K. Faust, "Social Network Analysis". .. [reciprocity] S. Wasserman and K. Faust, "Social Network Analysis".
(Cambridge University Press, Cambridge, 1994) (Cambridge University Press, Cambridge, 1994)
.. [lopez_reciprocity_2007] Gorka Zamora-López, Vinko Zlatić, Changsong Zhou, Hrvoje Štefančić, and Jürgen Kurths .. [lopez-reciprocity-2007] Gorka Zamora-López, Vinko Zlatić, Changsong Zhou, Hrvoje Štefančić, and Jürgen Kurths
"Reciprocity of networks with degree correlations and arbitrary degree sequences", Phys. Rev. E 77, 016106 (2008) "Reciprocity of networks with degree correlations and arbitrary degree sequences", Phys. Rev. E 77, 016106 (2008)
:doi:`10.1103/PhysRevE.77.016106`, :arxiv:`0706.3372` :doi:`10.1103/PhysRevE.77.016106`, :arxiv:`0706.3372`
......
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