relationship matrix calculation