def get_node_set(g1,g2,method="union"):
    """
    Returns the set of nodes that have to be considered in counting
    transitions of the Markov chains.  The input for the keyword
    argument `method` controls the method used.
    """
    if (method=="intersection"):
        nodes = list(set(g1.nodes()) & set(g2.nodes()))
    else:
        nodes = list(set(g1.nodes()) | set(g2.nodes()))
    return nodes