(self, normalized=False)
return node_centralities
Calculates the betweenness centralities of all nodes.
        If the order of the higher-order network is larger than one 
        centralities calculated based on the higher-order 
        topology will automatically be projected back to first-order 
        nodes.

        @param normalized: If set to True, betweenness centralities of 
            nodes will be scaled by the maximum value (default False)
Calculates the betweenness centralities of all nodes.
        If the order of the higher-order network is larger than one 
        centralities calculated based on the higher-order 
        topology will automatically be projected back to first-order 
        nodes.
Calculates the betweenness centralities of all nodes . If the order of the higher - order network is larger than one centralities calculated based on the higher - order topology will automatically be projected back to first - order nodes .
def BetweennessCentrality(self, normalized=False):
        """ 
        Calculates the betweenness centralities of all nodes.
        If the order of the higher-order network is larger than one 
        centralities calculated based on the higher-order 
        topology will automatically be projected back to first-order 
        nodes.

        @param normalized: If set to True, betweenness centralities of 
            nodes will be scaled by the maximum value (default False)
        """

        shortest_paths = self.getShortestPaths()
        node_centralities = _co.defaultdict( lambda: 0 )

        shortest_paths_firstorder =  _co.defaultdict( lambda:  _co.defaultdict( lambda: set() ) )

        Log.add('Calculating betweenness centralities (k = ' + str(self.order) + ') ...', Severity.INFO)

        for sk in shortest_paths:
            for dk in shortest_paths:
                s1 = self.HigherOrderNodeToPath(sk)[0]
                d1 = self.HigherOrderNodeToPath(dk)[-1]
                
                # we consider a path in a k-th order network 
                # connecting first-order node s1 to d1
                for pk in shortest_paths[sk][dk]:
                     # convert k-th order path to first-order path and add
                    shortest_paths_firstorder[s1][d1].add(self.HigherOrderPathToFirstOrder(pk))


        for s1 in shortest_paths_firstorder:
            for d1 in shortest_paths_firstorder[s1]:                               
                for p1 in shortest_paths_firstorder[s1][d1]:
                    # increase betweenness centrality of all intermediary nodes
                    # on path from s1 to d1
                    for v in p1[1:-1]:
                        if s1 != v != d1:
                            #print('node ' + x + ': ' + str(1.0 / len(shortest_paths[vk][wk])))
                            node_centralities[v] += 1.0 / (len(shortest_paths_firstorder[s1][d1]) + self.order-1)
                            #else:
                            #    node_centralities[v] += 1.0
        if normalized:
            m = max(node_centralities.values())
            for v in node_centralities:
                node_centralities[v] /= m

        # assign centrality zero to nodes not occurring on higher-order shortest paths
        nodes = self.paths.getNodes()
        for v in nodes:
            node_centralities[v] += 0

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

        return node_centralities
def BetweennessCentrality ( self , normalized = False ) : shortest_paths = self . getShortestPaths ( ) node_centralities = _co . defaultdict ( lambda : 0 ) shortest_paths_firstorder = _co . defaultdict ( lambda : _co . defaultdict ( lambda : set ( ) ) ) Log . add ( 'Calculating betweenness centralities (k = ' + str ( self . order ) + ') ...' , Severity . INFO ) for sk in shortest_paths : for dk in shortest_paths : s1 = self . HigherOrderNodeToPath ( sk ) [ 0 ] d1 = self . HigherOrderNodeToPath ( dk ) [ - 1 ] # we consider a path in a k-th order network  # connecting first-order node s1 to d1 for pk in shortest_paths [ sk ] [ dk ] : # convert k-th order path to first-order path and add shortest_paths_firstorder [ s1 ] [ d1 ] . add ( self . HigherOrderPathToFirstOrder ( pk ) ) for s1 in shortest_paths_firstorder : for d1 in shortest_paths_firstorder [ s1 ] : for p1 in shortest_paths_firstorder [ s1 ] [ d1 ] : # increase betweenness centrality of all intermediary nodes # on path from s1 to d1 for v in p1 [ 1 : - 1 ] : if s1 != v != d1 : #print('node ' + x + ': ' + str(1.0 / len(shortest_paths[vk][wk]))) node_centralities [ v ] += 1.0 / ( len ( shortest_paths_firstorder [ s1 ] [ d1 ] ) + self . order - 1 ) #else: #    node_centralities[v] += 1.0 if normalized : m = max ( node_centralities . values ( ) ) for v in node_centralities : node_centralities [ v ] /= m # assign centrality zero to nodes not occurring on higher-order shortest paths nodes = self . paths . getNodes ( ) for v in nodes : node_centralities [ v ] += 0 Log . add ( 'finished.' , Severity . INFO ) return node_centralities