def add_edge_attribute(G, attr_dict, name, bool_response=True):
    """
    Add an edge attribute where the value are binary bool based on
    whether the edge have a specific value for a given attribute,
    given as a dictionary.

    Parameters
    ----------
    G : networkx Graph/DiGraph/MultiGraph/MultiDiGraph/...
        Graph on which we want to add an attribute.
    attr_dict : dict
        Dictionary where the key are the key of the edges' attributes
        and values are the values of those attributes that we want to
        take into account.
    name : str
        Name of the new attribute.
    bool_response : bool, optional
        Bool response if we find one of the values on one of the
        attributes of the edges from the dictionary.
        The default is True.

    Raises
    ------
    NameError
        Raised if the name is already an attribute of an edge
        of the graph, in order to avoid unintended mix.

    Returns
    -------
    G : networkx Graph/DiGraph/MultiGraph/MultiDiGraph/...
        Graph with the new binary attribute.

    """
    G = G.copy()
    for edge in G.edges:
        if name in G.edges[edge]:
            raise NameError(
                "New attribute {} already in edge {}, use a new name".format(
                    name, edge)
                )
        for key in list(attr_dict.keys()):
            if key in list(G.edges[edge].keys()):
                if G.edges[edge][key] in attr_dict[key]:
                    G.edges[edge][name] = bool_response
                    break # otherwise next key can replace the value
                else:
                    G.edges[edge][name] = not bool_response
    return G