ghdms

영화별 출연진의 betweenness 평균 산출

...@@ -216,6 +216,7 @@ data = { ...@@ -216,6 +216,7 @@ data = {
216 # "몽타주": "", 216 # "몽타주": "",
217 # "명당": "", 217 # "명당": "",
218 } 218 }
219 +#500만 이상 + 스크린 수당 매출액 50위 이상 => 79개 영화, 730개 노드, 9348개 엣지
219 220
220 def named_union(graph1, graph2): #두 그래프 합성 221 def named_union(graph1, graph2): #두 그래프 합성
221 A = graph1.copy() 222 A = graph1.copy()
...@@ -274,6 +275,7 @@ frequency[top[len(top) - 1]] = 1 ...@@ -274,6 +275,7 @@ frequency[top[len(top) - 1]] = 1
274 G = Graph.Full(len(top)) 275 G = Graph.Full(len(top))
275 G.vs["name"] = top[:] 276 G.vs["name"] = top[:]
276 G.vs["label"] = G.vs["name"][:] 277 G.vs["label"] = G.vs["name"][:]
278 +topTmp = data["명량"]
277 del data["명량"] 279 del data["명량"]
278 280
279 for movie in data: 281 for movie in data:
...@@ -302,6 +304,9 @@ for movie in data: ...@@ -302,6 +304,9 @@ for movie in data:
302 weight[join]["audiences"] += audiences[movie] 304 weight[join]["audiences"] += audiences[movie]
303 weight[join]["count"] += 1 305 weight[join]["count"] += 1
304 306
307 +for f in sorted(list(frequency.keys()), key=lambda x: frequency[x], reverse=True)[:10]:
308 + print(f, frequency[f])
309 +
305 print("\n<같은 영화에 같이 출연한 빈도수>") 310 print("\n<같은 영화에 같이 출연한 빈도수>")
306 topten = sorted(keys, key=lambda n: weight[n]["count"], reverse=True)[:10] 311 topten = sorted(keys, key=lambda n: weight[n]["count"], reverse=True)[:10]
307 for t in topten: 312 for t in topten:
...@@ -343,6 +348,27 @@ egSorted = sorted(eg, reverse=True)[:10] ...@@ -343,6 +348,27 @@ egSorted = sorted(eg, reverse=True)[:10]
343 topEg = sorted(names1, key=lambda n: eg[names2.index(n)], reverse=True)[:10] 348 topEg = sorted(names1, key=lambda n: eg[names2.index(n)], reverse=True)[:10]
344 printResult(topEg, egSorted, 5, 8, 10) 349 printResult(topEg, egSorted, 5, 8, 10)
345 350
351 +avgOfBn = []
352 +totalBn = 0
353 +topActors = topTmp.split(",")
354 +for actor in topActors:
355 + i = names.index(actor)
356 + totalBn += bn[i]
357 +avgOfBn.append({"movie":"명량", "avgOfBn":totalBn / len(topActors)})
358 +
359 +for movie in data:
360 + totalBn = 0
361 + actors = data[movie].split(",")
362 + for actor in actors:
363 + i = names.index(actor)
364 + totalBn += bn[i]
365 + avgOfBn.append({"movie":movie, "avgOfBn":totalBn / len(actors)})
366 +
367 +print("\n<average of betweenness>")
368 +avgOfBnSorted = sorted(avgOfBn, key=lambda n: n["avgOfBn"], reverse=True)[:10]
369 +for a in avgOfBnSorted:
370 + print(a["movie"], a["avgOfBn"])
371 +
346 print("\n<total nodes>") 372 print("\n<total nodes>")
347 print(len(G.vs)) 373 print(len(G.vs))
348 374
...@@ -362,4 +388,4 @@ out = plot(G, ...@@ -362,4 +388,4 @@ out = plot(G,
362 ) 388 )
363 out.save("test.png") 389 out.save("test.png")
364 390
365 -#C:\Users\ghdms\2014104137\소스코드\movie.py
...\ No newline at end of file ...\ No newline at end of file
391 +#C:\Users\ghdms\2014104137\소스코드\centrality.py
...\ No newline at end of file ...\ No newline at end of file
......
This diff is collapsed. Click to expand it.