def subtree_induced_by_subset(tree, s):
    """ Returns the subtree of tree induced by the nodes containing the set s.

    Args:
       tree (NetworkX graph): A junction tree.
       s (set): Subset of the node in the underlying graph of T.

    Example:
        >>> t = jtlib.sample(5)  
        >>> t.nodes
        NodeView((frozenset([0, 4]), frozenset([3]), frozenset([1, 2, 4])))
        >>> t.edges
        EdgeView([(frozenset([0, 4]), frozenset([1, 2, 4])), (frozenset([3]), frozenset([1, 2, 4]))])
        >>> subt = jtlib.subtree_induced_by_subset(t, frozenset([1]))
        >>> subt.nodes
        NodeView((frozenset([1, 2, 4]),))
        >>> t.edges
        EdgeView([(frozenset([0, 4]), frozenset([1, 2, 4])), (frozenset([3]), frozenset([1, 2, 4]))])
    """
    if len(s) == 0:
        return tree.copy()
    v_prime = {c for c in tree.nodes() if s <= c}
    return tree.subgraph(v_prime).copy()