code: def move_gain(mapping, node_id, old_id, new_id, weight_dict, match_num):
      
      # new node mapping after moving
      new_mapping = (node_id, new_id)
      # node mapping before moving
      old_mapping = (node_id, old_id)
      # new nodes mapping list (all node pairs)
      new_mapping_list = mapping[:]
      new_mapping_list[node_id] = new_id
      # if this mapping is already been investigated, use saved one to avoid duplicate computing
      if tuple(new_mapping_list) in match_triple_dict:
          return match_triple_dict[tuple(new_mapping_list)] - match_num
      gain = 0
      # add the triple match incurred by new_mapping to gain
      if new_mapping in weight_dict:
          for key in weight_dict[new_mapping]:
              if key == -1:
                  # instance/attribute triple match
                  gain += weight_dict[new_mapping][-1]
              elif new_mapping_list[key[0]] == key[1]:
                  # relation gain incurred by new_mapping and another node pair in new_mapping_list
                  gain += weight_dict[new_mapping][key]
      # deduct the triple match incurred by old_mapping from gain
      if old_mapping in weight_dict:
          for k in weight_dict[old_mapping]:
              if k == -1:
                  gain -= weight_dict[old_mapping][-1]
              elif mapping[k[0]] == k[1]:
                  gain -= weight_dict[old_mapping][k]
      # update match number dictionary
      match_triple_dict[tuple(new_mapping_list)] = match_num + gain
      return gain
docs: Compute the triple match number gain from the move operation
      Arguments:
          mapping: current node mapping
          node_id: remapped node in AMR 1
          old_id: original node id in AMR 2 to which node_id is mapped
          new_id: new node in to which node_id is mapped
          weight_dict: weight dictionary
          match_num: the original triple matching number
      Returns:
          the triple match gain number (might be negative)