Commit 3512df30 authored by Tiago Peixoto's avatar Tiago Peixoto

Documentation improvements and fixes

parent 9d71c105
......@@ -184,8 +184,8 @@ intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
'ipython': ('https://ipython.org/ipython-doc/stable/', None),
'panda': ('https://pandas.pydata.org/pandas-docs/stable/', None)}
extlinks_fancy = {'ticket': (['https://graph-tool.skewed.de/tickets/ticket/{0}'],
['ticket {0}']),
extlinks_fancy = {'issue': (['https://git.skewed.de/count0/graph-tool/issues/{0}'],
['issue #{0}']),
'doi': (['https://dx.doi.org/{0}',
'https://sci-hub.tw/{0}',
'https://scihub22266oqcxt.onion.link/{0}'],
......
......@@ -219,8 +219,8 @@ approach for the same network, using the nested model.
.. testoutput:: model-evidence
Model evidence for deg_corr = True: -555.768070... (mean field), -731.501041... (Bethe)
Model evidence for deg_corr = False: -544.346500... (mean field), -630.951518... (Bethe)
Model evidence for deg_corr = True: -523.722360... (mean field), -686.592569... (Bethe)
Model evidence for deg_corr = False: -516.006708... (mean field), -619.110456... (Bethe)
The results are similar: If we consider the most accurate approximation,
the non-degree-corrected model possesses the largest evidence. Note also
......
......@@ -21,7 +21,7 @@ We set up the classification task by dividing the edges/non-edges into
two sets :math:`\boldsymbol A` and :math:`\delta \boldsymbol A`, where
the former corresponds to the observed network and the latter either to
the missing or spurious edges. We may compute the posterior of
:math:`\delta \boldsymbol A` as [valles-catala-consistency-2017]_
:math:`\delta \boldsymbol A` as [valles-catala-consistencies-2018]_
.. math::
:label: posterior-missing
......
......@@ -5,11 +5,12 @@ An important application of generative models is to be able to
generalize from observations and make predictions that go beyond what is
seen in the data. This is particularly useful when the network we
observe is incomplete, or contains errors, i.e. some of the edges are
either missing or are outcomes of mistakes in measurement. In this
situation, we can use statistical inference to reconstruct the original
network. Following [peixoto-reconstructing-2018]_, if
:math:`\boldsymbol{\mathcal{D}}` is the observed data, the network can
be reconstructed according to the posterior distribution,
either missing or are outcomes of mistakes in measurement, or is not
even observed at all. In this situation, we can use statistical
inference to reconstruct the original network. Following
[peixoto-reconstructing-2018]_, if :math:`\boldsymbol{\mathcal{D}}` is
the observed data, the network can be reconstructed according to the
posterior distribution,
.. math::
......@@ -55,7 +56,7 @@ information and the uncertainty in the measurement data. Furthermore,
the use of the SBM means that the reconstruction can take advantage of
the *correlations* observed in the data to further inform it, which
generally can lead to substantial improvements
[peixoto-reconstructing-2018]_.
[peixoto-reconstructing-2018]_ [peixoto-network-2019]_.
In graph-tool there is support for reconstruction with the above
framework for three measurement processes: 1. Repeated measurements with
......@@ -67,6 +68,9 @@ and 3. Extraneously obtained edge probabilities (via
:class:`~graph_tool.inference.uncertain_blockmodel.UncertainBlockState`),
which we describe in the following.
In addition, it is also possible to reconstruct networks from observed
dynamical, as described in :ref:`reconstruction_dynamics`.
Measured networks
+++++++++++++++++
......@@ -185,9 +189,9 @@ Which yields the following output:
.. testoutput:: measured
Posterior probability of edge (11, 36): 0.841384...
Posterior probability of non-edge (15, 73): 0.100010...
Estimated average local clustering: 0.571836 ± 0.005152...
Posterior probability of edge (11, 36): 0.890889...
Posterior probability of non-edge (15, 73): 0.056005...
Estimated average local clustering: 0.572758 ± 0.003998...
We have a successful reconstruction, where both ambiguous adjacency
matrix entries are correctly recovered. The value for the average
......@@ -306,9 +310,9 @@ Which yields:
.. testoutput:: measured
Posterior probability of edge (11, 36): 0.593359...
Posterior probability of non-edge (15, 73): 0.050705...
Estimated average local clustering: 0.570958 ± 0.006660...
Posterior probability of edge (11, 36): 0.515651...
Posterior probability of non-edge (15, 73): 0.009000...
Estimated average local clustering: 0.571673 ± 0.003228...
The results are very similar to the ones obtained with the uniform model
in this case, but can be quite different in situations where a large
......@@ -434,9 +438,9 @@ The above yields the output:
.. testoutput:: uncertain
Posterior probability of edge (11, 36): 0.948894...
Posterior probability of non-edge (15, 73): 0.049004...
Estimated average local clustering: 0.552446 ± 0.019751...
Posterior probability of edge (11, 36): 0.951195...
Posterior probability of non-edge (15, 73): 0.020702...
Estimated average local clustering: 0.538731 ± 0.017645...
The reconstruction is accurate, despite the two ambiguous entries having
the same measurement probability. The reconstructed network is visualized below.
......@@ -480,3 +484,5 @@ the same measurement probability. The reconstructed network is visualized below.
ambiguity, both errors are successfully corrected by the
reconstruction. The pie fractions on the nodes correspond to the
probability of being in group associated with the respective color.
.. include:: _reconstruction_dynamics.rst
.. _reconstruction_dynamics:
Reconstruction from dynamics
++++++++++++++++++++++++++++
.. testsetup:: dynamics
import os
try:
os.chdir("demos/inference")
except FileNotFoundError:
pass
np.random.seed(42)
gt.seed_rng(44)
.. testcode:: dynamics
g = gt.collection.data["dolphins"]
ss = []
for i in range(1000):
si_state = gt.SIState(g, beta=1)
s = []
for j in range(10):
si_state.iterate_sync()
s.append(si_state.get_state().copy())
s = gt.group_vector_property(s)
ss.append(s)
u = g.copy()
u.clear_edges()
ss = [u.own_property(s) for s in ss]
rstate = gt.EpidemicsBlockState(u, s=ss, beta=None, r=1e-6, global_beta=.99,
state_args=dict(B=1), nested=False)
# Now we collect the marginals for exactly 100,000 sweeps, at
# intervals of 10 sweeps:
gm = None
bm = None
def collect_marginals(s):
global gm, bm
gm = s.collect_marginal(gm)
b = gt.perfect_prop_hash([s.bstate.b])[0]
bm = s.bstate.collect_vertex_marginals(bm, b=b)
gt.mcmc_equilibrate(rstate, force_niter=10000, mcmc_args=dict(niter=10, xstep=0, p=0, h=0),
callback=collect_marginals)
b = bm.new_vp("int", vals=[bm[v].a.argmax() for v in bm.vertices()])
graph_draw(gm, gm.own_property(g.vp.pos), vertex_shape="square", vertex_color="black",
vertex_fill_color=b, vertex_pen_width=1,
edge_pen_width=prop_to_size(gm.ep.eprob, 0, 5), eorder=gm.ep.eprob, output="dolphins")
eprob = u.ep.eprob
print("Posterior probability of edge (11, 36):", eprob[u.edge(11, 36)])
print("Posterior probability of non-edge (15, 73):", eprob[u.edge(15, 73)])
print("Estimated average local clustering: %g ± %g" % (np.mean(cs), np.std(cs)))
......@@ -275,8 +275,8 @@ network as above.
.. testoutput:: nested-model-averaging
Change in description length: 20.223115...
Number of accepted vertex moves: 58320
Change in description length: 15.483135...
Number of accepted vertex moves: 57684
Similarly to the the non-nested case, we can use
:func:`~graph_tool.inference.mcmc.mcmc_equilibrate` to do most of the boring
......
......@@ -73,7 +73,11 @@ References
:arxiv:`1310.4378`
.. [peixoto-reconstructing-2018] Tiago P. Peixoto, "Reconstructing
networks with unknown and heterogeneous errors", :arxiv:`1806.07956`
networks with unknown and heterogeneous errors", Phys. Rev. X 8
041011 (2018). :doi:`10.1103/PhysRevX.8.041011`, :arxiv:`1806.07956`
.. [peixoto-network-2019] Tiago P. Peixoto, "Network reconstruction and
community detection from dynamics", :arxiv:`1903.10833`
.. [martin-structural-2015] Travis Martin, Brian Ball, M. E. J. Newman,
"Structural inference for uncertain networks", Phys. Rev. E 93,
......@@ -88,13 +92,15 @@ References
spurious interactions and the reconstruction of complex networks", PNAS
vol. 106 no. 52 (2009). :doi:`10.1073/pnas.0908366106`
.. [valles-catala-consistency-2017] Toni Vallès-Català,
Tiago P. Peixoto, Roger Guimerà, Marta Sales-Pardo, "On the consistency
between model selection and link prediction in networks". :arxiv:`1705.07967`
.. [valles-catala-consistencies-2018] Toni Vallès-Català,
Tiago P. Peixoto, Roger Guimerà, Marta Sales-Pardo, "Consistencies
and inconsistencies between model selection and link prediction in
networks", Phys. Rev. E 97 062316 (2018),
:doi:`10.1103/PhysRevE.97.062316`, :arxiv:`1705.07967`
.. [mezard-information-2009] Marc Mézard, Andrea Montanari, "Information,
Physics, and Computation", Oxford Univ Press (2009).
:DOI:`10.1093/acprof:oso/9780198570837.001.0001`
:doi:`10.1093/acprof:oso/9780198570837.001.0001`
.. [guimera-modularity-2004] Roger Guimerà, Marta Sales-Pardo, and
Luís A. Nunes Amaral, "Modularity from fluctuations in random graphs
......
.. automodule:: graph_tool.draw
:no-members:
.. container:: sec_title
Layout algorithms
.. autofunction:: sfdp_layout
.. autofunction:: fruchterman_reingold_layout
.. autofunction:: arf_layout
.. autofunction:: radial_tree_layout
.. autofunction:: planar_layout
.. autofunction:: random_layout
.. container:: sec_title
Graph drawing
.. autofunction:: graph_draw
.. autofunction:: draw_hierarchy
.. autofunction:: graphviz_draw
.. autofunction:: prop_to_size
.. autofunction:: get_hierarchy_control_points
.. container:: sec_title
Low-level graph drawing
.. autofunction:: cairo_draw
.. autofunction:: interactive_window
.. autoclass:: GraphWidget
:show-inheritance:
:members:
:undoc-members:
.. autoclass:: GraphWindow
:show-inheritance:
:members:
:undoc-members:
......@@ -392,13 +392,13 @@ ol.arabic li dl dt {
background-color: inherit;
}
.brackets:before {
content: "[";
}
/* .brackets:before { */
/* content: "["; */
/* } */
.brackets:after {
content: "]";
}
/* .brackets:after { */
/* content: "]"; */
/* } */
.fn-backref {
margin-right: 10px;
......
......@@ -47,6 +47,7 @@ import numpy as np
from pylab import *
from numpy import *
import graph_tool.all as gt
import graph_tool.draw
import random as prandom
figure()
......
......@@ -289,6 +289,24 @@ methods should be used:
for e in g.edges():
print(e)
.. testoutput::
:hide:
0
1
2
3
4
5
6
7
8
9
10
11
(0, 1)
(2, 3)
The code above will print the vertices and edges of the graph in the order they
are found.
......@@ -302,7 +320,6 @@ and :meth:`~graph_tool.Vertex.in_neighbors` methods, respectively.
.. testcode::
from itertools import izip
for v in g.vertices():
for e in v.out_edges():
print(e)
......@@ -310,9 +327,17 @@ and :meth:`~graph_tool.Vertex.in_neighbors` methods, respectively.
print(w)
# the edge and neighbors order always match
for e, w in izip(v.out_edges(), v.out_neighbors()):
for e, w in zip(v.out_edges(), v.out_neighbors()):
assert e.target() == w
.. testoutput::
:hide:
(0, 1)
1
(2, 3)
3
The code above will print the out-edges and out-neighbors of all
vertices in the graph.
......@@ -352,7 +377,7 @@ For example, using this interface we can get the out-degree of each node via:
.. testoutput::
[1 0 1 0 0 0 0 0 0 0 0 0]
[0 1 0 1 0 0 0 0 0 0 0 0]
or the sum of the product of the in and out-degrees of the endpoints of
each edge with:
......@@ -415,14 +440,13 @@ such:
.. testcode::
from itertools import izip
from numpy.random import randint
g = Graph()
g.add_vertex(100)
# insert some random links
for s,t in izip(randint(0, 100, 100), randint(0, 100, 100)):
for s,t in zip(randint(0, 100, 100), randint(0, 100, 100)):
g.add_edge(g.vertex(s), g.vertex(t))
vprop_double = g.new_vertex_property("double") # Double-precision floating point
......
......@@ -1193,7 +1193,7 @@ def infect_vertex_property(g, prop, vals=None):
Parameters
----------
prop : :class:`~graph_tool.PropertyMap`
prop : :class:`~graph_tool.VertexPropertyMap`
Property map to be modified.
vals : list (optional, default: `None`)
List of values to be propagated. If not provided, all values
......@@ -1225,17 +1225,17 @@ def edge_endpoint_property(g, prop, endpoint, eprop=None):
Parameters
----------
prop : :class:`~graph_tool.PropertyMap`
prop : :class:`~graph_tool.VertexPropertyMap`
Vertex property map to be used to propagated to the edge.
endpoint : `"source"` or `"target"`
Edge endpoint considered. If the graph is undirected, the source is
always the vertex with the lowest index.
eprop : :class:`~graph_tool.PropertyMap` (optional, default: `None`)
eprop : :class:`~graph_tool.EdgePropertyMap` (optional, default: `None`)
If provided, the resulting edge properties will be stored here.
Returns
-------
eprop : :class:`~graph_tool.PropertyMap`
eprop : :class:`~graph_tool.EdgePropertyMap`
Propagated edge property.
Examples
......@@ -1283,14 +1283,14 @@ def incident_edges_op(g, direction, op, eprop, vprop=None):
Direction of the incident edges.
op : `"sum"`, `"prod"`, `"min"` or `"max"`
Operation performed on incident edges.
eprop : :class:`~graph_tool.PropertyMap`
eprop : :class:`~graph_tool.EdgePropertyMap`
Edge property map to be summed.
vprop : :class:`~graph_tool.PropertyMap` (optional, default: `None`)
vprop : :class:`~graph_tool.VertexPropertyMap` (optional, default: `None`)
If provided, the resulting vertex properties will be stored here.
Returns
-------
vprop : :class:`~graph_tool.PropertyMap`
vprop : :class:`~graph_tool.VertexPropertyMap`
Resulting vertex property.
Examples
......@@ -1581,7 +1581,7 @@ class Graph(object):
filters, respectively.
If ``vorder`` is specified, it should correspond to a vertex
:class:`~graph_tool.PropertyMap` specifying the ordering of the vertices in
:class:`~graph_tool.VertexPropertyMap` specifying the ordering of the vertices in
the copied graph.
The graph is implemented as an `adjacency list`_, where both vertex and edge
......@@ -1842,7 +1842,7 @@ class Graph(object):
>>> g.add_vertex(5)
<...>
>>> g.get_vertices()
array([0, 1, 2, 3, 4], dtype=uint64)
array([0, 1, 2, 3, 4])
"""
vertices = libcore.get_vertex_list(self.__graph, 0,
......@@ -1949,9 +1949,9 @@ class Graph(object):
--------
>>> g = gt.random_graph(6, lambda: 1, directed=False)
>>> g.get_edges([g.edge_index])
array([[2, 1, 2],
[3, 4, 0],
[5, 0, 1]])
array([[0, 3, 2],
[1, 4, 1],
[2, 5, 0]])
"""
edges = libcore.get_edge_list(self.__graph, 0,
[ep._get_any() for ep in eprops])
......@@ -2038,8 +2038,7 @@ class Graph(object):
>>> g.get_in_edges(66, [g.edge_index])
array([[ 8687, 66, 179681],
[ 20369, 66, 255033],
[ 38674, 66, 300230]], dtype=uint64)
[ 38674, 66, 300230]])
"""
edges = libcore.get_in_edge_list(self.__graph, int(v),
[ep._get_any() for ep in eprops])
......@@ -2082,7 +2081,7 @@ class Graph(object):
>>> g.get_all_edges(66, [g.edge_index])
array([[ 8687, 66, 179681],
[ 20369, 66, 255033],
[ 38674, 66, 300230]], dtype=uint64)
[ 38674, 66, 300230]])
"""
edges = libcore.get_all_edge_list(self.__graph, int(v),
......@@ -2126,7 +2125,7 @@ class Graph(object):
--------
>>> g = gt.collection.data["pgp-strong-2009"]
>>> g.get_out_neighbors(66)
array([ 63, 20369, 13980, 8687, 38674], dtype=uint64)
array([ 63, 20369, 13980, 8687, 38674])
"""
vertices = libcore.get_out_neighbors_list(self.__graph, int(v),
......@@ -2175,7 +2174,7 @@ class Graph(object):
--------
>>> g = gt.collection.data["pgp-strong-2009"]
>>> g.get_in_neighbors(66)
array([ 8687, 20369, 38674], dtype=uint64)
array([ 8687, 20369, 38674])
"""
vertices = libcore.get_in_neighbors_list(self.__graph, int(v),
......@@ -2224,7 +2223,7 @@ class Graph(object):
--------
>>> g = gt.collection.data["pgp-strong-2009"]
>>> g.get_all_neighbors(66)
array([ 8687, 20369, 38674], dtype=uint64)
array([ 8687, 20369, 38674])
"""
vertices = libcore.get_all_neighbors_list(self.__graph, int(v),
......@@ -2240,13 +2239,13 @@ class Graph(object):
def get_out_degrees(self, vs, eweight=None):
"""Return a :class:`numpy.ndarray` containing the out-degrees of vertex list
``vs``. If supplied, the degrees will be weighted according to the edge
:class:`~graph_tool.PropertyMap` ``eweight``.
:class:`~graph_tool.EdgePropertyMap` ``eweight``.
Examples
--------
>>> g = gt.collection.data["pgp-strong-2009"]
>>> g.get_out_degrees([42, 666])
array([20, 38], dtype=uint64)
array([20, 38])
"""
return libcore.get_degree_list(self.__graph,
......@@ -2256,13 +2255,13 @@ class Graph(object):
def get_in_degrees(self, vs, eweight=None):
"""Return a :class:`numpy.ndarray` containing the in-degrees of vertex list
``vs``. If supplied, the degrees will be weighted according to the edge
:class:`~graph_tool.PropertyMap` ``eweight``.
:class:`~graph_tool.EdgePropertyMap` ``eweight``.
Examples
--------
>>> g = gt.collection.data["pgp-strong-2009"]
>>> g.get_in_degrees([42, 666])
array([20, 39], dtype=uint64)
array([20, 39])
"""
return libcore.get_degree_list(self.__graph,
......@@ -2571,7 +2570,7 @@ class Graph(object):
.. note::
Like :attr:`~graph_tool.Graph.edge_index`, this
is a special instance of a :class:`~graph_tool.PropertyMap`
is a special instance of a :class:`~graph_tool.VertexPropertyMap`
class, which is **immutable**, and cannot be
accessed as an array.""")
......@@ -2585,7 +2584,7 @@ class Graph(object):
.. note::
Like :attr:`~graph_tool.Graph.vertex_index`, this
is a special instance of a :class:`~graph_tool.PropertyMap`
is a special instance of a :class:`~graph_tool.EdgePropertyMap`
class, which is **immutable**, and cannot be
accessed as an array.
......@@ -2770,7 +2769,7 @@ class Graph(object):
def degree_property_map(self, deg, weight=None):
"""Create and return a vertex property map containing the degree type
given by ``deg``, which can be any of ``"in"``, ``"out"``, or ``"total"``.
If provided, ``weight`` should be an edge :class:`~graph_tool.PropertyMap`
If provided, ``weight`` should be an edge :class:`~graph_tool.EdgePropertyMap`
containing the edge weights which should be summed."""
pmap = self.__graph.degree_map(_to_str(deg), _prop("e", self, weight))
return VertexPropertyMap(pmap, self)
......@@ -3556,7 +3555,7 @@ def _all_neighbors(self):
def _in_degree(self, weight=None):
"""Return the in-degree of the vertex. If provided, ``weight`` should be a
scalar edge :class:`~graph_tool.PropertyMap`, and the in-degree will
scalar edge :class:`~graph_tool.EdgePropertyMap`, and the in-degree will
correspond to the sum of the weights of the in-edges.
"""
......@@ -3567,7 +3566,7 @@ def _in_degree(self, weight=None):
def _out_degree(self, weight=None):
"""Return the out-degree of the vertex. If provided, ``weight`` should be a
scalar edge :class:`~graph_tool.PropertyMap`, and the out-degree will
scalar edge :class:`~graph_tool.EdgePropertyMap`, and the out-degree will
correspond to the sum of the weights of the out-edges.
"""
......
......@@ -69,12 +69,12 @@ def pagerank(g, damping=0.85, pers=None, weight=None, prop=None, epsilon=1e-6,
Graph to be used.
damping : float, optional (default: 0.85)
Damping factor.
pers : :class:`~graph_tool.PropertyMap`, optional (default: None)
pers : :class:`~graph_tool.VertexPropertyMap`, optional (default: None)
Personalization vector. If omitted, a constant value of :math:`1/N`
will be used.
weight : :class:`~graph_tool.PropertyMap`, optional (default: None)
weight : :class:`~graph_tool.EdgePropertyMap`, optional (default: None)
Edge weights. If omitted, a constant value of 1 will be used.
prop : :class:`~graph_tool.PropertyMap`, optional (default: None)
prop : :class:`~graph_tool.VertexPropertyMap`, optional (default: None)
Vertex property map to store the PageRank values. If supplied, it will
be used uninitialized.
epsilon : float, optional (default: 1e-6)
......@@ -87,7 +87,7 @@ def pagerank(g, damping=0.85, pers=None, weight=None, prop=None, epsilon=1e-6,
Returns
-------
pagerank : :class:`~graph_tool.PropertyMap`
pagerank : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the PageRank values.
See Also
......@@ -243,11 +243,11 @@ def betweenness(g, pivots=None, vprop=None, eprop=None, weight=None, norm=True):
this list as pivots. If the list contains all nodes (the default) the
algorithm will be exact, and if the vertices are randomly chosen the
result will be an unbiased estimator.
vprop : :class:`~graph_tool.PropertyMap`, optional (default: None)
vprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: None)
Vertex property map to store the vertex betweenness values.
eprop : :class:`~graph_tool.PropertyMap`, optional (default: None)
eprop : :class:`~graph_tool.EdgePropertyMap`, optional (default: None)
Edge property map to store the edge betweenness values.
weight : :class:`~graph_tool.PropertyMap`, optional (default: None)
weight : :class:`~graph_tool.EdgePropertyMap`, optional (default: None)
Edge property map corresponding to the weight value of each edge.
norm : bool, optional (default: True)
Whether or not the betweenness values should be normalized.
......@@ -365,11 +365,11 @@ def closeness(g, weight=None, source=None, vprop=None, norm=True, harmonic=False
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
weight : :class:`~graph_tool.PropertyMap`, optional (default: None)
weight : :class:`~graph_tool.EdgePropertyMap`, optional (default: None)
Edge property map corresponding to the weight value of each edge.
source : :class:`~graph_tool.Vertex`, optional (default: ``None``)
If specified, the centrality is computed for this vertex alone.
vprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
vprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map to store the vertex centrality values.
norm : bool, optional (default: ``True``)
Whether or not the centrality values should be normalized.
......@@ -379,7 +379,7 @@ def closeness(g, weight=None, source=None, vprop=None, norm=True, harmonic=False
Returns
-------
vertex_closeness : :class:`~graph_tool.PropertyMap`
vertex_closeness : :class:`~graph_tool.VertexPropertyMap`
A vertex property map with the vertex closeness values.
See Also
......@@ -491,15 +491,14 @@ def closeness(g, weight=None, source=None, vprop=None, norm=True, harmonic=False
def central_point_dominance(g, betweenness):
r"""
Calculate the central point dominance of the graph, given the betweenness
r"""Calculate the central point dominance of the graph, given the betweenness
centrality of each vertex.
Parameters
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
betweenness : :class:`~graph_tool.PropertyMap`
betweenness : :class:`~graph_tool.VertexPropertyMap`
Vertex property map with the betweenness centrality values. The values
must be normalized.
......@@ -540,7 +539,7 @@ def central_point_dominance(g, betweenness):
----------
.. [freeman-set-1977] Linton C. Freeman, "A Set of Measures of Centrality
Based on Betweenness", Sociometry, Vol. 40, No. 1, pp. 35-41, 1977,
`http://www.jstor.org/stable/3033543 <http://www.jstor.org/stable/3033543>`_
:doi:`10.2307/3033543`
"""
return libgraph_tool_centrality.\
......@@ -557,9 +556,9 @@ def eigenvector(g, weight=None, vprop=None, epsilon=1e-6, max_iter=None):
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
weight : :class:`~graph_tool.PropertyMap` (optional, default: ``None``)
weight : :class:`~graph_tool.EdgePropertyMap` (optional, default: ``None``)
Edge property map with the edge weights.
vprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
vprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the values of eigenvector must be stored. If
provided, it will be used uninitialized.
epsilon : float, optional (default: ``1e-6``)
......@@ -572,7 +571,7 @@ def eigenvector(g, weight=None, vprop=None, epsilon=1e-6, max_iter=None):
-------
eigenvalue : float
The largest eigenvalue of the (weighted) adjacency matrix.
eigenvector : :class:`~graph_tool.PropertyMap`
eigenvector : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the eigenvector values.
See Also
......@@ -677,15 +676,15 @@ def katz(g, alpha=0.01, beta=None, weight=None, vprop=None, epsilon=1e-6,
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
weight : :class:`~graph_tool.PropertyMap` (optional, default: ``None``)
weight : :class:`~graph_tool.EdgePropertyMap` (optional, default: ``None``)
Edge property map with the edge weights.
alpha : float, optional (default: ``0.01``)
Free parameter :math:`\alpha`. This must be smaller than the inverse of
the largest eigenvalue of the adjacency matrix.
beta : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
beta : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the local personalization values. If not
provided, the global value of 1 will be used.
vprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
vprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the values of eigenvector must be stored. If
provided, it will be used uninitialized.
epsilon : float, optional (default: ``1e-6``)
......@@ -698,7 +697,7 @@ def katz(g, alpha=0.01, beta=None, weight=None, vprop=None, epsilon=1e-6,
Returns
-------
centrality : :class:`~graph_tool.PropertyMap`
centrality : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the Katz centrality values.
See Also
......@@ -795,11 +794,11 @@ def hits(g, weight=None, xprop=None, yprop=None, epsilon=1e-6, max_iter=None):
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
weight : :class:`~graph_tool.PropertyMap` (optional, default: ``None``)
weight : :class:`~graph_tool.EdgePropertyMap` (optional, default: ``None``)
Edge property map with the edge weights.
xprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
xprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the authority centrality must be stored.
yprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
yprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the hub centrality must be stored.
epsilon : float, optional (default: ``1e-6``)
Convergence condition. The iteration will stop if the total delta of all
......@@ -811,9 +810,9 @@ def hits(g, weight=None, xprop=None, yprop=None, epsilon=1e-6, max_iter=None):
-------
eig : `float`
The largest eigenvalue of the cocitation matrix.
x : :class:`~graph_tool.PropertyMap`
x : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the authority centrality values.
y : :class:`~graph_tool.PropertyMap`
y : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the hub centrality values.
See Also
......@@ -932,10 +931,10 @@ def eigentrust(g, trust_map, vprop=None, norm=False, epsilon=1e-6, max_iter=0,
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
trust_map : :class:`~graph_tool.PropertyMap`
trust_map : :class:`~graph_tool.EdgePropertyMap`
Edge property map with the values of trust associated with each
edge. The values must lie in the range [0,1].
vprop : :class:`~graph_tool.PropertyMap`, optional (default: ``None``)
vprop : :class:`~graph_tool.VertexPropertyMap`, optional (default: ``None``)
Vertex property map where the values of eigentrust must be stored.
norm : bool, optional (default: ``False``)
Norm eigentrust values so that the total sum equals 1.
......@@ -949,7 +948,7 @@ def eigentrust(g, trust_map, vprop=None, norm=False, epsilon=1e-6, max_iter=0,
Returns
-------
eigentrust : :class:`~graph_tool.PropertyMap`
eigentrust : :class:`~graph_tool.VertexPropertyMap`
A vertex property map containing the eigentrust values.
See Also
......@@ -1049,7 +1048,7 @@ def trust_transitivity(g, trust_map, source=None, target=None, vprop=None):
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
trust_map : :class:`~graph_tool.PropertyMap`
trust_map : :class:`~graph_tool.EdgePropertyMap`
Edge property map with the values of trust associated with each
edge. The values must lie in the range [0,1].
source : :class:`~graph_tool.Vertex` (optional, default: None)
......@@ -1058,13 +1057,13 @@ def trust_transitivity(g, trust_map, source=None, target=None, vprop=None):
target : :class:`~graph_tool.Vertex` (optional, default: None)
The only target for which the trust value will be calculated. If left
unspecified, the trust values for all targets are computed.
vprop : :class:`~graph_tool.PropertyMap` (optional, default: None)
vprop : :class:`~graph_tool.VertexPropertyMap` (optional, default: None)
A vertex property map where the values of transitive trust must be