定义:A scientist has index \(h\) if \(h\) of his or her \(N_p\) papers have at least citations each and the other \((N_p - h)\) papers have citations each.
H指数的计算基于其研究者的论文数量及其论文被引用的次数。赫希认为:一个人在其所有学术文章中有 N 篇论文分别被引用了至少N 次,他的 H 指数就是N [2]。
LeeCode [3] 中给出的描述是这样的:给定一位研究者论文被引用次数的数组(被引用次数是非负整数)。编写一个方法,计算出研究者的 h 指数。
参考代码:
class Solution:
def hIndex(self, citations: List[int]) -> int:
hi = 0
sc = sorted(citations, reverse=True)
for i,n in enumerate(sc):
if i>=n:
hi = i
break
hi=i+1
return hi
在网络科学中,定义节点的H-index值为h,满足至少h个邻居节点,每个邻居节点的度不小于h [4]。利用NetworkX求解H-index的代码如下:
# -*- coding: utf-8 -*-
'''
@Descripttion:
@Version:
@Author: Xinyu Huang
@Date: 2019-08-25 16:16:52
@LastEditors: Xinyu Huang
@LastEditTime: 2019-08-25 16:47:45
'''
import networkx as nx
import matplotlib.pyplot as plt
def h_index(G, u):
'''
@description: Calculate the h-index of node u.
@param : Graph G, node u
@return: h-index of node u
'''
# Define initial h_index equals 0.
hi = 0
# Define node u's neighbors.
ns = {n:G.degree[n] for n in G[u]}
# Sorted the neighbors in increasing order with node degree.
sns = sorted(zip(ns.keys(), ns.values()), key=lambda x:x[1], reverse=True)
# print(sns)
for i, n in enumerate(sns):
if i >= n[1]:
hi = i
break
hi = i+1
return hi
# Load karate club graph data.
G = nx.karate_club_graph()
# Show the Graph
nx.draw(G, with_labels=True, node_color='r')
plt.show()
# Show h-index
his = {n:h_index(G, n) for n in G.nodes()}
print(his)
运行结果:
{0: 5, 1: 4, 2: 5, 3: 4, 4: 3, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 10: 3, 11: 1, 12: 2, 13: 5, 14: 2, 15: 2, 16: 2, 17: 2, 18: 2, 19: 3, 20: 2, 21: 2, 22: 2, 23: 4, 24: 3, 25: 3, 26: 2, 27: 3, 28: 3, 29: 3, 30: 4, 31: 3, 32: 5, 33: 5}
参考文献:
- Hirsch, Jorge E., (2005), "An index to quantify an individual's scientific research output," PNAS 102(46):16569-16572
- Lehmann S. L., Lautrup B. E., and Jackson A. D. (December 2006). "Measures for measures". Nature 404 (7122): 1003–1004.
- https://leetcode-cn.com/problems/h-index
- L. Lü, T. Zhou, Q.-M. Zhang, and H. E. Stanley, “The H-index of a network node and its relation to degree and coreness,” Nat Commun, vol. 7, no. 1, p. 10168, Apr. 2016.