code: def common_trunk_tree_to_digraph(root: dict):
      """
      returns a networkx digraph from the common trunk tree dictionary (jst).
      Args:
          root: joint surrogate tree structure (a dictionary)
  
      Returns:
          T: a networkx digraph representation of the same jst
      """
  
      T = nx.DiGraph()
      color1 = "lightpink"  # node color for tree1
      color2 = "lightsalmon"  # node color for tree2
  
      leaf_colors = [
          "antiquewhite",
          "lightcyan",
          "grey70",
          "antiquewhite3",
          "aquamarine",
          "floralwhite",
      ]  # assume max 6 classes
  
      def _recurse(
          root, parentid, direction, style="", fillcolor="lightgrey"
      ):
          vnum = T.number_of_nodes()
  
          is_diverging = "tree1" in root
  
          if is_diverging:
              # separate trees
              T.add_node(vnum, shape="point")
  
              _recurse(
                  root["tree1"],
                  vnum,
                  "1",
                  style="filled",
                  fillcolor=color1,
              )
              _recurse(
                  root["tree2"],
                  vnum,
                  "2",
                  style="filled",
                  fillcolor=color2,
              )
  
          else:
              # common part
              if "cutoff" in root:
                  # split node
                  label = "{}({}) < {}".format(
                      root["col"],
                      root["index_col"],
                      np.around(root["cutoff"], 4),
                  )
                  # print(label)
                  T.add_node(
                      vnum,
                      label=label,
                      style=style,
                      fillcolor=fillcolor,
                  )
  
                  if "left" in root:
                      _recurse(
                          root["left"], vnum, "L", style, fillcolor
                      )
                      _recurse(
                          root["right"], vnum, "R", style, fillcolor
                      )
  
              else:
                  # leaf node
                  label = "label={}\n#samples={}".format(
                      root["val"], root["dist"]
                  )
                  T.add_node(
                      vnum,
                      label=label,
                      pred=root["val"],
                      shape="box",
                      style="filled",
                      fillcolor=leaf_colors[root["val"]],
                  )
  
          if parentid is not None:
              if direction in ["1", "2"]:
                  # this is where the trees diverge
                  T.add_edge(
                      parentid, vnum, label=direction, style="dashed"
                  )
              else:
                  # regular left-right edge
                  T.add_edge(parentid, vnum, label=direction)
  
      _recurse(root, None, None)
      return T
  
file_path: AIX360/aix360/algorithms/imd/utils.py
imports: import numpy
  import pandas
  import networkx
  from collections import defaultdict
  from aix360.algorithms.imd.rule import Rule
label_desc: Use image node_id 6 for calling a global function with example usage: common_trunk_tree_to_digraph(root) and returns: T