defproc addgroup($group_name, $target, $color=black) {
    edge [color=$color];
    A_~$group_name->$target:: \c($color) 1st\n(\Q($group_name));
    B_~$group_name->$target:: \c($color) 2nd\n(\Q($group_name));
    C_~$group_name->$target:: \c($color) 3rd\n(\Q($group_name));
}

graph {
    composite;
    replay addgroup(iron, composite);
    replay addgroup(steel, composite, blue);
    replay addgroup(gold, composite, yellow);
};