text: import json
  
  import dash
  import dash_cytoscape as cyto
  import dash_html_components as html
  import dash_core_components as dcc
  from dash.dependencies import Input, Output
  
  app = dash.Dash(__name__)
  
  styles = {
      'pre': {
          'border': 'thin lightgrey solid',
          'overflowX': 'scroll'
      }
  }
  
  
  nodes = [
      {
          'data': {'id': short, 'label': label},
          'position': {'x': 20*lat, 'y': -20*long}
      }
      for short, label, long, lat in (
          ('la', 'Los Angeles', 34.03, -118.25),
          ('nyc', 'New York', 40.71, -74),
          ('to', 'Toronto', 43.65, -79.38),
          ('mtl', 'Montreal', 45.50, -73.57),
          ('van', 'Vancouver', 49.28, -123.12),
          ('chi', 'Chicago', 41.88, -87.63),
          ('bos', 'Boston', 42.36, -71.06),
          ('hou', 'Houston', 29.76, -95.37)
      )
  ]
  
  edges = [
      {'data': {'source': source, 'target': target}}
      for source, target in (
          ('van', 'la'),
          ('la', 'chi'),
          ('hou', 'chi'),
          ('to', 'mtl'),
          ('mtl', 'bos'),
          ('nyc', 'bos'),
          ('to', 'hou'),
          ('to', 'nyc'),
          ('la', 'nyc'),
          ('nyc', 'bos')
      )
  ]
  
  
  default_stylesheet = [
      {
          'selector': 'node',
          'style': {
              'background-color': '#BFD7B5',
              'label': 'data(label)'
          }
      }
  ]
  
  
  app.layout = html.Div([
      cyto.Cytoscape(
          id='cytoscape-event-callbacks-3',
          layout={'name': 'preset'},
          elements=edges+nodes,
          stylesheet=default_stylesheet,
          style={'width': '100%', 'height': '450px'}
      ),
      dcc.Markdown(id='cytoscape-selectedNodeData-markdown')
  ])
  
  
  @app.callback(Output('cytoscape-selectedNodeData-markdown', 'children'),
                [Input('cytoscape-event-callbacks-3', 'selectedNodeData')])
  def displaySelectedNodeData(data_list):
      if data_list is None:
          return "No city selected."
  
      cities_list = [data['label'] for data in data_list]
      return "You selected the following cities: " + "\n* ".join(cities_list)
  
  
  if __name__ == '__main__':
      app.run_server(debug=True)
  