def is_clique(G, clique_nodes):
    """Determines whether the given nodes form a clique.

    A clique is a subset of nodes of an undirected graph such that every two
    distinct nodes in the clique are adjacent.

    Parameters
    ----------
    G : NetworkX graph
       The graph on which to check the clique nodes.

    clique_nodes : list
       List of nodes that form a clique, as
       determined by the given sampler.

    Returns
    -------
    is_clique : bool
        True if clique_nodes forms a clique.

    Example
    -------
    This example checks two sets of nodes, both derived from a
    single Chimera unit cell, for an independent set. The first set is
    the horizontal tile's nodes; the second has nodes from the horizontal and
    verical tiles.

    >>> import dwave_networkx as dnx
    >>> G = dnx.chimera_graph(1, 1, 4)
    >>> dnx.is_clique(G, [0, 1, 2, 3])
    False
    >>> dnx.is_clique(G, [0, 4])
    True
    """
    for x in clique_nodes:
        for y in clique_nodes:
            if x != y:
                if not G.has_edge(x, y):
                    return False
    return True
