def networkx_succession_diagram_reduced_network_based(ar,include_attractors_in_diagram=True,use_compressed_diagram=True):
    """Label the succesion diagram and (optionally) attractors of the input attractor
    repertoire according to the conventions of Rozum et al. (2021).

    Parameters
    ----------
    ar : AttractorRepertoire
        Attractor repertoire object for which to build the diagram.
    include_attractors_in_diagram : bool
        Whether attractors should be represented as nodes in the diagram (the
        default is True).
    use_compressed_diagram : bool
        Whether to use the (potentially compressed) succession diagram stored in
        ar.succession_digraph instead of the complete one ar.succession_diagram.digraph.
        These are equivelent unless ar.simplify_diagram is called. See
        AttractorRepertoire.py for additional details. The default is True.

    Returns
    -------
    networkx.DiGraph
        A labeled digraph that represents the succession diagram.

    """

    if use_compressed_diagram:
        G_reduced_network_based=ar.succession_digraph.copy()
        relevant_nodes = ar.relevant_nodes
    else:
        G_reduced_network_based=ar.succession_diagram.digraph.copy()
        relevant_nodes = ar.primes.keys()

    has_nodes = False
    for i in G_reduced_network_based.nodes():
        has_nodes = True
        states={}
        for k,v in ar.succession_diagram.motif_reduction_dict[i].logically_fixed_nodes.items():
            if k in relevant_nodes:
                states[k]=v
        G_reduced_network_based.nodes[i]['index'] = i
        G_reduced_network_based.nodes[i]['states']=states

        contraction_indices = [i]
        if use_compressed_diagram and 'contraction' in ar.succession_digraph.nodes[i].keys():
            contraction_indices += list(ar.succession_digraph.nodes[i]['contraction'].keys())

        histories = []
        for c in contraction_indices:
            histories.append(ar.succession_diagram.motif_reduction_dict[c].motif_history)
        G_reduced_network_based.nodes[i]['history']=histories
        G_reduced_network_based.nodes[i]['motif union'] = {k:v for h in histories
            for m in h
            for k,v in m.items()
            if k in ar.relevant_nodes or not use_compressed_diagram}

    if not has_nodes:
        G_reduced_network_based.add_node(0)
        G_reduced_network_based.nodes[0]['index'] = 0
        G_reduced_network_based.nodes[0]['states'] = {}
        G_reduced_network_based.nodes[0]['history'] = [[]]
        G_reduced_network_based.nodes[0]['motif union'] = {}

    for u,v in G_reduced_network_based.edges():
        ufixed = G_reduced_network_based.nodes[u]['states']
        vfixed = G_reduced_network_based.nodes[v]['states']
        lock_in = {}
        for k,val in vfixed.items():
            if k not in ufixed.keys():
                lock_in[k] = val
        G_reduced_network_based.edges[u,v]['states'] = lock_in

        ufixed = G_reduced_network_based.nodes[u]['motif union']
        vfixed = G_reduced_network_based.nodes[v]['motif union']
        lock_in = {}
        for k,val in vfixed.items():
            if k not in ufixed.keys():
                lock_in[k] = val
        G_reduced_network_based.edges[u,v]['motif'] = lock_in

    if include_attractors_in_diagram and not use_compressed_diagram:
        for a_index,a in enumerate(ar.attractors):
            astr = 'A'+str(a_index)
            G_reduced_network_based.add_node(astr)
            G_reduced_network_based.nodes[astr]['index']=astr
            G_reduced_network_based.nodes[astr]['states']=a.attractor_dict

            for r in a.reductions:
                r_ind = list(ar.succession_diagram.motif_reduction_dict.values()).index(r)
                r_key=list(ar.succession_diagram.motif_reduction_dict.keys())[r_ind]
                if r_key in G_reduced_network_based.nodes():
                    G_reduced_network_based.add_edge(r_key,astr,states='')
    if include_attractors_in_diagram and use_compressed_diagram:
        for a_index,a in enumerate(ar.attractor_equivalence_classes):
            astr = 'A'+str(a_index)
            G_reduced_network_based.add_node(astr)
            G_reduced_network_based.nodes[astr]['index']=astr
            G_reduced_network_based.nodes[astr]['states']=a['states']

            for r_key in a['reductions']:
                if r_key in G_reduced_network_based.nodes():
                    G_reduced_network_based.add_edge(r_key,astr,states='')

    for n in G_reduced_network_based.nodes():
        if str(n)[0]=='A':
            G_reduced_network_based.nodes[n]['label']='Attractor ' +\
                G_reduced_network_based.nodes[n]['index'] +\
                ':\n '+str(G_reduced_network_based.nodes[n]['states'])
        else:
            G_reduced_network_based.nodes[n]['label']=str(G_reduced_network_based.nodes[n]['motif union'])

    return G_reduced_network_based