def test_closeness_centrality(self):
     c = nx.bipartite_closeness_centrality(self.P4, [1, 3])
     answer = {0: 2.0 / 3, 1: 1.0, 2: 1.0, 3: 2.0 / 3}
     assert_equal(c, answer)
     c = nx.bipartite_closeness_centrality(self.K3, [0, 1, 2])
     answer = {0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0, 5: 1.0}
     assert_equal(c, answer)
     c = nx.bipartite_closeness_centrality(self.C4, [0, 2])
     answer = {0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0}
     assert_equal(c, answer)
 def test_closeness_centrality(self):
     c = nx.bipartite_closeness_centrality(self.P4, [1,3])
     answer = {0: 2.0/3, 1: 1.0, 2: 1.0, 3:2.0/3}
     assert_equal(c, answer)
     c = nx.bipartite_closeness_centrality(self.K3, [0,1,2])
     answer = {0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0, 4: 1.0, 5: 1.0}
     assert_equal(c, answer)
     c = nx.bipartite_closeness_centrality(self.C4, [0,2])
     answer = {0: 1.0, 1: 1.0, 2: 1.0, 3: 1.0}
     assert_equal(c, answer)
 def test_davis_closeness_centrality(self):
     G = self.davis
     clos = nx.bipartite_closeness_centrality(G, self.top_nodes)
     answer = {
         'E8': 0.85,
         'E9': 0.79,
         'E7': 0.73,
         'Nora Fayette': 0.80,
         'Evelyn Jefferson': 0.80,
         'Theresa Anderson': 0.80,
         'E6': 0.69,
         'Sylvia Avondale': 0.77,
         'Laura Mandeville': 0.73,
         'Brenda Rogers': 0.73,
         'Katherina Rogers': 0.73,
         'E5': 0.59,
         'Helen Lloyd': 0.73,
         'E3': 0.56,
         'Ruth DeSand': 0.71,
         'Verne Sanderson': 0.71,
         'E12': 0.56,
         'Myra Liddel': 0.69,
         'E11': 0.54,
         'Eleanor Nye': 0.67,
         'Frances Anderson': 0.67,
         'Pearl Oglethorpe': 0.67,
         'E4': 0.54,
         'Charlotte McDowd': 0.60,
         'E10': 0.55,
         'Olivia Carleton': 0.59,
         'Flora Price': 0.59,
         'E2': 0.52,
         'E1': 0.52,
         'Dorothy Murchison': 0.65,
         'E13': 0.52,
         'E14': 0.52
     }
     for node, value in answer.items():
         assert_almost_equal(value, clos[node], places=2)
 def test_davis_closeness_centrality(self):
     G = self.davis
     clos = nx.bipartite_closeness_centrality(G, self.top_nodes)
     answer = {'E8':0.85,
             'E9':0.79,
             'E7':0.73,
             'Nora Fayette':0.80,
             'Evelyn Jefferson':0.80,
             'Theresa Anderson':0.80,
             'E6':0.69,
             'Sylvia Avondale':0.77,
             'Laura Mandeville':0.73,
             'Brenda Rogers':0.73,
             'Katherina Rogers':0.73,
             'E5':0.59,
             'Helen Lloyd':0.73,
             'E3':0.56,
             'Ruth DeSand':0.71,
             'Verne Sanderson':0.71,
             'E12':0.56,
             'Myra Liddel':0.69,
             'E11':0.54,
             'Eleanor Nye':0.67,
             'Frances Anderson':0.67,
             'Pearl Oglethorpe':0.67,
             'E4':0.54,
             'Charlotte McDowd':0.60,
             'E10':0.55,
             'Olivia Carleton':0.59,
             'Flora Price':0.59,
             'E2':0.52,
             'E1':0.52,
             'Dorothy Murchison':0.65,
             'E13':0.52,
             'E14':0.52}
     for node, value in answer.items():
         assert_almost_equal(value, clos[node], places=2)