-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphing.py
More file actions
69 lines (57 loc) · 1.98 KB
/
Copy pathgraphing.py
File metadata and controls
69 lines (57 loc) · 1.98 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import networkx as nx
import matplotlib.pyplot as plt
import base
import shared
'''
Functions for graphing k high citation papers vs inbound edges from distinct
nodes
'''
def graph_distinct_citers(G, k=10):
if isinstance(k, int):
k = [k]
for k_val in k:
y = base.distinct_citers(G, k_val)
x = [n for n in range(1, k_val+1)]
plt.bar(x, y)
plt.title('Distinct Papers Citing any of Top-K Most Cited')
plt.xlabel('K')
plt.ylabel('Distinct Citers')
plt.savefig('citers_'+str(k_val)+'.png')
def graph_distinct_citers_fraction(G, k=10):
num_nodes = G.order()
if isinstance(k, int):
k = [k]
for k_val in k:
y = [count/num_nodes for count in base.distinct_citers(G, k_val)]
x = [n for n in range(1, k_val+1)]
plt.bar(x, y)
plt.title('Fraction of Papers Citing any of Top-K Most Cited')
plt.xlabel('K')
plt.ylabel('Fraction of Papers')
plt.savefig('frac_citers_'+str(k_val)+'.png')
def graph_distinct_cited(G, k=10):
if isinstance(k, int):
k = [k]
for k_val in k:
y = base.distinct_cited(G, k_val)
x = [n for n in range(1, k_val+1)]
plt.bar(x, y)
plt.title('Distinct Papers Cited by any of Top-K Papers with Most References')
plt.xlabel('K')
plt.ylabel('Distinct Cited')
plt.savefig('cited_'+str(k_val)+'.png')
def graph_distinct_cited_fraction(G, k=10):
num_nodes = G.order()
if isinstance(k, int):
k = [k]
for k_val in k:
y = [count/num_nodes for count in base.distinct_cited(G, k_val)]
x = [n for n in range(1, k_val+1)]
plt.bar(x, y)
plt.title('Fraction of Papers Papers Cited by any of Top-K Papers with Most Teferences')
plt.xlabel('K')
plt.ylabel('Fraction of Cited')
plt.savefig('frac_cited_'+str(k_val)+'.png')
G = shared.load_graph('HepTh')
print(nx.info(G))
graph_distinct_cited_fraction(G, [10, 50, 100, 1000, G.order()])