Showing
33 changed files
with
622 additions
and
0 deletions
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
소스코드/Movie_data/movie_top500.xlsx
0 → 100644
No preview for this file type
소스코드/[betweenness]all_annual_distributor.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_director_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | +for i in range(7,507,1): | ||
30 | + distributor_name='L'+str(i) | ||
31 | + director_name='K'+str(i) | ||
32 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[director_name].value)).split(',') | ||
33 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
34 | + movie_director_list.append(name3) | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | +for i in range(0, 500): | ||
40 | + if movie_director_list[i] in movie_check_list: | ||
41 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_director_list[i])] | ||
42 | + movie_audience_list[movie_check_list.index(movie_director_list[i])]=movie_audience_list[i] | ||
43 | + movie_check_list.append(movie_director_list[i]) | ||
44 | + else: | ||
45 | + movie_check_list.append(movie_director_list[i]) | ||
46 | + if movie_audience_list[i] > max_audience: | ||
47 | + max_audience=movie_audience_list[i] | ||
48 | + | ||
49 | + | ||
50 | +for i in range(0, 500): | ||
51 | + movie_graph = nx.Graph() | ||
52 | + movie_edge = make_edge(movie_director_list[i]) | ||
53 | + movie_edge_list.append(movie_edge) | ||
54 | + movie_graph.add_nodes_from(movie_director_list[i]) | ||
55 | + movie_graph.add_edges_from(movie_edge_list[i], weight = 1-(movie_audience_list[i]/(max_audience+1))) | ||
56 | + movie_graph_list.append(movie_graph) | ||
57 | + | ||
58 | + | ||
59 | +movie_total = nx.Graph() | ||
60 | + | ||
61 | +for i in range(0,500): | ||
62 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
63 | + | ||
64 | +degree = movie_total.degree() | ||
65 | +nx.write_gexf(movie_total, "Gephi/[betweenness]all_annual_distributor.gexf") | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | +plt.figure(figsize=(20,20)) | ||
71 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
72 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
73 | +plt.show() | ||
74 | + | ||
75 | + |
소스코드/[betweenness]all_annual_genre.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_genre_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | +for i in range(7,507,1): | ||
32 | + distributor_name='L'+str(i) | ||
33 | + genre_name='M'+str(i) | ||
34 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[genre_name].value)).split(',') | ||
35 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
36 | + movie_genre_list.append(name3) | ||
37 | + | ||
38 | + | ||
39 | +for i in range(0, 500): | ||
40 | + if movie_genre_list[i] in movie_check_list: | ||
41 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_genre_list[i])] | ||
42 | + movie_audience_list[movie_check_list.index(movie_genre_list[i])]=movie_audience_list[i] | ||
43 | + movie_check_list.append(movie_genre_list[i]) | ||
44 | + else: | ||
45 | + movie_check_list.append(movie_genre_list[i]) | ||
46 | + if movie_audience_list[i] > max_audience: | ||
47 | + max_audience=movie_audience_list[i] | ||
48 | + | ||
49 | + | ||
50 | +for i in range(0, 500): | ||
51 | + movie_graph = nx.Graph() | ||
52 | + movie_edge = make_edge(movie_genre_list[i]) | ||
53 | + movie_edge_list.append(movie_edge) | ||
54 | + movie_graph.add_nodes_from(movie_genre_list[i]) | ||
55 | + movie_graph.add_edges_from(movie_edge_list[i], weight = 1-(movie_audience_list[i]/(max_audience+1))) | ||
56 | + movie_graph_list.append(movie_graph) | ||
57 | + | ||
58 | + | ||
59 | +movie_total = nx.Graph() | ||
60 | + | ||
61 | +for i in range(0,500): | ||
62 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
63 | + | ||
64 | +degree = movie_total.degree() | ||
65 | +nx.write_gexf(movie_total, "Gephi/[betweenness]all_annual_genre.gexf") | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | +plt.figure(figsize=(20,20)) | ||
71 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
72 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
73 | +plt.show() | ||
74 | + | ||
75 | + |
소스코드/[betweenness]annual_distributor.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_director_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | +movie_year=input("영화의 개봉연도 4자리를 입력해주세요: ") | ||
28 | +range_count=0 | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | +for i in range(7,507,1): | ||
33 | + movie_year_check=str(load_ws['C'+str(i)].value) | ||
34 | + distributor_name='L'+str(i) | ||
35 | + director_name='K'+str(i) | ||
36 | + if movie_year == movie_year_check[:4]: | ||
37 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[director_name].value)).split(',') | ||
38 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
39 | + movie_director_list.append(name3) | ||
40 | + range_count+=1 | ||
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | +for i in range(0, range_count): | ||
46 | + if movie_director_list[i] in movie_check_list: | ||
47 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_director_list[i])] | ||
48 | + movie_audience_list[movie_check_list.index(movie_director_list[i])]=movie_audience_list[i] | ||
49 | + movie_check_list.append(movie_director_list[i]) | ||
50 | + else: | ||
51 | + movie_check_list.append(movie_director_list[i]) | ||
52 | + if movie_audience_list[i] > max_audience: | ||
53 | + max_audience=movie_audience_list[i] | ||
54 | + | ||
55 | + | ||
56 | +for i in range(0, range_count): | ||
57 | + movie_graph = nx.Graph() | ||
58 | + movie_edge = make_edge(movie_director_list[i]) | ||
59 | + movie_edge_list.append(movie_edge) | ||
60 | + movie_graph.add_nodes_from(movie_director_list[i]) | ||
61 | + movie_graph.add_edges_from(movie_edge_list[i], weight = 1-(movie_audience_list[i]/(max_audience+1))) | ||
62 | + movie_graph_list.append(movie_graph) | ||
63 | + | ||
64 | + | ||
65 | +movie_total = nx.Graph() | ||
66 | + | ||
67 | +for i in range(0,range_count): | ||
68 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
69 | + | ||
70 | +degree = movie_total.degree() | ||
71 | +nx.write_gexf(movie_total, "Gephi/[betweenness]annual_distributor_"+movie_year+".gexf") | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | +plt.figure(figsize=(20,20)) | ||
77 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
78 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
79 | +plt.show() | ||
80 | + | ||
81 | + |
소스코드/[betweenness]annual_genre.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_genre_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | +movie_year=input("영화의 개봉연도 4자리를 입력해주세요: ") | ||
29 | +range_count=0 | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | +for i in range(7,507,1): | ||
34 | + movie_year_check=str(load_ws['C'+str(i)].value) | ||
35 | + distributor_name='L'+str(i) | ||
36 | + genre_name='M'+str(i) | ||
37 | + if movie_year == movie_year_check[:4]: | ||
38 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[genre_name].value)).split(',') | ||
39 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
40 | + movie_genre_list.append(name3) | ||
41 | + range_count+=1 | ||
42 | + | ||
43 | + | ||
44 | +for i in range(0, range_count): | ||
45 | + if movie_genre_list[i] in movie_check_list: | ||
46 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_genre_list[i])] | ||
47 | + movie_audience_list[movie_check_list.index(movie_genre_list[i])]=movie_audience_list[i] | ||
48 | + movie_check_list.append(movie_genre_list[i]) | ||
49 | + else: | ||
50 | + movie_check_list.append(movie_genre_list[i]) | ||
51 | + if movie_audience_list[i] > max_audience: | ||
52 | + max_audience=movie_audience_list[i] | ||
53 | + | ||
54 | + | ||
55 | +for i in range(0, range_count): | ||
56 | + movie_graph = nx.Graph() | ||
57 | + movie_edge = make_edge(movie_genre_list[i]) | ||
58 | + movie_edge_list.append(movie_edge) | ||
59 | + movie_graph.add_nodes_from(movie_genre_list[i]) | ||
60 | + movie_graph.add_edges_from(movie_edge_list[i], weight = 1-(movie_audience_list[i]/(max_audience+1))) | ||
61 | + movie_graph_list.append(movie_graph) | ||
62 | + | ||
63 | + | ||
64 | +movie_total = nx.Graph() | ||
65 | + | ||
66 | +for i in range(0,range_count): | ||
67 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
68 | + | ||
69 | +degree = movie_total.degree() | ||
70 | +nx.write_gexf(movie_total, "Gephi/[betweenness]annual_genre_"+movie_year+".gexf") | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | +plt.figure(figsize=(20,20)) | ||
76 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
77 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
78 | +plt.show() | ||
79 | + | ||
80 | + |
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_director_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | +for i in range(7,507,1): | ||
30 | + distributor_name='L'+str(i) | ||
31 | + director_name='K'+str(i) | ||
32 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[director_name].value)).split(',') | ||
33 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
34 | + movie_director_list.append(name3) | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | +for i in range(0, 500): | ||
40 | + if movie_director_list[i] in movie_check_list: | ||
41 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_director_list[i])] | ||
42 | + movie_audience_list[movie_check_list.index(movie_director_list[i])]=movie_audience_list[i] | ||
43 | + movie_check_list.append(movie_director_list[i]) | ||
44 | + else: | ||
45 | + movie_check_list.append(movie_director_list[i]) | ||
46 | + if movie_audience_list[i] > max_audience: | ||
47 | + max_audience=movie_audience_list[i] | ||
48 | + | ||
49 | + | ||
50 | +for i in range(0, 500): | ||
51 | + movie_graph = nx.Graph() | ||
52 | + movie_edge = make_edge(movie_director_list[i]) | ||
53 | + movie_edge_list.append(movie_edge) | ||
54 | + movie_graph.add_nodes_from(movie_director_list[i]) | ||
55 | + movie_graph.add_edges_from(movie_edge_list[i], weight = movie_audience_list[i]/(max_audience+1)) | ||
56 | + movie_graph_list.append(movie_graph) | ||
57 | + | ||
58 | + | ||
59 | +movie_total = nx.Graph() | ||
60 | + | ||
61 | +for i in range(0,500): | ||
62 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
63 | + | ||
64 | +degree = movie_total.degree() | ||
65 | +nx.write_gexf(movie_total, "Gephi/[weighted-degree]all_annual_distributor.gexf") | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | +plt.figure(figsize=(20,20)) | ||
71 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
72 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
73 | +plt.show() | ||
74 | + | ||
75 | + |
소스코드/[weighted-degree]all_annual_genre.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_genre_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | +for i in range(7,507,1): | ||
32 | + distributor_name='L'+str(i) | ||
33 | + genre_name='M'+str(i) | ||
34 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[genre_name].value)).split(',') | ||
35 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
36 | + movie_genre_list.append(name3) | ||
37 | + | ||
38 | + | ||
39 | +for i in range(0, 500): | ||
40 | + if movie_genre_list[i] in movie_check_list: | ||
41 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_genre_list[i])] | ||
42 | + movie_audience_list[movie_check_list.index(movie_genre_list[i])]=movie_audience_list[i] | ||
43 | + movie_check_list.append(movie_genre_list[i]) | ||
44 | + else: | ||
45 | + movie_check_list.append(movie_genre_list[i]) | ||
46 | + if movie_audience_list[i] > max_audience: | ||
47 | + max_audience=movie_audience_list[i] | ||
48 | + | ||
49 | + | ||
50 | +for i in range(0, 500): | ||
51 | + movie_graph = nx.Graph() | ||
52 | + movie_edge = make_edge(movie_genre_list[i]) | ||
53 | + movie_edge_list.append(movie_edge) | ||
54 | + movie_graph.add_nodes_from(movie_genre_list[i]) | ||
55 | + movie_graph.add_edges_from(movie_edge_list[i], weight = movie_audience_list[i]/(max_audience+1)) | ||
56 | + movie_graph_list.append(movie_graph) | ||
57 | + | ||
58 | + | ||
59 | +movie_total = nx.Graph() | ||
60 | + | ||
61 | +for i in range(0,500): | ||
62 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
63 | + | ||
64 | +degree = movie_total.degree() | ||
65 | +nx.write_gexf(movie_total, "Gephi/[weighted-degree]all_annual_genre.gexf") | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | +plt.figure(figsize=(20,20)) | ||
71 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
72 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
73 | +plt.show() | ||
74 | + | ||
75 | + |
소스코드/[weighted-degree]annual_distributor.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_director_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | +movie_year=input("영화의 개봉연도 4자리를 입력해주세요: ") | ||
28 | +range_count=0 | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | +for i in range(7,507,1): | ||
33 | + movie_year_check=str(load_ws['C'+str(i)].value) | ||
34 | + distributor_name='L'+str(i) | ||
35 | + director_name='K'+str(i) | ||
36 | + if movie_year == movie_year_check[:4]: | ||
37 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[director_name].value)).split(',') | ||
38 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
39 | + movie_director_list.append(name3) | ||
40 | + range_count+=1 | ||
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | ||
45 | +for i in range(0, range_count): | ||
46 | + if movie_director_list[i] in movie_check_list: | ||
47 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_director_list[i])] | ||
48 | + movie_audience_list[movie_check_list.index(movie_director_list[i])]=movie_audience_list[i] | ||
49 | + movie_check_list.append(movie_director_list[i]) | ||
50 | + else: | ||
51 | + movie_check_list.append(movie_director_list[i]) | ||
52 | + if movie_audience_list[i] > max_audience: | ||
53 | + max_audience=movie_audience_list[i] | ||
54 | + | ||
55 | + | ||
56 | +for i in range(0, range_count): | ||
57 | + movie_graph = nx.Graph() | ||
58 | + movie_edge = make_edge(movie_director_list[i]) | ||
59 | + movie_edge_list.append(movie_edge) | ||
60 | + movie_graph.add_nodes_from(movie_director_list[i]) | ||
61 | + movie_graph.add_edges_from(movie_edge_list[i], weight = movie_audience_list[i]/(max_audience+1)) | ||
62 | + movie_graph_list.append(movie_graph) | ||
63 | + | ||
64 | + | ||
65 | +movie_total = nx.Graph() | ||
66 | + | ||
67 | +for i in range(0,range_count): | ||
68 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
69 | + | ||
70 | +degree = movie_total.degree() | ||
71 | +nx.write_gexf(movie_total, "Gephi/[weighted-degree]annual_distributor_"+movie_year+".gexf") | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | +plt.figure(figsize=(20,20)) | ||
77 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
78 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
79 | +plt.show() | ||
80 | + | ||
81 | + |
소스코드/[weighted-degree]annual_genre.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | +import matplotlib.pyplot as plt | ||
3 | +import networkx as nx | ||
4 | +from openpyxl import load_workbook | ||
5 | + | ||
6 | + | ||
7 | +movie_genre_list = [] | ||
8 | +movie_audience_list = [] | ||
9 | +movie_edge_list = [] | ||
10 | +movie_graph_list = [] | ||
11 | +movie_check_list = [] | ||
12 | +max_audience=-1 | ||
13 | +load_wb = load_workbook("Movie_data/movie_top500.xlsx", data_only=True) | ||
14 | +load_ws = load_wb['Sheet1'] | ||
15 | + | ||
16 | + | ||
17 | +def make_edge(movielist): | ||
18 | + edge_list = [] | ||
19 | + for i in range(0,len(movielist)): | ||
20 | + for j in range(0, len(movielist)): | ||
21 | + if i == j: | ||
22 | + break | ||
23 | + else: | ||
24 | + edge_list.append((movielist[i],movielist[j])) | ||
25 | + return edge_list | ||
26 | + | ||
27 | + | ||
28 | +movie_year=input("영화의 개봉연도 4자리를 입력해주세요: ") | ||
29 | +range_count=0 | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | +for i in range(7,507,1): | ||
34 | + movie_year_check=str(load_ws['C'+str(i)].value) | ||
35 | + distributor_name='L'+str(i) | ||
36 | + genre_name='M'+str(i) | ||
37 | + if movie_year == movie_year_check[:4]: | ||
38 | + name3=(str(load_ws[distributor_name].value) +','+ str(load_ws[genre_name].value)).split(',') | ||
39 | + movie_audience_list.append(int(load_ws['F'+str(i)].value)) | ||
40 | + movie_genre_list.append(name3) | ||
41 | + range_count+=1 | ||
42 | + | ||
43 | + | ||
44 | +for i in range(0, range_count): | ||
45 | + if movie_genre_list[i] in movie_check_list: | ||
46 | + movie_audience_list[i]=movie_audience_list[i]+movie_audience_list[movie_check_list.index(movie_genre_list[i])] | ||
47 | + movie_audience_list[movie_check_list.index(movie_genre_list[i])]=movie_audience_list[i] | ||
48 | + movie_check_list.append(movie_genre_list[i]) | ||
49 | + else: | ||
50 | + movie_check_list.append(movie_genre_list[i]) | ||
51 | + if movie_audience_list[i] > max_audience: | ||
52 | + max_audience=movie_audience_list[i] | ||
53 | + | ||
54 | + | ||
55 | +for i in range(0, range_count): | ||
56 | + movie_graph = nx.Graph() | ||
57 | + movie_edge = make_edge(movie_genre_list[i]) | ||
58 | + movie_edge_list.append(movie_edge) | ||
59 | + movie_graph.add_nodes_from(movie_genre_list[i]) | ||
60 | + movie_graph.add_edges_from(movie_edge_list[i], weight = movie_audience_list[i]/(max_audience+1)) | ||
61 | + movie_graph_list.append(movie_graph) | ||
62 | + | ||
63 | + | ||
64 | +movie_total = nx.Graph() | ||
65 | + | ||
66 | +for i in range(0,range_count): | ||
67 | + movie_total = nx.compose(movie_total, movie_graph_list[i]) | ||
68 | + | ||
69 | +degree = movie_total.degree() | ||
70 | +nx.write_gexf(movie_total, "Gephi/[weighted-degree]annual_genre_"+movie_year+".gexf") | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | +plt.figure(figsize=(20,20)) | ||
76 | +pos = nx.spring_layout(movie_total, iterations = 10) | ||
77 | +nx.draw(movie_total, pos, alpha = 1, line_color= 'black', linewidths = 0, width = 0.05 ,node_size = 100, node_color = 'w', with_labels = True, font_family='NanumGothic', font_color='black', font_size=8) | ||
78 | +plt.show() | ||
79 | + | ||
80 | + |
-
Please register or login to post a comment