Showing
6 changed files
with
146 additions
and
0 deletions
소스코드/baseball.xlsx
0 → 100644
No preview for this file type
소스코드/baseball_between_closeness.gexf
0 → 100644
This diff could not be displayed because it is too large.
소스코드/baseball_between_closeness.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | + | ||
3 | +import matplotlib.pyplot as plt | ||
4 | +import networkx as nx | ||
5 | +from openpyxl import load_workbook | ||
6 | + | ||
7 | +wb = load_workbook("baseball.xlsx") | ||
8 | +load_ws = wb['Sheet1'] | ||
9 | + | ||
10 | + | ||
11 | +def make_edge(BBlist): | ||
12 | + edge_list = [] | ||
13 | + for i in range(0,len(BBlist)): | ||
14 | + for j in range(0, len(BBlist)): | ||
15 | + if i == j: | ||
16 | + break | ||
17 | + else: | ||
18 | + edge_list.append((BBlist[i],BBlist[j])) | ||
19 | + return edge_list | ||
20 | +BB_name_list = [] | ||
21 | +BB_Salary_list = [] | ||
22 | + | ||
23 | +for i in range(1,857,1): | ||
24 | + school_name='G'+str(i) | ||
25 | + player_name='B'+str(i) | ||
26 | + name3=(str(load_ws[school_name].value) +','+ str(load_ws[player_name].value)).split(',') | ||
27 | + BB_Salary_list.append(int(load_ws['H'+str(i)].value)) | ||
28 | + BB_name_list.append(name3) | ||
29 | + | ||
30 | + | ||
31 | +edge_list = [] | ||
32 | +graph_list = [] | ||
33 | +check_list = [] | ||
34 | + | ||
35 | +for i in range(0,856): | ||
36 | + graph = nx.Graph() | ||
37 | + edge = make_edge(BB_name_list[i]) | ||
38 | + if BB_name_list[i] in check_list: | ||
39 | + BB_Salary_list[i]=BB_Salary_list[i]+BB_Salary_list[check_list.index(BB_name_list[i])] | ||
40 | + BB_Salary_list[check_list.index(BB_name_list[i])]=BB_Salary_list[i] | ||
41 | + check_list.append(BB_name_list[i]) | ||
42 | + else: | ||
43 | + check_list.append(BB_name_list[i]) | ||
44 | + | ||
45 | + edge_list.append(edge) | ||
46 | + graph.add_nodes_from(BB_name_list[i]) | ||
47 | + graph.add_edges_from(edge_list[i], weight = 1-BB_Salary_list[i]/10000000000) | ||
48 | + graph_list.append(graph) | ||
49 | + | ||
50 | +total = nx.Graph() | ||
51 | + | ||
52 | +for i in range(0,856): | ||
53 | + total = nx.compose(total, graph_list[i]) | ||
54 | + | ||
55 | +degree = total.degree() | ||
56 | +nx.write_gexf(total, "baseball_between_closeness.gexf") | ||
57 | + | ||
58 | +options = { | ||
59 | + 'edge_color': '#FFDEA2', | ||
60 | + 'width': 1, | ||
61 | + 'with_labels': True, | ||
62 | + 'font_weight': 'regular', | ||
63 | +} | ||
64 | + | ||
65 | +plt.figure(figsize=(20,20)) | ||
66 | +pos = nx.spring_layout(total, iterations = 10) | ||
67 | +nx.draw(total, pos, **options, font_family='batang', font_color='black', font_size=8) | ||
68 | +ax = plt.gca() | ||
69 | +ax.collections[0].set_edgecolor("#555555") | ||
70 | +plt.show() | ||
71 | + | ||
72 | + |
소스코드/baseball_wiehgted-degree.gexf
0 → 100644
This diff could not be displayed because it is too large.
소스코드/baseball_wiehgted-degree.py
0 → 100644
1 | +#-*-encoding utf-8 -*- | ||
2 | + | ||
3 | +import matplotlib.pyplot as plt | ||
4 | +import networkx as nx | ||
5 | +from openpyxl import load_workbook | ||
6 | + | ||
7 | +wb = load_workbook("baseball.xlsx") | ||
8 | +load_ws = wb['Sheet1'] | ||
9 | + | ||
10 | + | ||
11 | +def make_edge(BBlist): | ||
12 | + edge_list = [] | ||
13 | + for i in range(0,len(BBlist)): | ||
14 | + for j in range(0, len(BBlist)): | ||
15 | + if i == j: | ||
16 | + break | ||
17 | + else: | ||
18 | + edge_list.append((BBlist[i],BBlist[j])) | ||
19 | + return edge_list | ||
20 | + | ||
21 | +BB_name_list = [] | ||
22 | +BB_Salary_list = [] | ||
23 | + | ||
24 | +for i in range(1,857,1): | ||
25 | + school_name='G'+str(i) | ||
26 | + player_name='B'+str(i) | ||
27 | + name3=(str(load_ws[school_name].value) +','+ str(load_ws[player_name].value)).split(',') | ||
28 | + BB_Salary_list.append(int(load_ws['H'+str(i)].value)) | ||
29 | + BB_name_list.append(name3) | ||
30 | + | ||
31 | + | ||
32 | +edge_list = [] | ||
33 | +graph_list = [] | ||
34 | +check_list = [] | ||
35 | + | ||
36 | +for i in range(0,856): | ||
37 | + graph = nx.Graph() | ||
38 | + edge = make_edge(BB_name_list[i]) | ||
39 | + if BB_name_list[i] in check_list: | ||
40 | + BB_Salary_list[i]=BB_Salary_list[i]+BB_Salary_list[check_list.index(BB_name_list[i])] | ||
41 | + BB_Salary_list[check_list.index(BB_name_list[i])]=BB_Salary_list[i] | ||
42 | + check_list.append(BB_name_list[i]) | ||
43 | + else: | ||
44 | + check_list.append(BB_name_list[i]) | ||
45 | + | ||
46 | + edge_list.append(edge) | ||
47 | + graph.add_nodes_from(BB_name_list[i]) | ||
48 | + graph.add_edges_from(edge_list[i], weight = BB_Salary_list[i]/10000000000) | ||
49 | + graph_list.append(graph) | ||
50 | + | ||
51 | + | ||
52 | +total = nx.Graph() | ||
53 | + | ||
54 | +for i in range(0,856): | ||
55 | + total = nx.compose(total, graph_list[i]) | ||
56 | + | ||
57 | +degree = total.degree() | ||
58 | +nx.write_gexf(total, "baseball_wiehgted-degree.gexf") | ||
59 | + | ||
60 | +options = { | ||
61 | + 'edge_color': '#FFDEA2', | ||
62 | + 'width': 1, | ||
63 | + 'with_labels': True, | ||
64 | + 'font_weight': 'regular', | ||
65 | +} | ||
66 | + | ||
67 | +plt.figure(figsize=(20,20)) | ||
68 | +pos = nx.spring_layout(total, iterations = 10) | ||
69 | +nx.draw(total, pos, **options, font_family='batang', font_color='black', font_size=8) | ||
70 | +ax = plt.gca() | ||
71 | +ax.collections[0].set_edgecolor("#555555") | ||
72 | +plt.show() | ||
73 | + | ||
74 | + |
소스코드/중심성 엑셀.xlsx
0 → 100644
No preview for this file type
-
Please register or login to post a comment