(self)
return shortest_paths
Calculates all shortest paths between all pairs of 
        higher-order nodes using the Floyd-Warshall algorithm.
Calculates all shortest paths between all pairs of 
        higher-order nodes using the Floyd-Warshall algorithm.
Calculates all shortest paths between all pairs of higher - order nodes using the Floyd - Warshall algorithm .
def getShortestPaths(self):
        """
        Calculates all shortest paths between all pairs of 
        higher-order nodes using the Floyd-Warshall algorithm.
        """
        
        Log.add('Calculating shortest paths in higher-order network (k = ' + str(self.order) + ') ...', Severity.INFO)

        dist = _co.defaultdict( lambda: _co.defaultdict( lambda: _np.inf ) )
        shortest_paths = _co.defaultdict( lambda: _co.defaultdict( lambda: set() ) )

        for e in self.edges:
            dist[e[0]][e[1]] = 1
            shortest_paths[e[0]][e[1]].add(e)
       
        for v in self.nodes:
            for w in self.nodes:
                if v != w:
                    for k in self.nodes:
                        if dist[v][w] > dist[v][k] + dist[k][w]:
                            dist[v][w] = dist[v][k] + dist[k][w]
                            shortest_paths[v][w] = set()
                            for p in list(shortest_paths[v][k]):
                                for q in list(shortest_paths[k][w]):
                                    shortest_paths[v][w].add(p+q[1:])
                        elif dist[v][w] == dist[v][k] + dist[k][w]:
                            for p in list(shortest_paths[v][k]):
                                for q in list(shortest_paths[k][w]):
                                    shortest_paths[v][w].add(p+q[1:])
        
        for v in self.nodes:
            dist[v][v] = 0
            shortest_paths[v][v].add((v,))

        Log.add('finished.', Severity.INFO)

        return shortest_paths
def getShortestPaths ( self ) : Log . add ( 'Calculating shortest paths in higher-order network (k = ' + str ( self . order ) + ') ...' , Severity . INFO ) dist = _co . defaultdict ( lambda : _co . defaultdict ( lambda : _np . inf ) ) shortest_paths = _co . defaultdict ( lambda : _co . defaultdict ( lambda : set ( ) ) ) for e in self . edges : dist [ e [ 0 ] ] [ e [ 1 ] ] = 1 shortest_paths [ e [ 0 ] ] [ e [ 1 ] ] . add ( e ) for v in self . nodes : for w in self . nodes : if v != w : for k in self . nodes : if dist [ v ] [ w ] > dist [ v ] [ k ] + dist [ k ] [ w ] : dist [ v ] [ w ] = dist [ v ] [ k ] + dist [ k ] [ w ] shortest_paths [ v ] [ w ] = set ( ) for p in list ( shortest_paths [ v ] [ k ] ) : for q in list ( shortest_paths [ k ] [ w ] ) : shortest_paths [ v ] [ w ] . add ( p + q [ 1 : ] ) elif dist [ v ] [ w ] == dist [ v ] [ k ] + dist [ k ] [ w ] : for p in list ( shortest_paths [ v ] [ k ] ) : for q in list ( shortest_paths [ k ] [ w ] ) : shortest_paths [ v ] [ w ] . add ( p + q [ 1 : ] ) for v in self . nodes : dist [ v ] [ v ] = 0 shortest_paths [ v ] [ v ] . add ( ( v , ) ) Log . add ( 'finished.' , Severity . INFO ) return shortest_paths