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

        node_centralities = _co.defaultdict( lambda: 0 )
        shortest_path_lengths = self.getDistanceMatrix()                

        for x in shortest_path_lengths:
            for d in shortest_path_lengths[x]:
                if x != d and shortest_path_lengths[x][d] < _np.inf:
                    node_centralities[x] += 1.0 / shortest_path_lengths[x][d]

        # assign zero values to nodes not occurring
        nodes = self.getNodes()
        for v in nodes:
            node_centralities[v] += 0
       
        if normalized:
            m = max(node_centralities.values())
            for v in nodes:
                node_centralities[v] /= m

        return node_centralities
def ClosenessCentrality ( self , normalized = False ) : node_centralities = _co . defaultdict ( lambda : 0 ) shortest_path_lengths = self . getDistanceMatrix ( ) for x in shortest_path_lengths : for d in shortest_path_lengths [ x ] : if x != d and shortest_path_lengths [ x ] [ d ] < _np . inf : node_centralities [ x ] += 1.0 / shortest_path_lengths [ x ] [ d ] # assign zero values to nodes not occurring nodes = self . getNodes ( ) for v in nodes : node_centralities [ v ] += 0 if normalized : m = max ( node_centralities . values ( ) ) for v in nodes : node_centralities [ v ] /= m return node_centralities