[pypy-issue] Issue #2678: Is code possible to run PyPy? (pypy/pypy)
JINOPAEK
issues-reply at bitbucket.org
Wed Oct 11 07:16:44 EDT 2017
New issue 2678: Is code possible to run PyPy?
https://bitbucket.org/pypy/pypy/issues/2678/is-code-possible-to-run-pypy
JINOPAEK:
I want to social network analysis with python networkx
but when I use python, it is very slow..
So I search many solution, I choose PyPy
But I don't know PyPy deep...
I can use ubuntu
Code is
```
#!python
import networkx as nx
import time
start_time = time.time()
G = nx.Graph() # 그래프 생성
f= open('H:/최종네트워크/201310_Network_basic.txt','r') # 파일 열기
#파일 읽기
f_1 = f.readlines()
for lineF in f_1:
i = lineF[:-1].split('|')
categories = i[0]
k = (i[0],i[1])
G.add_node(i[0]) # 노드 지정
G.add_edge(*k) # 라인 생성
pos = nx.shell_layout(G) #좌표 지정
nx.draw_networkx_labels(G,pos,font_size=10) # 라벨 씌우기
nx.draw_shell(G) # 그래프 모양 지정
#네트워크 분석
#네트워크 분석
x = G.number_of_edges() # 총 연결된 라인수
y = len(G) #총 노드의 수
# 연결정도중심성 PART
o = nx.degree_centrality(G)
o1 = []
o2 = []
for v in o.values():
o1.append(float(v))
e = float(sum(o1)/y) #연결중심성평균
for w in o.values():
o2.append(float(pow(w-e,2)))
j = float(sum(o2)/y) #연결중심성분산
o = str(o)#연결정도중심성
#매개중심성 PARRT
p = nx.betweenness_centrality(G)
p1 = []
p2= []
for s in p.values():
p1.append(s)
l = float(sum(p1)/y) # 매개중심성평균
for t in p.values():
p2.append(pow(t-l,2))
m = float(sum(p2)/y) # 매개중심성분산
p = str(p) #매개정도중심성
q = nx.degree(G) #연결정도
n1=[]
for r in q.values():
n1.append(r)
n = sum(n1)#라인 연결정도 합
n = str(n)
e = str(e)
j = str(j)
l = str(l)
m = str(m)
q = str(q)
x = str(x)
y = str(y)
g = open('C:/Users/UrbanLab-4/Desktop/201310결과.txt','a+')
print('총노드수 '+': ' + y + '\n',file=g)
print('\n'+'총 라인수 '+': ' + x + '\n',file=g)
print('\n'+'라인 연결정도 합 '+': ' + n + '\n',file=g)
print('\n'+'연결정도 '+': ' + q + '\n',file=g)
print('\n'+'연결정도중심성 '+': ' + o + '\n',file=g)
print('\n'+'연결정도중심성 평균 '+':' +e + '\n',file=g)
print('\n'+'연결정도중심성 분산 '+':' +j + '\n',file=g)
print('\n'+'매개정도중심성 '+':' +p + '\n',file=g)
print('\n'+'매개정도중심성 평균 '+':' +l + '\n',file=g)
print('\n'+'매개정도중심성 분산'+':' +m + '\n',file=g)
g.close()
f.close()
end_time = time.time()
print(end_time - start_time)
```
More information about the pypy-issue
mailing list