Showing
1 changed file
with
0 additions
and
74 deletions
소스코드/baseball.py
deleted
100644 → 0
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_school_list = [] | ||
22 | -BB_player_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_player_list.append(int(load_ws['H'+str(i)].value)) | ||
29 | - BB_school_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_school_list[i]) | ||
39 | - if BB_school_list[i] in check_list: | ||
40 | - BB_player_list[i]=BB_player_list[i]+BB_player_list[check_list.index(BB_school_list[i])] | ||
41 | - BB_player_list[check_list.index(BB_school_list[i])]=BB_player_list[i] | ||
42 | - check_list.append(BB_school_list[i]) | ||
43 | - else: | ||
44 | - check_list.append(BB_school_list[i]) | ||
45 | - | ||
46 | - edge_list.append(edge) | ||
47 | - graph.add_nodes_from(BB_school_list[i]) | ||
48 | - graph.add_edges_from(edge_list[i], weight = round(BB_player_list[i]/100000000,5)) | ||
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.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 | - |
-
Please register or login to post a comment