'Tests that the google_matrix doesn\'t change except for the dangling
nodes.'

def test_dangling_matrix(self):

    G = self.G
    dangling = self.dangling_edges
    dangling_sum = float(sum(dangling.values()))
    M1 = networkx.google_matrix(G, personalization=dangling)
    M2 = networkx.google_matrix(G, personalization=dangling, dangling=dangling)
    for i in range(len(G)):
        for j in range(len(G)):
            if ((i == self.dangling_node_index) and ((j + 1) in dangling)):
                assert_almost_equal(M2[(i, j)], (dangling[(j + 1)] / dangling_sum), places=4)
            else:
                assert_almost_equal(M2[(i, j)], M1[(i, j)], places=4)
