'Tests that node contraction preserves node attributes.'

def test_node_attributes(self):

    G = nx.cycle_graph(4)
    G.node[0]['foo'] = 'bar'
    G.node[1]['baz'] = 'xyzzy'
    actual = nx.contracted_nodes(G, 0, 1)
    expected = nx.complete_graph(3)
    expected = nx.relabel_nodes(expected, {1: 2, 2: 3})
    expected.add_edge(0, 0)
    cdict = {1: {'baz': 'xyzzy'}}
    expected.node[0].update(dict(foo='bar', contraction=cdict))
    assert_true(nx.is_isomorphic(actual, expected))
    assert_equal(actual.node, expected.node)
