<jupyter_start><jupyter_text>Draw a graphUse the LesMiserables graph with layout copy/pasted from Java.<jupyter_code>%matplotlib inline
import networkx as nx
import matplotlib.pyplot as plt
import io
g = nx.generators.social.les_miserables_graph()
rename = {}
for label in g.nodes:
    rename[label] = label.lower()
g = nx.relabel_nodes(g, rename)
fig, ax = plt.subplots(figsize=(14, 14))
nx.draw(g, ax=ax)
with open('D:/tmp/lesmiserables-xy.txt') as f:
    lxy = ''.join(f.readlines())
buf = io.StringIO(lxy)
buf.seek(0)
force = {}
for line in buf:
    label, x, y = line.strip().split(',')
    x = float(x)
    y = float(y)
    force[label.lower()] = [x, -y]
#     print(line.strip())
fig, ax = plt.subplots(figsize=(14, 14))
nx.draw_networkx_edges(g, force, node_size=42, edge_color='grey', with_labels=False, ax=ax)
nx.draw_networkx_nodes(g, force, node_size=42, node_color='k', with_labels=False, ax=ax)<jupyter_output><empty_output><jupyter_text>Read a graph output by D3 testing<jupyter_code>pos = {}
g = nx.Graph()
with open('D:/tmp/tree-xy.txt') as f:
    for line in f:
        line = line.strip()
#         print(line)
        if line.startswith('-'):
            _, s, t = line.split(',')
            g.add_edge(s, t)
        else:
            label, x, y = line.split(',')
            x = float(x)
            y = float(y)
            g.add_node(label)
            pos[label] = [x, -y]
fig, ax = plt.subplots(figsize=(14, 14))
nx.draw_networkx_edges(g, pos, edge_color='grey', with_labels=False, ax=ax)
nx.draw_networkx_nodes(g, pos, node_size=42, node_color='k', with_labels=False, ax=ax)
fig, ax = plt.subplots(figsize=(14, 14))
nx.draw_networkx_edges(g, pos, edge_color='grey', with_labels=False, ax=ax)
nx.draw_networkx_nodes(g, pos, node_size=42, node_color='k', with_labels=False, ax=ax)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16339869281045752, 'fraction_numerical': 0.014161220043572984, 'mean_word_length': 3.911764705882353, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '363965', 'license': 'Apache-2.0', 'n_tokens_mistral': 741, 'n_tokens_neox': 720, 'n_words': 151, 'path': 'ForceLayout/draw-a-graph.ipynb', 'repo_name': 'algol60/reconst', 'size': '1836'}