code: def add_edge(graph, edge):
      """Adds an edge to a given graph.
  
      If an edge between the two nodes already exists, the one with the largest
      weight is retained.
  
      Args:
        graph: A `dict`: source_id -> (target_id -> weight) to be augmented.
        edge: A `list` (or `tuple`) of the form `[source, target, weight]`, where
          `source` and `target` are strings, and `weight` is a numeric value of
          type `string` or `float`. The 'weight' component is optional; if not
          supplied, it defaults to 1.0.
  
      Returns:
        `True` if and only if a new edge was added to `graph`.
      """
      source = edge[0]
      target = edge[1]
      weight = float(edge[2]) if len(edge) > 2 else 1.0
      t_dict = graph.setdefault(source, {})
      is_new_edge = target not in t_dict
      if is_new_edge or weight > t_dict[target]:
          t_dict[target] = weight
      return is_new_edge
  
file_path: neural-structured-learning/neural_structured_learning/tools/graph_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import time
  from absl import logging
  import six
label_desc: Use image node_id 1 for calling a global function with example usage: add_edge(graph, edge) and returns: is_new_edge