コード例 #1
0
def test_disconnected_triads_mgd_rolling_sum():
    G = nx.Graph()
    # First triad
    G.add_edges_from([(1, 2), (2, 3), (3, 1)])
    # Second triad
    G.add_edges_from([(4, 5), (5, 6), (6, 4)])
    num_distances, sum_distances = ss.all_pairs_shortest_paths_rolling_sum(G)
    assert sum_distances/num_distances == apsp_multi_component_rolling_sum(networkx_to_igraph(G))
コード例 #2
0
def test_three_components_mgd_2():
    G = nx.Graph()
    # First triad
    G.add_edges_from([(1, 2), (2, 3), (3, 1)])
    # Second triad
    G.add_edges_from([(4, 5), (5, 6), (6, 4)])
    G.add_edge(9, 10)
    num_distances, sum_distances = ss.all_pairs_shortest_paths_rolling_sum(G)
    dist = apsp_multi_component(networkx_to_igraph(G))
    assert sum_distances/num_distances == sum([k*v for k, v in dist.items()])/sum([v for _, v in dist.items()])
コード例 #3
0
def test_zkc_mgd():
    G = nx.karate_club_graph()
    num_distances, sum_distances = ss.all_pairs_shortest_paths_rolling_sum(G)
    dist = apsp_multi_component(networkx_to_igraph(G))
    assert sum_distances/num_distances == sum([k*v for k, v in dist.items()])/sum([v for _, v in dist.items()])
コード例 #4
0
def test_zkc_mgd_rolling_sum():
    G = nx.karate_club_graph()
    num_distances, sum_distances = ss.all_pairs_shortest_paths_rolling_sum(G)
    assert sum_distances / num_distances == apsp_multi_component_rolling_sum(networkx_to_igraph(G))