Example #1
0
    def test_exp_map_graph3(self):
        G = nx.complete_graph(5)
        a = [1, 1, 1, 0, 0]
        for node in G.nodes():
            G.nodes[node]['A'] = a[node]

        npt.assert_equal([2, 2, 2, 3, 3], exp_map(G, 'A'))
Example #2
0
    def test_exp_map_graph2(self):
        G = nx.star_graph(4)
        a = [1, 1, 0, 0, 0]
        for node in G.nodes():
            G.nodes[node]['A'] = a[node]

        npt.assert_equal([1, 1, 1, 1, 1], exp_map(G, 'A'))
Example #3
0
    def test_exp_map_directed(self):
        G = nx.DiGraph()
        G.add_edges_from([(0, 1), (0, 2), (0, 3), (0, 4)])
        a = [1, 0, 1, 1, 1]
        for node in G.nodes():
            G.nodes[node]['A'] = a[node]

        npt.assert_equal([3, 0, 0, 0, 0], exp_map(G, 'A'))
Example #4
0
    def test_fast_exp_map_graph3(self):
        G = nx.complete_graph(5)
        a = [1, 1, 1, 0, 0]
        for node in G.nodes():
            G.nodes[node]['A'] = a[node]

        npt.assert_equal(
            fast_exp_map(nx.adjacency_matrix(G, weight=None),
                         np.array(a),
                         measure='sum'), exp_map(G, 'A'))
Example #5
0
    def test_fast_exp_map_directed(self):
        G = nx.DiGraph()
        G.add_edges_from([(0, 1), (0, 2), (0, 3), (0, 4)])
        a = [1, 0, 1, 1, 1]
        for node in G.nodes():
            G.nodes[node]['A'] = a[node]

        npt.assert_equal(
            fast_exp_map(nx.adjacency_matrix(G, weight=None),
                         np.array(a),
                         measure='sum'), exp_map(G, 'A'))