<s> import json <EOL> from nose . tools import assert_equal , assert_raises , assert_not_equal , assert_true <EOL> import networkx as nx <EOL> from networkx . readwrite . json_graph import * <EOL> class TestTree : <EOL> def test_graph ( self ) : <EOL> G = nx . DiGraph ( ) <EOL> G . add_nodes_from ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , color = '<STR_LIT>' ) <EOL> G . add_edge ( <NUM_LIT:1> , <NUM_LIT:2> , foo = <NUM_LIT:7> ) <EOL> G . add_edge ( <NUM_LIT:1> , <NUM_LIT:3> , foo = <NUM_LIT:10> ) <EOL> G . add_edge ( <NUM_LIT:3> , <NUM_LIT:4> , foo = <NUM_LIT:10> ) <EOL> H = tree_graph ( tree_data ( G , <NUM_LIT:1> ) ) <EOL> nx . is_isomorphic ( G , H ) <EOL> def test_graph_attributes ( self ) : <EOL> G = nx . DiGraph ( ) <EOL> G . add_nodes_from ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] , color = '<STR_LIT>' ) <EOL> G . add_edge ( <NUM_LIT:1> , <NUM_LIT:2> , foo = <NUM_LIT:7> ) <EOL> G . add_edge ( <NUM_LIT:1> , <NUM_LIT:3> , foo = <NUM_LIT:10> ) <EOL> G . add_edge ( <NUM_LIT:3> , <NUM_LIT:4> , foo = <NUM_LIT:10> ) <EOL> H = tree_graph ( tree_data ( G , <NUM_LIT:1> ) ) <EOL> assert_equal ( H . node [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> d = json . dumps ( tree_data ( G , <NUM_LIT:1> ) ) <EOL> H = tree_graph ( json . loads ( d ) ) <EOL> assert_equal ( H . node [ <NUM_LIT:1> ] [ '<STR_LIT>' ] , '<STR_LIT>' ) </s>
