Fix calculation for relation roles graph