(self)
return shortest_paths
Calculates all observed shortest paths (and subpaths) between 
        all pairs of nodes
Calculates all observed shortest paths (and subpaths) between 
        all pairs of nodes
Calculates all observed shortest paths ( and subpaths ) between all pairs of nodes
def getShortestPaths(self):
        """
        Calculates all observed shortest paths (and subpaths) between 
        all pairs of nodes
        """
        shortest_paths = _co.defaultdict( lambda: _co.defaultdict( lambda: set() ) )
        shortest_path_lengths = _co.defaultdict( lambda: _co.defaultdict( lambda: _np.inf ) )
        
        Log.add('Calculating shortest paths based on empirical paths ...', Severity.INFO)

        for l in self.paths:
            for p in self.paths[l]:
                s = p[0]
                d = p[-1]
                # we found a path of length l from s to d
                if l < shortest_path_lengths[s][d]:
                    shortest_path_lengths[s][d] = l
                    shortest_paths[s][d] = set()
                    shortest_paths[s][d].add(p)
                elif l == shortest_path_lengths[s][d]:
                    shortest_paths[s][d].add(p)

        Log.add('finished.', Severity.INFO)
        
        return shortest_paths
def getShortestPaths ( self ) : shortest_paths = _co . defaultdict ( lambda : _co . defaultdict ( lambda : set ( ) ) ) shortest_path_lengths = _co . defaultdict ( lambda : _co . defaultdict ( lambda : _np . inf ) ) Log . add ( 'Calculating shortest paths based on empirical paths ...' , Severity . INFO ) for l in self . paths : for p in self . paths [ l ] : s = p [ 0 ] d = p [ - 1 ] # we found a path of length l from s to d if l < shortest_path_lengths [ s ] [ d ] : shortest_path_lengths [ s ] [ d ] = l shortest_paths [ s ] [ d ] = set ( ) shortest_paths [ s ] [ d ] . add ( p ) elif l == shortest_path_lengths [ s ] [ d ] : shortest_paths [ s ] [ d ] . add ( p ) Log . add ( 'finished.' , Severity . INFO ) return shortest_paths