-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
41 lines (30 loc) · 902 Bytes
/
base.py
File metadata and controls
41 lines (30 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import networkx as nx
import shared
'''
cumulative count of distinct nodes that cite the top k most cited papers
in G
'''
def distinct_citers(G, k):
top_ids = shared.in_degree_top_k_ids(G, k)
distinct_nodes = set()
k_steps = []
for id in top_ids:
papers_citing_id = G.predecessors(str(id))
for paper in papers_citing_id:
distinct_nodes.add(paper)
k_steps.append(len(distinct_nodes))
return k_steps
'''
cumulative count of distinct nodes that are cited by the top k papers with
the most citations in G
'''
def distinct_cited(G, k):
top_ids = shared.out_degree_top_k_ids(G, k)
distinct_nodes = set()
k_steps = []
for id in top_ids:
papers_citing_id = G.successors(str(id))
for paper in papers_citing_id:
distinct_nodes.add(paper)
k_steps.append(len(distinct_nodes))
return k_steps