(self, normalized=False)
return node_centralities
Calculates the betweenness centrality of nodes based on
        observed shortest paths between all pairs of nodes
Calculates the betweenness centrality of nodes based on
        observed shortest paths between all pairs of nodes
Calculates the betweenness centrality of nodes based on observed shortest paths between all pairs of nodes
def BetweennessCentrality(self, normalized=False):
        """
        Calculates the betweenness centrality of nodes based on
        observed shortest paths between all pairs of nodes
        """

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

        for s in shortest_paths:
            for d in shortest_paths[s]:
                for p in shortest_paths[s][d]:
                    for x in p[1:-1]:
                        if s != d != x:
                            # print('node ' + x + ': ' + str(1.0 / len(shortest_paths[start][end])))                            
                            node_centralities[x] += 1.0 / len(shortest_paths[s][d])
                            # node_centralities[x] += 1.0
        if normalized:
            m = max(node_centralities.values())
            for v in node_centralities:
                node_centralities[v] /= m

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

        return node_centralities
def BetweennessCentrality ( self , normalized = False ) : node_centralities = _co . defaultdict ( lambda : 0 ) shortest_paths = self . getShortestPaths ( ) for s in shortest_paths : for d in shortest_paths [ s ] : for p in shortest_paths [ s ] [ d ] : for x in p [ 1 : - 1 ] : if s != d != x : # print('node ' + x + ': ' + str(1.0 / len(shortest_paths[start][end])))                             node_centralities [ x ] += 1.0 / len ( shortest_paths [ s ] [ d ] ) # node_centralities[x] += 1.0 if normalized : m = max ( node_centralities . values ( ) ) for v in node_centralities : node_centralities [ v ] /= m # assign zero values to nodes not occurring on shortest paths nodes = self . getNodes ( ) for v in nodes : node_centralities [ v ] += 0 return node_centralities