hyper_wiener_index#
- graph_tool.structure.hyper_wiener_index(g, weights=None)[git][source]#
Return the hyper-Wiener index of the graph.
- Parameters:
- g
Graph Graph to be used. Edge directions are ignored.
- weights
EdgePropertyMap(optional, default:None) Edge weights (lengths).
- g
- Returns:
- WW
float The hyper-Wiener index \(\frac{1}{2}\sum_{u<v}(d_{uv} + d_{uv}^2)\) [randic-novel-1993], or \(\infty\) if the graph is not connected.
- WW
See also
wiener_indexSum of the distances between all pairs
schultz_indexDegree-weighted variant of the Wiener index
gutman_indexDegree-product-weighted variant of the Wiener index
Notes
The hyper-Wiener index [randic-novel-1993] is
\[WW = \frac{1}{2}\sum_{u<v}\left[d(u, v) + d(u, v)^2\right],\]where the sum runs over the unordered pairs of distinct vertices, and \(d(u, v)\) is the length of a shortest path between \(u\) and \(v\), ignoring the edge directions (the number of its edges, or the sum of their weights). If the graph is not connected, \(WW = \infty\). This is the usual definition, with a sum over unordered pairs, for which a path of \(n\) vertices has \(WW = \binom{n+2}{4}\) (see also the Wiener index, computed by
wiener_index()).The distances are computed by a breadth-first search (or Dijkstra’s algorithm, with weights) from every vertex, in time \(O(VE)\) (or \(O(V(E + V)\log V)\)), in parallel.
Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[randic-novel-1993] (1,2)Milan Randić, “Novel molecular descriptor for structure-property studies”, Chemical Physics Letters 211, 478-483 (1993), DOI: 10.1016/0009-2614(93)87094-J [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.hyper_wiener_index(g)) 2545.0