added cpp clustering code