class_docstr: Controls the setup and execution of a pipeline of processes.
class_docstr_tok: ["Controls","the","setup","and","execution","of","a","pipeline","of","processes","."]
docstr: Generates a graphviz dot file and a png file
  
  Parameters
  ----------
  
  graph2use: 'orig', 'hierarchical' (default), 'flat', 'exec', 'colored'
      orig - creates a top level graph without expanding internal
      workflow nodes;
      flat - expands workflow nodes recursively;
      hierarchical - expands workflow nodes recursively with a
      notion on hierarchy;
      colored - expands workflow nodes recursively with a
      notion on hierarchy in color;
      exec - expands workflows to depict iterables
  
  format: 'png', 'svg'
  
  simple_form: boolean (default: True)
      Determines if the node name used in the graph should be of the form
      'nodename (package)' when True or 'nodename.Class.package' when
      False.
docstr_tok: ["Generates","a","graphviz","dot","file","and","a","png","file","Parameters","--","--","--","--","--","graph2use",":","'orig","'",",","'hierarchical","'","(","default",")",",","'flat","'",",","'exec","'",",","'colored'","orig","-","creates","a","top","level","graph","without","expanding","internal","workflow","nodes",";","flat","-","expands","workflow","nodes","recursively",";","hierarchical","-","expands","workflow","nodes","recursively","with","a","notion","on","hierarchy",";","colored","-","expands","workflow","nodes","recursively","with","a","notion","on","hierarchy","in","color",";","exec","-","expands","workflows","to","depict","iterables","format",":","'png","'",",","'svg'","simple_form",":","boolean","(","default",":","True",")","Determines","if","the","node","name","used","in","the","graph","should","be","of","the","form","'nodename","(","package",")","'","when","True","or","'nodename.Class.package","'","when","False","."]
code: def write_graph(
      self,
      dotfilename="graph.dot",
      graph2use="hierarchical",
      format="png",
      simple_form=True,
  ):
      """Generates a graphviz dot file and a png file
  
      Parameters
      ----------
  
      graph2use: 'orig', 'hierarchical' (default), 'flat', 'exec', 'colored'
          orig - creates a top level graph without expanding internal
          workflow nodes;
          flat - expands workflow nodes recursively;
          hierarchical - expands workflow nodes recursively with a
          notion on hierarchy;
          colored - expands workflow nodes recursively with a
          notion on hierarchy in color;
          exec - expands workflows to depict iterables
  
      format: 'png', 'svg'
  
      simple_form: boolean (default: True)
          Determines if the node name used in the graph should be of the form
          'nodename (package)' when True or 'nodename.Class.package' when
          False.
  
      """
      graphtypes = ["orig", "flat", "hierarchical", "exec", "colored"]
      if graph2use not in graphtypes:
          raise ValueError(
              "Unknown graph2use keyword. Must be one of: "
              + str(graphtypes)
          )
      base_dir, dotfilename = op.split(dotfilename)
      if base_dir == "":
          if self.base_dir:
              base_dir = self.base_dir
              if self.name:
                  base_dir = op.join(base_dir, self.name)
          else:
              base_dir = os.getcwd()
      os.makedirs(base_dir, exist_ok=True)
      if graph2use in ["hierarchical", "colored"]:
          if self.name[:1].isdigit():  # these graphs break if int
              raise ValueError(
                  "{} graph failed, workflow name cannot begin "
                  "with a number".format(graph2use)
              )
          dotfilename = op.join(base_dir, dotfilename)
          self.write_hierarchical_dotfile(
              dotfilename=dotfilename,
              colored=graph2use == "colored",
              simple_form=simple_form,
          )
          outfname = format_dot(dotfilename, format=format)
      else:
          graph = self._graph
          if graph2use in ["flat", "exec"]:
              graph = self._create_flat_graph()
          if graph2use == "exec":
              graph = generate_expanded_graph(deepcopy(graph))
          outfname = export_graph(
              graph,
              base_dir,
              dotfilename=dotfilename,
              format=format,
              simple_form=simple_form,
          )
  
      logger.info(
          "Generated workflow graph: %s (graph2use=%s, simple_form=%s)."
          % (outfname, graph2use, simple_form)
      )
      return outfname
  
imports: import os
  import os.path
  import sys
  from datetime import datetime
  from copy import deepcopy
  import pickle
  import shutil
  import numpy
  from ...None import config, logging
  from ...utils.misc import str2bool
  from ...utils.functions import getsource, create_function_from_source
  from ...interfaces.base import traits, TraitedSpec, TraitDictObject, TraitListObject
  from ...utils.filemanip import save_json
  from .utils import generate_expanded_graph, export_graph, write_workflow_prov, write_workflow_resources, format_dot, topological_sort, get_print_name, merge_dict, format_node
  from .base import EngineBase
  from .nodes import MapNode
label_desc: Use image node_id 11 for calling the Workflow obj's underlying member method code with example usage: obj.write_graph(dotfilename, graph2use, format, simple_form) and returns: outfname