<jupyter_start><jupyter_text>NetworkX로 파이썬 언어 관계도 그려보기* 출처 : https://www.kaggle.com/jncharon/python-network-graph/notebook<jupyter_code>import networkx as nx
import matplotlib.pyplot as plt
import pandas as pd
G = nx.Graph(day="Stackoverflow")
df_nodes = pd.read_csv('data/stack_network_nodes.csv')
df_edges = pd.read_csv('data/stack_network_links.csv')
print(df_nodes.shape)
print(df_edges.shape)
df_nodes.head()
df_edges.head()
for index, row in df_nodes.iterrows():
    G.add_node(row['name'], group=row['group'], nodesize=row['nodesize'])
for index, row in df_edges.iterrows():
    G.add_weighted_edges_from([(row['source'], row['target'], row['value'])])
plt.figure(figsize=(25, 25))
options = {
    'edge_color': '#FFDEA2',
    'width' : 1,
    'with_labels' : True,
    'font_weight' : 'regular'
}
size = [G.node[node]['nodesize']*10 for node in G]
color_map = {1:'#f09494', 2:'#eebcbc', 3:'#72bbd0', 4:'#91f0a1', 5:'#629fff', 6:'#bcc2f2',  
             7:'#eebcbc', 8:'#f1f0c0', 9:'#d2ffe7', 10:'#caf3a6', 11:'#ffdf55', 12:'#ef77aa', 
             13:'#d6dcff', 14:'#d2f5f0'} 
colors = [color_map[G.node[node]['group']] for node in G]
nx.draw(G, node_color=colors, node_size=size, pos=nx.spring_layout(G, k=0.25, iterations=50), **options)
ax = plt.gca()
ax.collections[0].set_edgecolor("#555555")
plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup