code: def find_c_components(adjacency_matrix, node_set, idx2node):
      """
      Obtain C-components in a graph.
  
      :param adjacency_matrix: Graph adjacency matrix.
      :param node_set: Set of nodes whos ancestors must be obtained.
      :param idx2node: A dictionary mapping the row or column indices in the adjacency matrix to the corresponding node names.
      :returns: List of C-components in the graph.
      """
      num_nodes = len(node_set)
      adj_matrix = adjacency_matrix.copy()
      adjacency_list = [[] for _ in range(num_nodes)]
  
      # Modify graph such that it only contains bidirected edges
      for h in range(0, num_nodes - 1):
          for w in range(h + 1, num_nodes):
              if (
                  adjacency_matrix[h, w] == 1
                  and adjacency_matrix[w, h] == 1
              ):
                  adjacency_list[h].append(w)
                  adjacency_list[w].append(h)
              else:
                  adj_matrix[h, w] = 0
                  adj_matrix[w, h] = 0
  
      # Find c components by finding connected components on the undirected graph
      visited = [False for _ in range(num_nodes)]
  
      def dfs(node_idx, component):
          visited[node_idx] = True
          component.add(idx2node[node_idx])
          for neighbour in adjacency_list[node_idx]:
              if visited[neighbour] == False:
                  dfs(neighbour, component)
  
      c_components = []
      for i in range(num_nodes):
          if visited[i] == False:
              component = OrderedSet()
              dfs(i, component)
              c_components.append(component)
  
      return c_components
  
imports: import re
  from queue import LifoQueue
  import networkx
  import numpy
  from networkx.algorithms.dag import is_directed_acyclic_graph
  from networkx.algorithms.shortest_paths.generic import shortest_path
  from dowhy.utils.ordered_set import OrderedSet
label_desc: Use image node_id 6 for calling a global function with example usage: find_c_components(adjacency_matrix, node_set, idx2node) and returns: c_components