question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

finding Mutual Friends

See original GitHub issue

Hi , Thanks again for this awesome library.

Here is the raw Query in Gremlin to get mutual friends.

g.V(FirstUserId).both("Friend").where(both("Friend").is(eq(SecondUserId)))

The closest query I was able to write is below but it always return all the friends of first user as I was not able to write equivalent statement of .is(eq(SecondUserId)

await _g.V(FirstUserId).Both<Friend>()
                   .Where(l => l.Both<Friend>().V(SecondUserId)).Dedup().OfType<User>();

Thank you

reference links

  1. https://groups.google.com/forum/#!topic/gremlin-users/Saw7hvOPrcM
  2. https://stackoverflow.com/questions/36516914/get-a-list-of-common-friends-between-more-than-2-users-in-graph-database

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
danielcwebercommented, Jun 26, 2020

Then more like…

var mutualFriends = await _g.V(_marko.Id)
    .Both<Knows>()
    .OfType<Person>()
    .Fold()
    .As((__, markosFriends) => __.V(friend1.Id, friend2.Id)
        .Both<Knows>()
        .OfType<Person>()
        .Dedup()
        .Where(otherFriend => markosFriends.Value.Contains(otherFriend)));

?

1reaction
danielcwebercommented, Jun 26, 2020

How about

var mutualFriends = await _g.V(_marko.Id)
    .Both<Knows>()
    .OfType<Person>()
    .Fold()
    .As((__, markosFriends) => __.V(_peter.Id)
        .Both<Knows>()
        .OfType<Person>()
        .Where(petersFriend => markosFriends.Value.Contains(petersFriend))
        .Fold()
        .As((__, markosAndPetersFriends) => __.V(_josh.Id)
            .Both<Knows>()
            .OfType<Person>()
            .Where(joshsFriend => markosAndPetersFriends.Value.Contains(joshsFriend ))));

A great place to start learning Gremlin is the official documentation. You need to be familiar with Gremlin concepts to make the most of ExRam.Gremlinq. The sample graph in ExRam.Gremlinq.Samples is directly taken from the official docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Check Mutual Friends of 2 People on Facebook
Head to the Timeline of any current Facebook friend, and click the "Friends" tab. Before you even click, you'll see a number indicating...
Read more >
How to find mutual friends between two people on Facebook
Click the More button on the Friendship page, type in the names of the two friends whose mutual friendsyou want to view, and...
Read more >
How to see a list of mutual friends of two Facebook accounts?
Follow this simple technique: Find Profile ID of B - say it is Profile_B. Go to FB profile of A - say URL...
Read more >
How To See Mutual Friends on Facebook
The simplest method to see your mutual friends with another person on Facebook is by looking up their Facebook profile and seeing their...
Read more >
How do you find out who you have the most mutual friends ...
From there, you can click on the “Mutual Friends” tab to view a list of all of your mutual friends. You can then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found