class_docstr: Read a GraphML document.  Produces NetworkX graph objects.
class_docstr_tok: ["Read","a","GraphML","document",".","Produces","NetworkX","graph","objects","."]
docstr: Add an edge to the graph.
docstr_tok: ["Add","an","edge","to","the","graph","."]
code: def add_edge(self, G, edge_element, graphml_keys):
      """Add an edge to the graph."""
      # warn on finding unsupported ports tag
      ports = edge_element.find(f"{{{self.NS_GRAPHML}}}port")
      if ports is not None:
          warnings.warn("GraphML port tag not supported.")
  
      # raise error if we find mixed directed and undirected edges
      directed = edge_element.get("directed")
      if G.is_directed() and directed == "false":
          msg = "directed=false edge found in directed graph."
          raise nx.NetworkXError(msg)
      if (not G.is_directed()) and directed == "true":
          msg = "directed=true edge found in undirected graph."
          raise nx.NetworkXError(msg)
  
      source = self.node_type(edge_element.get("source"))
      target = self.node_type(edge_element.get("target"))
      data = self.decode_data_elements(graphml_keys, edge_element)
      # GraphML stores edge ids as an attribute
      # NetworkX uses them as keys in multigraphs too if no key
      # attribute is specified
      edge_id = edge_element.get("id")
      if edge_id:
          # self.edge_ids is used by `make_graph` method for non-multigraphs
          self.edge_ids[source, target] = edge_id
          try:
              edge_id = self.edge_key_type(edge_id)
          except ValueError:  # Could not convert.
              pass
      else:
          edge_id = data.get("key")
  
      if G.has_edge(source, target):
          # mark this as a multigraph
          self.multigraph = True
  
      # Use add_edges_from to avoid error with add_edge when `'key' in data`
      # Note there is only one edge here...
      G.add_edges_from([(source, target, edge_id, data)])
  
imports: import warnings
  from collections import defaultdict
  import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 5 for calling the GraphMLReader obj's underlying member method code with example usage: obj.add_edge(G, edge_element, graphml_keys) without return types