import collections


def _get_relationships_map(relationships):
  """Get relationships map.

  Args:
    relationships: list of tuples containing relationships data.

  Returns:
    a map from computed object ids to a list of aggregate object ids.
  """
  rel_map = collections.defaultdict(set)
  for _, aggregate_id, computed_type, computed_id in relationships:
    rel_map[(computed_type, computed_id)].add(aggregate_id)
  return rel_map