<jupyter_start><jupyter_text>NetworkX Tutorial 1<jupyter_code>import networkx as nx
import matplotlib.pyplot as plt
%matplotlib inline
# Create empty graph
g = nx.Graph()
# Add node
g.add_node(2)
g.add_node(5)

# Add endge
g.add_edge(2,5)
# Add nodes from existing edge
g.add_edge(4,1)
# Add from many to many
g.add_edges_from([(2,5),(1,4)])
# Echo info
print(nx.info(g))
# Draw
nx.draw(g)
plt.show()
# Read edges form file
filename='../src/visualization/links.csv'
h = nx.read_weighted_edgelist(filename, create_using=nx.Graph(), nodetype=str, delimiter=',', comments='#')
print(nx.info(h))
nx.draw(h)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15863141524105753, 'fraction_numerical': 0.017107309486780714, 'mean_word_length': 6.318181818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '531764', 'license': 'Unlicense', 'n_tokens_mistral': 273, 'n_tokens_neox': 265, 'n_words': 56, 'path': 'notebooks/24_0_L_NetworkX_Tutorial.ipynb', 'repo_name': 'luiservela/AstraZeneca', 'size': '643'}