code: def print_dot(docgraph):
      
      stripped_graph = preprocess_for_pydot(docgraph)
      return nx.drawing.nx_pydot.to_pydot(stripped_graph).to_string()
docs: converts a document graph into a dot file and returns it as a string.
  
      If this function call is prepended by %dotstr,
      it will display the given document graph as a dot/graphviz graph
      in the currently running IPython notebook session.
  
      To use this function, the gvmagic IPython notebook extension
      needs to be installed once::
  
          %install_ext https://raw.github.com/cjdrake/ipython-magic/master/gvmagic.py
  
      In order to visualize dot graphs in your currently running
      IPython notebook, run this command once::
  
          %load_ext gvmagic