<commit_before>import numpy as np

def import_net(file_name):
    """ Import CSV file in the competition format
        Output graph as adjacency list and a set with all nodes """

    print(file_name)
    mt = np.genfromtxt(file_name + '.csv',delimiter=',').astype(np.int32)

    # create adjacency list
    network = {}
    for row in mt:
        source = row[0]
        target = row[1]
        if source not in network:
            network[source] = set()
        network[source].add(target)
        
    print("Nodes with outgoing edges: ", len(network))

    # create set of nods, including nodes without outgoing edges
    all_nodes = set(mt.flatten())
    print("All nodes: ", len(all_nodes))

    return network, all_nodes

def exportGML_net(adjaceny_network, all_nodes, file_out):
    f = open(file_out,'w')
    f.write("graph [\n");
    for node in all_nodes:
        f.write("\tnode [\n");
        f.write("\t\tid " + str(node) + "\n");
        f.write("\t]\n");
    f.write("]\n");

def export_net(results, network_name, file_out, first=True):
    """ Export to format required by competition 
        Required: optimize/clean last if, redundancy """

    if first:
        f = open(file_out, 'w')
<commit_msg>TODO: inserir arestas no GML, nao vou ter como fazer agora, voltando pra casa termino<commit_after>import numpy as np

def import_net(file_name):
    """ Import CSV file in the competition format
        Output graph as adjacency list and a set with all nodes """

    print(file_name)
    mt = np.genfromtxt(file_name + '.csv',delimiter=',').astype(np.int32)

    # create adjacency list
    network = {}
    for row in mt:
        source = row[0]
        target = row[1]
        if source not in network:
            network[source] = set()
        network[source].add(target)
        
    print("Nodes with outgoing edges: ", len(network))

    # create set of nods, including nodes without outgoing edges
    all_nodes = set(mt.flatten())
    print("All nodes: ", len(all_nodes))

    return network, all_nodes

def exportGML_net(adjaceny_network, all_nodes, file_out):
    f = open(file_out,'w')
    f.write("graph [\n");
    #INSERIR TODOS OS NOS EM GML
    for node in all_nodes:
        f.write("\tnode [\n");
        f.write("\t\tid " + str(node) + "\n");
        f.write("\t]\n");
    #INSERIR TODAS AS ARESTAS EM GML
    f.write("]\n");

def export_net(results, network_name, file_out, first=True):
    """ Export to format required by competition 
        Required: optimize/clean last if, redundancy """

    if first:
        f = open(file_out, 'w')

{'fraction_non_alphanumeric': 0.12722351121423048, 'fraction_numerical': 0.0030935808197989174, 'mean_word_length': 2.7223021582733815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1273197', 'n_tokens_mistral': 847, 'n_tokens_neox': 810, 'n_words': 246}