<s> from graph import Graph <EOL> def build_graph ( sequence ) : <EOL> graph = Graph ( ) <EOL> for item in sequence : <EOL> if not graph . has_node ( item ) : <EOL> graph . add_node ( item ) <EOL> return graph <EOL> def remove_unreachable_nodes ( graph ) : <EOL> for node in graph . nodes ( ) : <EOL> if sum ( graph . edge_weight ( ( node , other ) ) for other in graph . neighbors ( node ) ) == <NUM_LIT:0> : <EOL> graph . del_node ( node ) </s>
