hyper_wiener_index#
- hyper_wiener_index(G, weight=None)[source]#
Returns the Hyper-Wiener index of the graph
G
.The Hyper-Wiener index of a connected graph
G
is defined as\[WW(G) = \frac{1}{2} \sum_{u,v \in V(G)} (d(u,v) + d(u,v)^2)\]where
d(u, v)
is the shortest-path distance between nodesu
andv
.- Parameters:
- GNetworkX graph
An undirected, connected graph.
- weightstring or None, optional (default: None)
The edge attribute to use for calculating shortest-path distances. If None, all edges are considered to have a weight of 1.
- Returns:
- float
The Hyper-Wiener index of the graph G. Returns float(“inf”) if the graph is not connected.
References
[1]M. Randić, “Novel molecular descriptor for structure-property studies,” Chemical Physics Letters, vol. 211, pp. 478-483, 1993.
Examples
>>> G = nx.path_graph(4) >>> nx.hyper_wiener_index(G) 30.0
>>> G = nx.cycle_graph(4) >>> nx.hyper_wiener_index(G) 20.0