<commit_before>#!/usr/bin/env python
"""
Generate a graph with weight.
Draw a graph with matplotlib.
You must have matplotlib for this to work.
"""
__author__ = """<NAME> (<EMAIL>)"""

import networkx as nx
import numpy as np
try:
    import matplotlib.pyplot as plt
except:
    raise

def generate_graph(id):
    strid = str(id)
    num = [int(i) for i in strid]
    G = nx.Graph(id=strid)
    for i in xrange(len(strid)):
        size = num[i]
        if size:
            randnums = np.random.random_integers(0, 9, size=size)
            for r in randnums:
                G.add_edge(i,r,weight=np.random.randint(1,100))
    return G

def draw(G):
    #pos=nx.spring_layout(G) # positions for all nodes
    pos = nx.random_layout(G)
    
    # nodes
    nx.draw_networkx_nodes(G,pos,node_size=600,alpha=0.8)

    # edges
    nx.draw_networkx_edges(G,pos,width=3,alpha=0.5,edge_color='b')

    # labels
    nx.draw_networkx_labels(G,pos,font_size=20,font_family='sans-serif')
    
    plt.axis('off')
    plt.show()<commit_msg>Add weight labels<commit_after>#!/usr/bin/env python
"""
Generate a graph with weight.
Draw a graph with matplotlib.
You must have matplotlib for this to work.
"""
__author__ = """<NAME> (<EMAIL>)"""

import networkx as nx
import numpy as np
try:
    import matplotlib.pyplot as plt
except:
    raise

def generate_graph(id):
    strid = str(id)
    num = [int(i) for i in strid]
    G = nx.Graph(id=strid)
    for i in xrange(len(strid)):
        size = num[i]
        if size:
            randnums = np.random.random_integers(0, 9, size=size)
            for r in randnums:
                G.add_edge(i,r,weight=np.random.randint(1,100))
    return G

def draw(G):
    #pos=nx.spring_layout(G) # positions for all nodes
    pos = nx.random_layout(G)
    
    # nodes
    nx.draw_networkx_nodes(G,pos,node_size=600,alpha=0.8)
    
    # edges
    #nx.draw_networkx_edges(G,pos,width=3,alpha=0.5,edge_color='b')
    nx.draw_networkx_edges(G,pos)
    
    # labels
    nx.draw_networkx_labels(G,pos,font_size=20,font_family='sans-serif')

    # specifiy edge labels explicitly
    edge_weight=dict([((u,v,),int(d['weight'])) for u,v,d in G.edges(data=True)])
    nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_weight)
    
    plt.axis('off')
    plt.show()
{'fraction_non_alphanumeric': 0.13362445414847163, 'fraction_numerical': 0.013973799126637555, 'mean_word_length': 3.069271758436945, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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}}
{'dir': 'git-commits-cleaned', 'id': '7494474', 'n_tokens_mistral': 893, 'n_tokens_neox': 866, 'n_words': 184}