'Add an edge to the graph.'

def add_edge(self, G, edge_element, graphml_keys):

    ports = edge_element.find(('{%s}port' % self.NS_GRAPHML))
    if (ports is not None):
        warnings.warn('GraphML    port    tag    not    supported.')
    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)
    edge_id = edge_element.get('id')
    if edge_id:
        self.edge_ids[(source, target)] = edge_id
        try:
            edge_id = self.edge_key_type(edge_id)
        except ValueError:
            pass
    else:
        edge_id = data.get('key')
    if G.has_edge(source, target):
        self.multigraph = True
    G.add_edges_from([(source, target, edge_id, data)])
