new version with own conflict matrix and new function to compute affinity matrix