ghdms

중간보고서 제출

......@@ -232,9 +232,12 @@ def named_union(graph1, graph2): #두 그래프 합성
Z.vs["label"] = Z.vs["name"][:]
return Z
frequency = {}
weight = {}
keys = []
top = data["명량"].split(",")
for t in top:
frequency[t] = 1
G = Graph.Full(len(top))
G.vs["name"] = top[:]
G.vs["label"] = G.vs["name"][:]
......@@ -246,6 +249,11 @@ for movie in data:
g.vs["name"] = actors[:]
g.vs["label"] = g.vs["name"][:]
G = named_union(G, g)
for a in actors:
if(a not in frequency):
frequency[a] = 1
else:
frequency[a] += 1
for i in range(0, len(actors)-1):
for j in range(i+1, len(actors)):
......@@ -271,7 +279,10 @@ names, names1, names2 = G.vs["name"][:], G.vs["name"][:], G.vs["name"][:]
degree = G.degree()
print(sorted(degree, reverse=True)[:10])
print(sorted(names1, key=lambda n: degree[names2.index(n)], reverse=True)[:10])
topDegree = sorted(names1, key=lambda n: degree[names2.index(n)], reverse=True)[:10]
for td in topDegree:
print(td + "(" + str(frequency[td]) + ")")
print("정인기(" + str(frequency["정인기"]) + ")")
edge_weight = [1] * len(G.es)
for k in keys:
......@@ -291,6 +302,8 @@ cn = G.closeness(weights=edge_weight)
print(sorted(cn, reverse=True)[:10])
print(sorted(names1, key=lambda n: cn[names2.index(n)], reverse=True)[:10])
print(len(G.vs))
print(len(G.es))
out = plot(G,
bbox = (2000, 2000),
vertex_size = [int((float(i)/max(bn)) * 20) + 5 for i in bn],
......
No preview for this file type