prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  dot_graph does not work in stable version
  I try to generate visual graphs as [described in documentation](http://dask.pydata.org/en/latest/inspect.html), but get:
  `'module' object has no attribute 'to_pydot'`
  
  The graphviz is installed with homebrew. Dask is installed from conda (latest stable release):
  
  ```
  In [15]: dask.__version__
  
  Out[15]: '0.5.0'
  ```
  
  The code and traceback are below (I had to replace `blockshape` with `chunks`, otherwise it did not create task graph):
  
  ``` python
  In [1]: 
  import dask.array as da
  from dask.dot import dot_graph
  In [2]:
  
  x = da.ones((5, 15), chunks=(5, 5))
  In [5]:
  
  d = (x + 1).dask
  In [6]:
  
  dot_graph(d)
  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  <ipython-input-6-c797e633866d> in <module>()
  ----> 1 dot_graph(d)
  
  /Users/koldunov/miniconda/lib/python2.7/site-packages/dask/dot.pyc in dot_graph(d, filename, **kwargs)
       73 def dot_graph(d, filename='mydask', **kwargs):
       74     dg = to_networkx(d, **kwargs)
  ---> 75     write_networkx_to_dot(dg, filename=filename)
       76 
       77 
  
  /Users/koldunov/miniconda/lib/python2.7/site-packages/dask/dot.pyc in write_networkx_to_dot(dg, filename)
       61 def write_networkx_to_dot(dg, filename='mydask'):
       62     import os
  ---> 63     p = nx.to_pydot(dg)
       64     p.set_rankdir('BT')
       65     with open(filename + '.dot', 'w') as f:
  
  AttributeError: 'module' object has no attribute 'to_pydot'
  ```
  
  
  </issue>
  <code>
  [start of dask/dot.py]
  1 from __future__ import absolute_import, division, print_function
  2 
  3 import networkx as nx
  4 from dask.core import istask, get_dependencies
  5 
  6 
  7 def make_hashable(x):
  8     try:
  9         hash(x)
  10         return x
  11     except TypeError:
  12         return hash(str(x))
  13 
  14 
  15 def lower(func):
  16     while hasattr(func, 'func'):
  17         func = func.func
  18     return func
  19 
  20 def name(func):
  21     try:
  22         return lower(func).__name__
  23     except AttributeError:
  24         return 'func'
  25 
  26 
  27 def to_networkx(d, data_attributes=None, function_attributes=None):
  28     if data_attributes is None:
  29         data_attributes = dict()
  30     if function_attributes is None:
  31         function_attributes = dict()
  32 
  33     g = nx.DiGraph()
  34 
  35     for k, v in sorted(d.items(), key=lambda x: x[0]):
  36         g.add_node(k, shape='box', **data_attributes.get(k, dict()))
  37         if istask(v):
  38             func, args = v[0], v[1:]
  39             func_node = make_hashable((v, 'function'))
  40             g.add_node(func_node,
  41                        shape='circle',
  42                        label=name(func),
  43                        **function_attributes.get(k, dict()))
  44             g.add_edge(func_node, k)
  45             for dep in sorted(get_dependencies(d, k)):
  46                 arg2 = make_hashable(dep)
  47                 g.add_node(arg2,
  48                            label=str(dep),
  49                            shape='box',
  50                            **data_attributes.get(dep, dict()))
  51                 g.add_edge(arg2, func_node)
  52         else:
  53             if v not in d:
  54                 g.add_node(k, label='%s=%s' % (k, v), **data_attributes.get(k, dict()))
  55             else:  # alias situation
  56                 g.add_edge(v, k)
  57 
  58     return g
  59 
  60 
  61 def write_networkx_to_dot(dg, filename='mydask'):
  62     import os
  63     p = nx.to_pydot(dg)
  64     p.set_rankdir('BT')
  65     with open(filename + '.dot', 'w') as f:
  66         f.write(p.to_string())
  67 
  68     os.system('dot -Tpdf %s.dot -o %s.pdf' % (filename, filename))
  69     os.system('dot -Tpng %s.dot -o %s.png' % (filename, filename))
  70     print("Writing graph to %s.pdf" % filename)
  71 
  72 
  73 def dot_graph(d, filename='mydask', **kwargs):
  74     dg = to_networkx(d, **kwargs)
  75     write_networkx_to_dot(dg, filename=filename)
  76 
  77 
  78 if __name__ == '__main__':
  79     def add(x, y):
  80         return x + y
  81     def inc(x):
  82         return x + 1
  83 
  84     dsk = {'x': 1, 'y': (inc, 'x'),
  85            'a': 2, 'b': (inc, 'a'),
  86            'z': (add, 'y', 'b')}
  87 
  88     dot_graph(dsk)
  89
  [end of dask/dot.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/dask/dot.py b/dask/dot.py
  --- a/dask/dot.py
  +++ b/dask/dot.py
  @@ -60,7 +60,11 @@
   
   def write_networkx_to_dot(dg, filename='mydask'):
       import os
  -    p = nx.to_pydot(dg)
  +    try:
  +        p = nx.to_pydot(dg)
  +    except AttributeError:
  +        raise ImportError("Can not find pydot module. Please install.\n"
  +                          "    pip install pydot")
       p.set_rankdir('BT')
       with open(filename + '.dot', 'w') as f:
           f.write(p.to_string())
  
verification_info: {"golden_diff": "diff --git a/dask/dot.py b/dask/dot.py\n--- a/dask/dot.py\n+++ b/dask/dot.py\n@@ -60,7 +60,11 @@\n \n def write_networkx_to_dot(dg, filename='mydask'):\n     import os\n-    p = nx.to_pydot(dg)\n+    try:\n+        p = nx.to_pydot(dg)\n+    except AttributeError:\n+        raise ImportError(\"Can not find pydot module. Please install.\\n\"\n+                          \"    pip install pydot\")\n     p.set_rankdir('BT')\n     with open(filename + '.dot', 'w') as f:\n         f.write(p.to_string())\n", "issue": "dot_graph does not work in stable version\nI try to generate visual graphs as [described in documentation](http://dask.pydata.org/en/latest/inspect.html), but get:\n`'module' object has no attribute 'to_pydot'`\n\nThe graphviz is installed with homebrew. Dask is installed from conda (latest stable release):\n\n```\nIn [15]: dask.__version__\n\nOut[15]: '0.5.0'\n```\n\nThe code and traceback are below (I had to replace `blockshape` with `chunks`, otherwise it did not create task graph):\n\n``` python\nIn [1]: \nimport dask.array as da\nfrom dask.dot import dot_graph\nIn [2]:\n\nx = da.ones((5, 15), chunks=(5, 5))\nIn [5]:\n\nd = (x + 1).dask\nIn [6]:\n\ndot_graph(d)\n---------------------------------------------------------------------------\nAttributeError                            Traceback (most recent call last)\n<ipython-input-6-c797e633866d> in <module>()\n----> 1 dot_graph(d)\n\n/Users/koldunov/miniconda/lib/python2.7/site-packages/dask/dot.pyc in dot_graph(d, filename, **kwargs)\n     73 def dot_graph(d, filename='mydask', **kwargs):\n     74     dg = to_networkx(d, **kwargs)\n---> 75     write_networkx_to_dot(dg, filename=filename)\n     76 \n     77 \n\n/Users/koldunov/miniconda/lib/python2.7/site-packages/dask/dot.pyc in write_networkx_to_dot(dg, filename)\n     61 def write_networkx_to_dot(dg, filename='mydask'):\n     62     import os\n---> 63     p = nx.to_pydot(dg)\n     64     p.set_rankdir('BT')\n     65     with open(filename + '.dot', 'w') as f:\n\nAttributeError: 'module' object has no attribute 'to_pydot'\n```\n\n", "before_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport networkx as nx\nfrom dask.core import istask, get_dependencies\n\n\ndef make_hashable(x):\n    try:\n        hash(x)\n        return x\n    except TypeError:\n        return hash(str(x))\n\n\ndef lower(func):\n    while hasattr(func, 'func'):\n        func = func.func\n    return func\n\ndef name(func):\n    try:\n        return lower(func).__name__\n    except AttributeError:\n        return 'func'\n\n\ndef to_networkx(d, data_attributes=None, function_attributes=None):\n    if data_attributes is None:\n        data_attributes = dict()\n    if function_attributes is None:\n        function_attributes = dict()\n\n    g = nx.DiGraph()\n\n    for k, v in sorted(d.items(), key=lambda x: x[0]):\n        g.add_node(k, shape='box', **data_attributes.get(k, dict()))\n        if istask(v):\n            func, args = v[0], v[1:]\n            func_node = make_hashable((v, 'function'))\n            g.add_node(func_node,\n                       shape='circle',\n                       label=name(func),\n                       **function_attributes.get(k, dict()))\n            g.add_edge(func_node, k)\n            for dep in sorted(get_dependencies(d, k)):\n                arg2 = make_hashable(dep)\n                g.add_node(arg2,\n                           label=str(dep),\n                           shape='box',\n                           **data_attributes.get(dep, dict()))\n                g.add_edge(arg2, func_node)\n        else:\n            if v not in d:\n                g.add_node(k, label='%s=%s' % (k, v), **data_attributes.get(k, dict()))\n            else:  # alias situation\n                g.add_edge(v, k)\n\n    return g\n\n\ndef write_networkx_to_dot(dg, filename='mydask'):\n    import os\n    p = nx.to_pydot(dg)\n    p.set_rankdir('BT')\n    with open(filename + '.dot', 'w') as f:\n        f.write(p.to_string())\n\n    os.system('dot -Tpdf %s.dot -o %s.pdf' % (filename, filename))\n    os.system('dot -Tpng %s.dot -o %s.png' % (filename, filename))\n    print(\"Writing graph to %s.pdf\" % filename)\n\n\ndef dot_graph(d, filename='mydask', **kwargs):\n    dg = to_networkx(d, **kwargs)\n    write_networkx_to_dot(dg, filename=filename)\n\n\nif __name__ == '__main__':\n    def add(x, y):\n        return x + y\n    def inc(x):\n        return x + 1\n\n    dsk = {'x': 1, 'y': (inc, 'x'),\n           'a': 2, 'b': (inc, 'a'),\n           'z': (add, 'y', 'b')}\n\n    dot_graph(dsk)\n", "path": "dask/dot.py"}]}