def make_interaction_map(name, list, interaction):
    """ Print out an interaction map named 'name' of the groups in 'list'
    based on the function 'interaction' """
    if len(list) == 0:
        return ''
    if len(list) > 10:
        res = 'Condensed form:\n'
        for i in range(len(list)):
            for j in range(i, len(list)):
                if interaction(list[i], list[j]):
                    res += 'Coupling: %9s - %9s\n' % (list[i].label, list[j
                        ].label)
        return res
    res = '%s\n%12s' % (name, '')
    for g in list:
        res += '%9s | ' % g.label
    for g1 in list:
        res += '\n%-12s' % g1.label
        for g2 in list:
            tag = ''
            if interaction(g1, g2):
                tag = '    X     '
            res += '%10s| ' % tag
    return res
