def get_terminal_subgraph(g):
    """
    Return the subgraph induced by terminal nodes in g
    :param g:
    :return:
    """
    terminals = {node for node, d in g.nodes(data=True) if 'nt' not in d}
    return g.subgraph(terminals).copy()