Exemple #1
0
 def test_simrank_numpy_no_source_no_target(self):
     G = nx.cycle_graph(5)
     expected = numpy.array([[
         1.0, 0.3947180735764555, 0.570482097206368, 0.570482097206368,
         0.3947180735764555
     ],
                             [
                                 0.3947180735764555, 1.0,
                                 0.3947180735764555, 0.570482097206368,
                                 0.570482097206368
                             ],
                             [
                                 0.570482097206368, 0.3947180735764555, 1.0,
                                 0.3947180735764555, 0.570482097206368
                             ],
                             [
                                 0.570482097206368, 0.570482097206368,
                                 0.3947180735764555, 1.0, 0.3947180735764555
                             ],
                             [
                                 0.3947180735764555, 0.570482097206368,
                                 0.570482097206368, 0.3947180735764555, 1.0
                             ]])
     actual = nx.simrank_similarity_numpy(G)
     numpy.testing.assert_allclose(expected, actual, atol=1e-7)
Exemple #2
0
 def test_simrank_numpy_source_no_target(self):
     G = nx.cycle_graph(5)
     expected = numpy.array(
         [1.0, 0.3947180735764555, 0.570482097206368, 0.570482097206368, 0.3947180735764555],
     )
     actual = nx.simrank_similarity_numpy(G, source=0)
     numpy.testing.assert_allclose(expected, actual, atol=1e-7)
Exemple #3
0
def CoSimRankNumpy(G,
                   src=0,
                   ngh=1,
                   importance_factor=0.85,
                   max_iterations=100,
                   tolerance=0.0001):
    print("Start SimRankNumpy")
    t0 = time.time()
    similarity = nx.simrank_similarity_numpy(
        G,
        source=src,
        target=ngh,
        importance_factor=importance_factor,
        max_iterations=max_iterations,
        tolerance=tolerance)
    t1 = time.time()
    print("Time: ", t1 - t0)
    print("Similarity: ", similarity)
Exemple #4
0
 def test_simrank_numpy_source_and_target(self):
     G = nx.cycle_graph(5)
     expected = 1.0
     actual = nx.simrank_similarity_numpy(G, source=0, target=0)
     numpy.testing.assert_allclose(expected, actual, atol=1e-7)
Exemple #5
0
 def test_simrank_numpy_source_and_target(self):
     G = nx.cycle_graph(5)
     expected = 1.0
     actual = nx.simrank_similarity_numpy(G, source=0, target=0)
     numpy.testing.assert_allclose(expected, actual, atol=1e-7)