code: def cytoscape_graph(
      dsk,
      filename: str | None = "mydask",
      format: str | None = None,
      *,
      rankdir: str = "BT",
      node_sep: float = 10,
      edge_sep: float = 10,
      spacing_factor: float = 1,
      node_style: dict[str, str] | None = None,
      edge_style: dict[str, str] | None = None,
      **kwargs,
  ):
      """
      Create an ipycytoscape widget for a dask graph.
  
      If `filename` is not None, write an HTML file to disk with the specified name.
  
      This uses the Cytoscape dagre layout algorithm. Options for that are documented here:
      https://github.com/cytoscape/cytoscape.js-dagre#api
  
      Parameters
      ----------
      dsk : dict
          The graph to display.
      filename : str or None, optional
          The name of the HTML file to write to disk.
      format : str, optional
          Not used in this engine.
      rankdir: str
          The direction in which to orient the visualization.
      node_sep: float
          The separation (in px) between nodes in the DAG layout.
      edge_sep: float
          The separation (in px) between edges in the DAG layout.
      spacing_factor: float
          An overall scaling factor to increase (>1) or decrease (<1) the spacing
          of the layout.
      node_style: dict[str, str], optional
          A dictionary of style attributes for nodes (refer to Cytoscape JSON docs
          for available options: https://js.cytoscape.org/#notation/elements-json)
      edge_style: dict[str, str], optional
          A dictionary of style attributes for edges (refer to Cytoscape JSON docs
          for available options: https://js.cytoscape.org/#notation/elements-json)
      **kwargs
          Additional keyword arguments to forward to `_to_cytoscape_json`.
  
      Returns
      -------
      result : ipycytoscape.CytoscapeWidget
      """
      ipycytoscape = import_required(
          "ipycytoscape",
          "Drawing dask graphs with the cytoscape engine requires the `ipycytoscape` "
          "python library.\n\n"
          "Please either conda or pip install as follows:\n\n"
          "  conda install ipycytoscape            # either conda install\n"
          "  python -m pip install ipycytoscape    # or pip install",
      )
  
      node_style = node_style or {}
      edge_style = edge_style or {}
  
      data = _to_cytoscape_json(dsk, **kwargs)
      # TODO: it's not easy to programmatically increase the height of the widget.
      # Ideally we would make it a bit bigger, but that will probably require upstreaming
      # some fixes.
      g = ipycytoscape.CytoscapeWidget(
          layout={"height": "400px"},
      )
      g.set_layout(
          name="dagre",
          rankDir=rankdir,
          nodeSep=node_sep,
          edgeSep=edge_sep,
          spacingFactor=spacing_factor,
          nodeDimensionsIncludeLabels=True,
      )
      g.graph.add_graph_from_json(
          data,
          directed=True,
      )
      g.set_style(
          [
              {
                  "selector": "node",
                  "style": {
                      "font-family": "helvetica",
                      "font-size": "24px",
                      "font-weight": "bold",
                      "color": "black",
                      "background-color": "#eee",
                      "border-color": "data(color)",
                      "border-width": 4,
                      "opacity": "1.0",
                      "text-valign": "center",
                      "text-halign": "center",
                      "label": "data(label)",
                      "shape": "data(shape)",
                      "width": 64,
                      "height": 64,
                      **node_style,
                  },
              },
              {
                  "selector": "edge",
                  "style": {
                      "width": 8,
                      "line-color": "gray",
                      "target-arrow-shape": "triangle",
                      "target-arrow-color": "gray",
                      "curve-style": "bezier",
                      **edge_style,
                  },
              },
          ],
      )
      # Tweak the zoom sensitivity
      z = g.zoom
      g.max_zoom = z * 2.0
      g.min_zoom = z / 10.0
      g.wheel_sensitivity = 0.1
  
      if filename is not None:
          from ipywidgets.embed import embed_minimal_html
  
          filename = (
              filename
              if filename.endswith(".html")
              else filename + ".html"
          )
          embed_minimal_html(
              filename, views=[g], title="Dask task graph"
          )
      return g
  
file_path: dask/dask/dot.py
imports: from __future__ import annotations
  import os
  import re
  from functools import partial
  from dask.core import get_dependencies, ishashable, istask
  from dask.utils import apply, funcname, import_required, key_split
label_desc: Use image node_id 11 for calling a global function with example usage: cytoscape_graph(dsk, filename, format) and returns: g