def reachability(self):
        """ Idea: graph reachability floyd-warshall
            for k in (0, n):
                for i in (0, n):
                    for j in (0, n):
                    g[i][j] = graph[i][j] || (graph[i][k]&&graph[k][j]))
        """
        vertices = self.v.keys()
        d =  self.adj(float('0'))
        for u in vertices:
            for v in vertices:
                if u ==v or d[u][v]: d[u][v] = True
                else: d[u][v] = False
        for v2 in vertices:
            d = {v1: {v3: d[v1][v3] or (d[v1][v2] and d[v2][v3]) # path for v1->v3 or v1->v2, v2-?v3
                     for v3 in vertices}
                 for v1 in vertices}
        return d
 Idea: graph reachability floyd-warshall
            for k in (0, n):
                for i in (0, n):
                    for j in (0, n):
                    g[i][j] = graph[i][j] || (graph[i][k]&&graph[k][j]))
        
recipes/Python/579141_Simple_Graph_library/recipe-579141.py