Add calculation for modularity function q in tag_preprocessing