nodifications in calculation of the affinity matrix and dependency graphs