Skip to content

Commit e2ccb1f

Browse files
authored
Merge pull request #726 from xgi-org/stats-docstring-deduplication
docs: deduplicate stats docstrings and link to algorithms (#621)
2 parents 23afad9 + 61603ec commit e2ccb1f

4 files changed

Lines changed: 127 additions & 206 deletions

File tree

xgi/algorithms/centrality.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def clique_eigenvector_centrality(H, tol=1e-6):
3939
Centrality, where keys are node IDs and values are centralities. The
4040
centralities are 1-normalized.
4141
42+
Notes
43+
-----
44+
Also accessible via the stats interface as
45+
``H.nodes.clique_eigenvector_centrality``.
46+
4247
See Also
4348
--------
4449
h_eigenvector_centrality
@@ -115,6 +120,9 @@ def node_edge_centrality(
115120
general functions for both nodes and edges, nodes and edges may be weighted,
116121
and one can choose different norms for normalization.
117122
123+
Also accessible via the stats interface: ``H.nodes.node_edge_centrality`` for the
124+
node component and ``H.edges.node_edge_centrality`` for the edge component.
125+
118126
References
119127
----------
120128
Node and edge nonlinear eigenvector centrality for hypergraphs,
@@ -271,6 +279,8 @@ def katz_centrality(H, cutoff=100):
271279
[2] The Katz-centrality of isolated nodes (no hyperedges contains them) is
272280
zero. The Katz-centrality of an empty hypergraph is not defined.
273281
282+
Also accessible via the stats interface as ``H.nodes.katz_centrality``.
283+
274284
References
275285
----------
276286
See https://en.wikipedia.org/wiki/Katz_centrality#Alpha_centrality (visited
@@ -320,6 +330,10 @@ def h_eigenvector_centrality(H, max_iter=100, tol=1e-6, seed=None):
320330
Centrality, where keys are node IDs and values are centralities. The
321331
centralities are 1-normalized.
322332
333+
Notes
334+
-----
335+
Also accessible via the stats interface as ``H.nodes.h_eigenvector_centrality``.
336+
323337
See Also
324338
--------
325339
clique_eigenvector_centrality
@@ -409,6 +423,10 @@ def z_eigenvector_centrality(H, max_iter=100, tol=1e-6):
409423
XGIError
410424
If the hypergraph is not uniform.
411425
426+
Notes
427+
-----
428+
Also accessible via the stats interface as ``H.nodes.z_eigenvector_centrality``.
429+
412430
See Also
413431
--------
414432
clique_eigenvector_centrality

xgi/algorithms/clustering.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def clustering_coefficient(H):
4242
to 0 in these cases. For more discussion, see
4343
https://arxiv.org/abs/0802.2512
4444
45+
Also accessible via the stats interface as ``H.nodes.clustering_coefficient``.
46+
4547
See Also
4648
--------
4749
local_clustering_coefficient
@@ -99,6 +101,9 @@ def local_clustering_coefficient(H):
99101
to 0 in these cases. For more discussion, see
100102
https://arxiv.org/abs/0802.2512
101103
104+
Also accessible via the stats interface as
105+
``H.nodes.local_clustering_coefficient``.
106+
102107
See Also
103108
--------
104109
clustering_coefficient
@@ -191,6 +196,9 @@ def two_node_clustering_coefficient(H, kind="union"):
191196
to 0 in these cases. For more discussion, see
192197
https://arxiv.org/abs/0802.2512
193198
199+
Also accessible via the stats interface as
200+
``H.nodes.two_node_clustering_coefficient``.
201+
194202
See Also
195203
--------
196204
clustering_coefficient

xgi/stats/edgestats.py

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -191,51 +191,27 @@ def node_edge_centrality(
191191
max_iter=100,
192192
tol=1e-6,
193193
):
194-
"""Computes edge centralities.
194+
"""Edge component of the nonlinear node-edge centrality.
195+
196+
See :func:`xgi.algorithms.centrality.node_edge_centrality` for the definition,
197+
parameters, and references.
195198
196199
Parameters
197200
----------
198201
net : Hypergraph
199-
The hypergraph of interest
202+
The hypergraph of interest.
200203
bunch : Iterable
201-
Edges in `net`
202-
f : lambda function, default: x^2
203-
The function f as described in Tudisco and Higham.
204-
Must accept a numpy array.
205-
g : lambda function, default: x^0.5
206-
The function g as described in Tudisco and Higham.
207-
Must accept a numpy array.
208-
phi : lambda function, default: x^2
209-
The function phi as described in Tudisco and Higham.
210-
Must accept a numpy array.
211-
psi : lambda function, default: x^0.5
212-
The function psi as described in Tudisco and Higham.
213-
Must accept a numpy array.
214-
max_iter : int, default: 100
215-
Number of iterations at which the algorithm terminates
216-
if convergence is not reached.
217-
tol : float > 0, default: 1e-6
218-
The total allowable error in the node and edge centralities.
204+
Edges in `net`.
219205
220206
Returns
221207
-------
222-
dict, dict
223-
The edge centrality where keys are the edge IDs and values are
224-
associated centralities.
225-
226-
Notes
227-
-----
228-
In the paper from which this was taken, it is more general in that it includes
229-
general functions for both nodes and edges, nodes and edges may be weighted,
230-
and one can choose different norms for normalization.
208+
dict
209+
Edge centralities.
231210
232-
This method does not output the node centralities even though they are computed.
211+
See Also
212+
--------
213+
~xgi.algorithms.centrality.node_edge_centrality
233214
234-
References
235-
----------
236-
Node and edge nonlinear eigenvector centrality for hypergraphs,
237-
Francesco Tudisco & Desmond J. Higham,
238-
https://doi.org/10.1038/s42005-021-00704-2
239215
"""
240216
_, c = xgi.node_edge_centrality(net, f, g, phi, psi, max_iter, tol)
241217
return {e: c[e] for e in c if e in bunch}

0 commit comments

Comments
 (0)