<commit_before>import random

def run(graph, params, setup):
    num_colors = params['colors']
    colors = range(num_colors)
    
    coloring = [random.choice(colors) for _ in graph]
    num_conflicts = num_conflicts_graph(graph, coloring)

    while num_conflicts > 0:
        index = random.randint(0, len(graph) - 1)

        initial_conflicts = num_conflicts_node(graph, index, coloring)
        initial_color = coloring[index]
        min_conflicts = initial_conflicts
        min_conflicts_value = initial_color
        
        for color in colors:
            if color != initial_color:
                coloring[index] = color

                conflicts = num_conflicts_node(graph, index, coloring)
                if conflicts < min_conflicts:
                    min_conflicts = conflicts
                    min_conflicts_value = color

        coloring[index] = min_conflicts_value
        num_conflicts -= initial_conflicts - min_conflicts

    return coloring

def num_conflicts_graph(graph, coloring):
    conflicts = 0
    for from_index, connections in enumerate(graph):
        for to_index in connections:
            if coloring[to_index] == coloring[from_index]:
                conflicts += 1
    conflicts /= 2 # each connection is counted twice
    return conflicts

    
def num_conflicts_node(graph, index, coloring):
    conflicts = 0
    for to_index in graph[index]:
        if coloring[index] == coloring[to_index]:
            conflicts += 1
    return conflicts
<commit_msg>Fix style stuff<commit_after>import random


def run(graph, params, setup):
    num_colors = params['colors']
    colors = range(num_colors)

    coloring = [random.choice(colors) for _ in graph]
    num_conflicts = num_conflicts_graph(graph, coloring)

    while num_conflicts > 0:
        index = random.randint(0, len(graph) - 1)

        initial_conflicts = num_conflicts_node(graph, index, coloring)
        initial_color = coloring[index]
        min_conflicts = initial_conflicts
        min_conflicts_value = initial_color

        for color in colors:
            if color != initial_color:
                coloring[index] = color

                conflicts = num_conflicts_node(graph, index, coloring)
                if conflicts < min_conflicts:
                    min_conflicts = conflicts
                    min_conflicts_value = color

        coloring[index] = min_conflicts_value
        num_conflicts -= initial_conflicts - min_conflicts

    return coloring


def num_conflicts_graph(graph, coloring):
    conflicts = 0
    for from_index, connections in enumerate(graph):
        for to_index in connections:
            if coloring[to_index] == coloring[from_index]:
                conflicts += 1
    conflicts /= 2  # each connection is counted twice
    return conflicts


def num_conflicts_node(graph, index, coloring):
    conflicts = 0
    for to_index in graph[index]:
        if coloring[index] == coloring[to_index]:
            conflicts += 1
    return conflicts

{'fraction_non_alphanumeric': 0.0718801996672213, 'fraction_numerical': 0.005324459234608985, 'mean_word_length': 2.447247706422018, '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}}
{'dir': 'git-commits-cleaned', 'id': '4602285', 'n_tokens_mistral': 901, 'n_tokens_neox': 810, 'n_words': 216}