def closeness_centrality(G, u=None, distance=None, wf_improved=True): @context_to_dict @project_to_simple def _closeness_centrality(G, weight=None, wf_improved=True): return AppAssets(algo="closeness_centrality", context="vertex_data")(G, wf_improved) if u is not None: # forward return nxa.closeness_centrality(G, u, distance, wf_improved) return _closeness_centrality(G, weight=distance, wf_improved=wf_improved)
def closeness_sum(self,h1,h2): G = self._graph c_h1 = nxa.closeness_centrality(G,h1) c_h2 = nxa.closeness_centrality(G,h2) return c_h1 + c_h2
def closeness_difference(self,h1,h2): G = self._graph c_h1 = nxa.closeness_centrality(G,h1) c_h2 = nxa.closeness_centrality(G,h2) return abs(c_h1 - c_h2)
def getClosenessCentrality(self, G): return nalgos.closeness_centrality(G)
def closeness_sum(self, h1, h2): G = self._graph c_h1 = nxa.closeness_centrality(G, h1) c_h2 = nxa.closeness_centrality(G, h2) return c_h1 + c_h2
def closeness_difference(self, h1, h2): G = self._graph c_h1 = nxa.closeness_centrality(G, h1) c_h2 = nxa.closeness_centrality(G, h2) return abs(c_h1 - c_h2)