So, imagine a simple graph for a social network, where you have profile nodes and post nodes. Profiles can follow other profiles, and profiles can also watch, like and publish posts. So overall, 4 types of edges.
Then, given a target_profile and a list of profiles, I'd like to rank the list of profiles for that target_profile .
My idea is simple. I'd like to see how many similar activities each of those profiles has done to the target_profile and count them. But I'd also like to give extra weight to the activities performed by profiles that the target_profile follows, multiplying them by 3 for example. Then just order the results in descending order.
I can easily do both queries separately.
For getting profiles that the user follows:
g.V(TARGET_PROFILE).out('follows_profile').hasId(PROFILES_LIST)
For getting the count of similar activities each profile has done
g.V(TARGET_PROFILE).out().in().hasId(PROFILES_LIST).groupCount().by(T.id)
but since I'm new to gremlin queries (and graph databases in general) I can't find a way to multiply the groupCount() for the activities of each profile if the target_profile also follows them.
I got to this point with my code, but after that I have no idea of what to do:
g.V(TARGET_PROFILE).as('sourceProfile')
.out('follows_profile').hasId(PROFILES_LIST).as('followers')
.select('sourceProfile')
.out().in().hasId(PROFILES_LIST).groupCount().by(T.id).as('activities')