code: def add_edges(self, G, graph_element):
      def edge_key_data(G):
          # helper function to unify multigraph and graph edge iterator
          if G.is_multigraph():
              for u, v, key, data in G.edges(data=True, keys=True):
                  edge_data = data.copy()
                  edge_data.update(key=key)
                  edge_id = edge_data.pop("id", None)
                  if edge_id is None:
                      edge_id = next(self.edge_id)
                      while str(edge_id) in self.all_edge_ids:
                          edge_id = next(self.edge_id)
                      self.all_edge_ids.add(str(edge_id))
                  yield u, v, edge_id, edge_data
          else:
              for u, v, data in G.edges(data=True):
                  edge_data = data.copy()
                  edge_id = edge_data.pop("id", None)
                  if edge_id is None:
                      edge_id = next(self.edge_id)
                      while str(edge_id) in self.all_edge_ids:
                          edge_id = next(self.edge_id)
                      self.all_edge_ids.add(str(edge_id))
                  yield u, v, edge_id, edge_data
  
      edges_element = Element("edges")
      for u, v, key, edge_data in edge_key_data(G):
          kw = {"id": str(key)}
          try:
              edge_label = edge_data.pop("label")
              kw["label"] = str(edge_label)
          except KeyError:
              pass
          try:
              edge_weight = edge_data.pop("weight")
              kw["weight"] = str(edge_weight)
          except KeyError:
              pass
          try:
              edge_type = edge_data.pop("type")
              kw["type"] = str(edge_type)
          except KeyError:
              pass
          try:
              start = edge_data.pop("start")
              kw["start"] = str(start)
              self.alter_graph_mode_timeformat(start)
          except KeyError:
              pass
          try:
              end = edge_data.pop("end")
              kw["end"] = str(end)
              self.alter_graph_mode_timeformat(end)
          except KeyError:
              pass
          source_id = str(G.nodes[u].get("id", u))
          target_id = str(G.nodes[v].get("id", v))
          edge_element = Element(
              "edge", source=source_id, target=target_id, **kw
          )
          default = G.graph.get("edge_default", {})
          if self.VERSION == "1.1":
              edge_data = self.add_slices(edge_element, edge_data)
          else:
              edge_data = self.add_spells(edge_element, edge_data)
          edge_data = self.add_viz(edge_element, edge_data)
          edge_data = self.add_attributes(
              "edge", edge_element, edge_data, default
          )
          edges_element.append(edge_element)
      graph_element.append(edges_element)
  
imports: import itertools
  import time
  from xml.etree.ElementTree import Element, ElementTree, SubElement, register_namespace, tostring
  import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 5 for calling the GEXFWriter obj's underlying member method code with example usage: obj.add_edges(G, graph_element) without return types