<commit_before><commit_msg>Floyd warshall algorithm in python<commit_after># Given a graph (adjacency matrix) calculates the minimum distance between each vertex pair
from collections import defaultdict

INF = 999999999


class Graph:
    def __init__(self, vertices, directed=True):
        self.graph = defaultdict(list)
        self.V = vertices
        self.directed = directed
        for i in range(self.V):
            self.graph[i] = [INF] * self.V
            self.add_edge(i, i, 0)

    def add_edge(self, u, v, distance):
        self.graph[u][v] = distance
        if not self.directed:
            self.graph[v][u] = distance

    def solve(self):
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    if self.graph[i][k] + self.graph[k][j] < self.graph[i][j]:
                        self.graph[i][j] = self.graph[i][k] + self.graph[k][j]

    def print_matrix(self):
        for i in range(self.V):
            print(self.graph[i])


g = Graph(4)
g.add_edge(0, 3, 10)
g.add_edge(2, 3, 1)
g.add_edge(0, 1, 5)
g.add_edge(1, 2, 3)
g.add_edge(3, 1, 7)
g.add_edge(2, 0, 9)

g.solve()

g.print_matrix()

{'fraction_non_alphanumeric': 0.13743676222596965, 'fraction_numerical': 0.025295109612141653, 'mean_word_length': 2.2880886426592797, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '3926474', 'n_tokens_mistral': 448, 'n_tokens_neox': 411, 'n_words': 108}