I'm using Memgraph Lab for a project related to music genres and I imported a dataset structured something like this: The dataset is composed of 2k users. Each user is defined by id and a list of genres he loves. The edges represent the mutual friendship between the users. The genres are listed in the order the users have added them. First I wanted to count all of the genres and managed to do that by running this query:
MATCH (n)
WITH n, "Pop" AS genre
WHERE genre IN n.genres
RETURN genre, count(n);
My issue is that now if we assume that users picked the genres in order of preference, my goal is to create a query or a query module that tells us in what percentage each genre appears in top n place and I'm stuck on creating that