code: def complete_to_chordal_graph(G):
      """Return a copy of G completed to a chordal graph
  
      Adds edges to a copy of G to create a chordal graph. A graph G=(V,E) is
      called chordal if for each cycle with length bigger than 3, there exist
      two non-adjacent nodes connected by an edge (called a chord).
  
      Parameters
      ----------
      G : NetworkX graph
          Undirected graph
  
      Returns
      -------
      H : NetworkX graph
          The chordal enhancement of G
      alpha : Dictionary
              The elimination ordering of nodes of G
  
      Notes
      -----
      There are different approaches to calculate the chordal
      enhancement of a graph. The algorithm used here is called
      MCS-M and gives at least minimal (local) triangulation of graph. Note
      that this triangulation is not necessarily a global minimum.
  
      https://en.wikipedia.org/wiki/Chordal_graph
  
      References
      ----------
      .. [1] Berry, Anne & Blair, Jean & Heggernes, Pinar & Peyton, Barry. (2004)
             Maximum Cardinality Search for Computing Minimal Triangulations of
             Graphs.  Algorithmica. 39. 287-298. 10.1007/s00453-004-1084-3.
  
      Examples
      --------
      >>> from networkx.algorithms.chordal import complete_to_chordal_graph
      >>> G = nx.wheel_graph(10)
      >>> H, alpha = complete_to_chordal_graph(G)
      """
      H = G.copy()
      alpha = {node: 0 for node in H}
      if nx.is_chordal(H):
          return H, alpha
      chords = set()
      weight = {node: 0 for node in H.nodes()}
      unnumbered_nodes = list(H.nodes())
      for i in range(len(H.nodes()), 0, -1):
          # get the node in unnumbered_nodes with the maximum weight
          z = max(unnumbered_nodes, key=lambda node: weight[node])
          unnumbered_nodes.remove(z)
          alpha[z] = i
          update_nodes = []
          for y in unnumbered_nodes:
              if G.has_edge(y, z):
                  update_nodes.append(y)
              else:
                  # y_weight will be bigger than node weights between y and z
                  y_weight = weight[y]
                  lower_nodes = [
                      node
                      for node in unnumbered_nodes
                      if weight[node] < y_weight
                  ]
                  if nx.has_path(
                      H.subgraph(lower_nodes + [z, y]), y, z
                  ):
                      update_nodes.append(y)
                      chords.add((z, y))
          # during calculation of paths the weights should not be updated
          for node in update_nodes:
              weight[node] += 1
      H.add_edges_from(chords)
      return H, alpha
  
file_path: networkx/networkx/algorithms/chordal.py
imports: import sys
  import networkx
  from networkx.algorithms.components import connected_components
  from networkx.utils import arbitrary_element, not_implemented_for
label_desc: Use image node_id 9 for calling a global function with example usage: complete_to_chordal_graph(G) and returns: H,  alpha, H,  alpha