forked from SNUCSE-CTA/graph-analysis-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdegree.py
50 lines (43 loc) · 1.21 KB
/
degree.py
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
from matplotlib import pyplot as plt
import math
import sys
plt.switch_backend('agg')
graph_name = sys.argv[1]
# degree
with open('./pyplot/degree.txt', mode='rt') as f:
while True:
text=f.readline()
if not text:
break
a=text.split()
for i in range(len(a)):
a[i]=int(a[i])
b=[]
for i in range(a[-1]+1):
b.append(0)
degree = list(range(0, a[-1]+1))
for i in range(len(a)):
b[a[i]]=b[a[i]]+1
plt.figure(3)
plt.scatter(degree, b)
plt.xlabel('degree')
plt.ylabel('# of vertex')
plt.title('degree')
fig = plt.gcf()
fpath="./pyplot/"+str(graph_name)+"_degree.png"
fig.savefig(fpath, dpi=300)
#log scale
plt.figure(4)
plt.xscale('log')
plt.yscale('log')
xmax = max(degree) * 2
ymax = max(b) * 2
plt.xlim(0.8, xmax)
plt.ylim(0.8, ymax)
plt.scatter(degree, b)
plt.xlabel('degree')
plt.ylabel('# of vertex')
plt.title('degree_log')
fig = plt.gcf()
fpath = "./pyplot/"+str(graph_name)+"_degree_log.png"
fig.savefig(fpath, dpi=300)