<s> from IPython . html import widgets <EOL> from IPython . utils . traitlets import Unicode , CInt , CFloat <EOL> from IPython . display import display , Javascript <EOL> def publish_js ( ) : <EOL> with open ( '<STR_LIT>' , '<STR_LIT:r>' ) as f : <EOL> display ( Javascript ( data = f . read ( ) ) ) <EOL> class ForceDirectedGraphWidget ( widgets . DOMWidget ) : <EOL> _view_name = Unicode ( '<STR_LIT>' , sync = True ) <EOL> width = CInt ( <NUM_LIT> , sync = True ) <EOL> height = CInt ( <NUM_LIT> , sync = True ) <EOL> charge = CFloat ( <NUM_LIT> , sync = True ) <EOL> distance = CInt ( <NUM_LIT> , sync = True ) <EOL> strength = CInt ( <NUM_LIT> , sync = True ) <EOL> def __init__ ( self , eventful_graph , * pargs , ** kwargs ) : <EOL> widgets . DOMWidget . __init__ ( self , * pargs , ** kwargs ) <EOL> self . _eventful_graph = eventful_graph <EOL> self . _send_dict_changes ( eventful_graph . graph , '<STR_LIT>' ) <EOL> self . _send_dict_changes ( eventful_graph . node , '<STR_LIT>' ) <EOL> self . _send_dict_changes ( eventful_graph . adj , '<STR_LIT>' ) <EOL> def _ipython_display_ ( self , * pargs , ** kwargs ) : <EOL> widgets . DOMWidget . _ipython_display_ ( self , * pargs , ** kwargs ) <EOL> for ( key , value ) in self . _eventful_graph . graph . items ( ) : <EOL> self . send ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key , '<STR_LIT:value>' : value } ) <EOL> for ( key , value ) in self . _eventful_graph . node . items ( ) : <EOL> self . send ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key , '<STR_LIT:value>' : value } ) <EOL> for ( key , value ) in self . _eventful_graph . adj . items ( ) : <EOL> self . send ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key , '<STR_LIT:value>' : value } ) <EOL> def _send_dict_changes ( self , eventful_dict , dict_name ) : <EOL> def key_add ( key , value ) : <EOL> self . send ( { '<STR_LIT>' : dict_name , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key , '<STR_LIT:value>' : value } ) <EOL> def key_set ( key , value ) : <EOL> self . send ( { '<STR_LIT>' : dict_name , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key , '<STR_LIT:value>' : value } ) <EOL> def key_del ( key ) : <EOL> self . send ( { '<STR_LIT>' : dict_name , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT:key>' : key } ) <EOL> eventful_dict . on_add ( key_add ) <EOL> eventful_dict . on_set ( key_set ) <EOL> eventful_dict . on_del ( key_del ) </s>
