code: def _show_mermaid(graph, markdown: bool = False):
      from dvc.repo.graph import get_pipelines
  
      pipelines = get_pipelines(graph)
  
      graph = "flowchart TD"
  
      total_nodes = 0
      for pipeline in pipelines:
          node_ids = {}
          nodes = sorted(str(x) for x in pipeline.nodes)
          for node in nodes:
              total_nodes += 1
              node_id = f"node{total_nodes}"
              graph += f'\n\t{node_id}["{node}"]'
              node_ids[node] = node_id
          edges = sorted((str(a), str(b)) for b, a in pipeline.edges)
          for a, b in edges:
              graph += f"\n\t{node_ids[str(a)]}-->{node_ids[str(b)]}"
  
      if markdown:
          return f"```mermaid\n{graph}\n```"
  
      return graph
  
file_path: dvc/dvc/commands/dag.py
imports: from typing import TYPE_CHECKING
  from dvc.cli import formatter
  from dvc.cli.command import CmdBase
  from dvc.cli.utils import append_doc_link
  from dvc.ui import ui
label_desc: Use image node_id 4 for calling a global function with example usage: _show_mermaid(graph, markdown) and returns: graph, str, graph, str