ghdms

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

......@@ -216,6 +216,7 @@ data = {
# "몽타주": "",
# "명당": "",
}
#500만 이상 + 스크린 수당 매출액 50위 이상 => 79개 영화, 730개 노드, 9348개 엣지
def named_union(graph1, graph2): #두 그래프 합성
A = graph1.copy()
......@@ -274,6 +275,7 @@ frequency[top[len(top) - 1]] = 1
G = Graph.Full(len(top))
G.vs["name"] = top[:]
G.vs["label"] = G.vs["name"][:]
topTmp = data["명량"]
del data["명량"]
for movie in data:
......@@ -302,6 +304,9 @@ for movie in data:
weight[join]["audiences"] += audiences[movie]
weight[join]["count"] += 1
for f in sorted(list(frequency.keys()), key=lambda x: frequency[x], reverse=True)[:10]:
print(f, frequency[f])
print("\n<같은 영화에 같이 출연한 빈도수>")
topten = sorted(keys, key=lambda n: weight[n]["count"], reverse=True)[:10]
for t in topten:
......@@ -343,6 +348,27 @@ egSorted = sorted(eg, reverse=True)[:10]
topEg = sorted(names1, key=lambda n: eg[names2.index(n)], reverse=True)[:10]
printResult(topEg, egSorted, 5, 8, 10)
avgOfBn = []
totalBn = 0
topActors = topTmp.split(",")
for actor in topActors:
i = names.index(actor)
totalBn += bn[i]
avgOfBn.append({"movie":"명량", "avgOfBn":totalBn / len(topActors)})
for movie in data:
totalBn = 0
actors = data[movie].split(",")
for actor in actors:
i = names.index(actor)
totalBn += bn[i]
avgOfBn.append({"movie":movie, "avgOfBn":totalBn / len(actors)})
print("\n<average of betweenness>")
avgOfBnSorted = sorted(avgOfBn, key=lambda n: n["avgOfBn"], reverse=True)[:10]
for a in avgOfBnSorted:
print(a["movie"], a["avgOfBn"])
print("\n<total nodes>")
print(len(G.vs))
......@@ -362,4 +388,4 @@ out = plot(G,
)
out.save("test.png")
#C:\Users\ghdms\2014104137\소스코드\movie.py
\ No newline at end of file
#C:\Users\ghdms\2014104137\소스코드\centrality.py
\ No newline at end of file
......
This diff is collapsed. Click to expand it.