def METHOD_NAME(self, a, b, **kwargs):
    """Add a connection between two parts.
    Parameters
    ----------
    a : :class:`~compas.datastructures.Part`
        The "from" part.
    b : :class:`~compas.datastructures.Part`
        The "to" part.
    **kwargs : dict[str, Any], optional
        Attribute dict compiled from named arguments.
    Returns
    -------
    tuple[int | str, int | str]
        The tuple of node identifiers that identifies the connection.
    Raises
    ------
    :class:`AssemblyError`
        If `a` and/or `b` are not in the assembly.
    """
    error_msg = "Both parts have to be added to the assembly before a connection can be created."
    if a.key is None or b.key is None:
        raise AssemblyError(error_msg)
    if not self.graph.has_node(a.key) or not self.graph.has_node(b.key):
        raise AssemblyError(error_msg)
    return self.graph.add_edge(a.key, b.key, **kwargs)