code: def _custom_create_vertical_neighbor_indicator(graph, pos):
      # Creates a matrix indicating whether two nodes are vertical neighbors.
      all_nodes = list(graph.nodes)
      vertical_neighbor_indicator = pd.DataFrame(
          np.zeros((len(all_nodes), len(all_nodes))).astype(bool),
          index=[str(n) for n in all_nodes],
          columns=[str(n) for n in all_nodes],
      )
  
      # Get all y coordinates per layer
      layer_y_coords = {}
      for n in graph.nodes:
          if graph.nodes[n]["layer"] not in layer_y_coords:
              layer_y_coords[graph.nodes[n]["layer"]] = []
  
          layer_y_coords[graph.nodes[n]["layer"]].append((n, pos[n][1]))
  
      # Sort the y-coordinates
      for layer in layer_y_coords:
          layer_y_coords[layer].sort(key=lambda x: x[1])
  
      layer_y_coords_map = {}
      for layer in layer_y_coords:
          for i, k in enumerate(layer_y_coords[layer]):
              if k[0] in layer_y_coords_map:
                  raise RuntimeError(
                      "Something went wrong when creating the layer y-coordinate map."
                  )
              layer_y_coords_map[k[0]] = i
  
      for n1 in all_nodes:
          for n2 in all_nodes:
              if n1 == n2:
                  vertical_neighbor_indicator.loc[
                      str(n1), str(n2)
                  ] = True
                  continue
  
              n1_layer = graph.nodes[n1]["layer"]
              n2_layer = graph.nodes[n2]["layer"]
  
              if n1_layer != n2_layer:
                  vertical_neighbor_indicator.loc[
                      str(n1), str(n2)
                  ] = False
                  continue
  
              vertical_neighbor_indicator.loc[str(n1), str(n2)] = (
                  layer_y_coords_map[n1] == layer_y_coords_map[n2] + 1
              ) or (
                  layer_y_coords_map[n1] == layer_y_coords_map[n2] - 1
              )
  
      return vertical_neighbor_indicator
  
file_path: dowhy/dowhy/utils/networkx_plotting.py
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple, Union
  import matplotlib.pyplot
  import networkx
  import numpy
  import pandas
  from networkx.drawing import nx_pydot
label_desc: Use image node_id 5 for calling a global function with example usage: _custom_create_vertical_neighbor_indicator(graph, pos) and returns: vertical_neighbor_indicator