Exemple #1
0
 def test_AdamicAdar_2(self):
     ""
     # Test the AdamicAdar score of two nodes
     node_1 = "g3"
     node_2 = "p3"
     # neighbors of "g3" = {g1}, neighbors of "p3" = {p1}. The intersection is {}.
     # The score =0
     score = link_prediction_functions.AdamicAdar(self.g, node_1, node_2)
     self.assertAlmostEqual(0, score)
Exemple #2
0
 def test_AdamicAdar_3(self):
     ""
     # Test the AdamicAdar score of two nodes
     node_1 = "g3"
     node_2 = "g4"
     # neighbors of "g3" = {g1}, neighbors of "g4" = {g1}. The intersection is {g1}.
     #neighbours of g1 = {g0, g2, ..., g100, p1,d1}. Score = 1/ log(102)
     score = link_prediction_functions.AdamicAdar(self.g, node_1, node_2)
     self.assertAlmostEqual(1.0 / np.log(102.0), score)
Exemple #3
0
 def test_AdamicAdar_2(self):
     ""
     # Test the AdamicAdar score of two nodes
     node_1 = "g4"
     node_2 = "d1"
     # neighbors of "g4" = {g1,g3,p4,d2}, neighbors of "d1" = {d1,d2, g3}. The intersection is {d2,g3}.
     # #Neighbors of d2 = {g4,d3,d1}, neighbors of g3 = {g1,g2,g4,d1,p3}
     # The score = (1/log 3) + (1/ log 5) = (1/1.098) + (1/ 1.609) =  0.910+ 0.621 = 1.531
     score = link_prediction_functions.AdamicAdar(self.g, node_1, node_2)
     self.assertAlmostEqual((1.0 / np.log(3)) + (1.0 / np.log(5)), score)
Exemple #4
0
 def test_AdamicAdar_1(self):
     ""
     # Test the AdamicAdar score of two nodes
     node_1 = "g1"
     node_2 = "g2"
     # neighbors of "g1" = {g2,g3,g4,p1,d3}, neighbors of "g2" = {g1,g3,p1,p3}. The intersection = {g3, p1}.
     #Neighbors of g3 = {g1,g2,g4,p3,d1}, neighbors of p1 = {g1,g2,p2,p3}
     # The score = (1/log 5) + (1/ log 4) = (1/1.609) + (1/ 1.386) = 0.621 + 0.721 = 1.342
     score = link_prediction_functions.AdamicAdar(self.g, node_1, node_2)
     self.assertAlmostEqual((1.0 / np.log(5)) + (1.0 / np.log(4)), score)
Exemple #5
0
 def test_AdamicAdar_1(self):
     ""
     # Test the AdamicAdar score of two nodes
     node_1 = "g1"
     node_2 = "d2"
     # neighbors of "g1" = {g0,g2,g3,...,g100,p1,d1}, neighbors of "d2" = {d1}.
     # The intersection is d1.
     # #Neighbors of d1 = {g1,d2,..,d20},
     # The score = (1/log 20) = 0.333
     score = link_prediction_functions.AdamicAdar(self.g, node_1, node_2)
     self.assertAlmostEqual(1.0 / np.log(20), score)