ghdms

중간보고서 제출

...@@ -232,9 +232,12 @@ def named_union(graph1, graph2): #두 그래프 합성 ...@@ -232,9 +232,12 @@ def named_union(graph1, graph2): #두 그래프 합성
232 Z.vs["label"] = Z.vs["name"][:] 232 Z.vs["label"] = Z.vs["name"][:]
233 return Z 233 return Z
234 234
235 +frequency = {}
235 weight = {} 236 weight = {}
236 keys = [] 237 keys = []
237 top = data["명량"].split(",") 238 top = data["명량"].split(",")
239 +for t in top:
240 + frequency[t] = 1
238 G = Graph.Full(len(top)) 241 G = Graph.Full(len(top))
239 G.vs["name"] = top[:] 242 G.vs["name"] = top[:]
240 G.vs["label"] = G.vs["name"][:] 243 G.vs["label"] = G.vs["name"][:]
...@@ -246,6 +249,11 @@ for movie in data: ...@@ -246,6 +249,11 @@ for movie in data:
246 g.vs["name"] = actors[:] 249 g.vs["name"] = actors[:]
247 g.vs["label"] = g.vs["name"][:] 250 g.vs["label"] = g.vs["name"][:]
248 G = named_union(G, g) 251 G = named_union(G, g)
252 + for a in actors:
253 + if(a not in frequency):
254 + frequency[a] = 1
255 + else:
256 + frequency[a] += 1
249 257
250 for i in range(0, len(actors)-1): 258 for i in range(0, len(actors)-1):
251 for j in range(i+1, len(actors)): 259 for j in range(i+1, len(actors)):
...@@ -271,7 +279,10 @@ names, names1, names2 = G.vs["name"][:], G.vs["name"][:], G.vs["name"][:] ...@@ -271,7 +279,10 @@ names, names1, names2 = G.vs["name"][:], G.vs["name"][:], G.vs["name"][:]
271 279
272 degree = G.degree() 280 degree = G.degree()
273 print(sorted(degree, reverse=True)[:10]) 281 print(sorted(degree, reverse=True)[:10])
274 -print(sorted(names1, key=lambda n: degree[names2.index(n)], reverse=True)[:10]) 282 +topDegree = sorted(names1, key=lambda n: degree[names2.index(n)], reverse=True)[:10]
283 +for td in topDegree:
284 + print(td + "(" + str(frequency[td]) + ")")
285 +print("정인기(" + str(frequency["정인기"]) + ")")
275 286
276 edge_weight = [1] * len(G.es) 287 edge_weight = [1] * len(G.es)
277 for k in keys: 288 for k in keys:
...@@ -291,6 +302,8 @@ cn = G.closeness(weights=edge_weight) ...@@ -291,6 +302,8 @@ cn = G.closeness(weights=edge_weight)
291 print(sorted(cn, reverse=True)[:10]) 302 print(sorted(cn, reverse=True)[:10])
292 print(sorted(names1, key=lambda n: cn[names2.index(n)], reverse=True)[:10]) 303 print(sorted(names1, key=lambda n: cn[names2.index(n)], reverse=True)[:10])
293 304
305 +print(len(G.vs))
306 +print(len(G.es))
294 out = plot(G, 307 out = plot(G,
295 bbox = (2000, 2000), 308 bbox = (2000, 2000),
296 vertex_size = [int((float(i)/max(bn)) * 20) + 5 for i in bn], 309 vertex_size = [int((float(i)/max(bn)) * 20) + 5 for i in bn],
......
No preview for this file type