code: def construct_cost_functions(
      G1,
      G2,
      node_substitution_cost,
      edge_substitution_cost,
      G1_node_deletion_cost,
      G1_edge_deletion_cost,
      G2_node_insertion_cost,
      G2_edge_insertion_cost,
  ):
      """Constructs cost matrices for LAP solution
  
  
      Parameters : see graph_edit_distance
  
      """
      num_G1_nodes = G1.num_nodes()
      num_G2_nodes = G2.num_nodes()
  
      num_G1_edges = G1.num_edges()
      num_G2_edges = G2.num_edges()
  
      # cost matrix of node mappings
      cost_upper_bound = (
          node_substitution_cost.sum()
          + G1_node_deletion_cost.sum()
          + G2_node_insertion_cost.sum()
          + 1
      )
      C_node = np.zeros(
          (num_G1_nodes + num_G2_nodes, num_G1_nodes + num_G2_nodes),
          dtype=float,
      )
  
      C_node[0:num_G1_nodes, 0:num_G2_nodes] = node_substitution_cost
      C_node[
          0:num_G1_nodes, num_G2_nodes : num_G2_nodes + num_G1_nodes
      ] = np.array(
          [
              G1_node_deletion_cost[i] if i == j else cost_upper_bound
              for i in range(num_G1_nodes)
              for j in range(num_G1_nodes)
          ]
      ).reshape(
          num_G1_nodes, num_G1_nodes
      )
      C_node[
          num_G1_nodes : num_G1_nodes + num_G2_nodes, 0:num_G2_nodes
      ] = np.array(
          [
              G2_node_insertion_cost[i] if i == j else cost_upper_bound
              for i in range(num_G2_nodes)
              for j in range(num_G2_nodes)
          ]
      ).reshape(
          num_G2_nodes, num_G2_nodes
      )
  
      # cost matrix of edge mappings
      cost_upper_bound = (
          edge_substitution_cost.sum()
          + G1_edge_deletion_cost.sum()
          + G2_edge_insertion_cost.sum()
          + 1
      )
      C_edge = np.zeros(
          (num_G1_edges + num_G2_edges, num_G1_edges + num_G2_edges),
          dtype=float,
      )
  
      C_edge[0:num_G1_edges, 0:num_G2_edges] = edge_substitution_cost
      C_edge[
          0:num_G1_edges, num_G2_edges : num_G2_edges + num_G1_edges
      ] = np.array(
          [
              G1_edge_deletion_cost[i] if i == j else cost_upper_bound
              for i in range(num_G1_edges)
              for j in range(num_G1_edges)
          ]
      ).reshape(
          num_G1_edges, num_G1_edges
      )
      C_edge[
          num_G1_edges : num_G1_edges + num_G2_edges, 0:num_G2_edges
      ] = np.array(
          [
              G2_edge_insertion_cost[i] if i == j else cost_upper_bound
              for i in range(num_G2_edges)
              for j in range(num_G2_edges)
          ]
      ).reshape(
          num_G2_edges, num_G2_edges
      )
      return C_node, C_edge
  
file_path: dgl/examples/pytorch/graph_matching/ged.py
imports: from copy import deepcopy
  from heapq import heapify, heappop, heappush, nsmallest
  import dgl
  import numpy
  from lapjv import lapjv
label_desc: Use image node_id 2 for calling a global function with example usage: construct_cost_functions(G1, G2, node_substitution_cost, edge_substitution_cost, G1_node_deletion_cost, G1_edge_deletion_cost, G2_node_insertion_cost, G2_edge_insertion_cost) and returns: C_node,  C_edge