Good graph database for intersections (Neo4j? Pegasus? Allegro? ...)

I am looking for a good graph database to search for multiple intersections - I take any two nodes and see if their endpoints overlap. An analogy in a social network is two glances at two people and see if they are connected with the same people.

I tried to get FlockDB (from people on Twitter) to work because the intersection features are built-in, but found that there is no support in user communities. So any recommendations from other graphical databases, especially where the kind of intersection functions I'm looking for already exists ...?

+4
source share
2 answers

Isn't that the shortest path between two nodes with length == 2?

In Neo4j, you can use shortestPath () Finder from GraphAlgoFactory to do this.

+2
source

This will tell you if there is a connection:

Node from_node = index.get("guid", "user_a").getSingle(); Node to_node = index.get("guid", "user_b").getSingle(); if(from_node != null && to_node != null) { RelationshipExpander expander = Traversal.expanderForAllTypes(Direction.BOTH); PathFinder<Path> finder = GraphAlgoFactory.shortestPath(expander, 2); if(finder.findSinglePath(from_node, to_node) != null) { //Connected by at least 1 common friend } else { //Too far apart or not connected at all } } 

This will tell you who are mutual friends:

 Node from_node = index.get("guid", "user_a").getSingle(); Node to_node = index.get("guid", "user_b").getSingle(); if(from_node != null && to_node != null) { RelationshipExpander expander = Traversal.expanderForAllTypes(Direction.BOTH); PathFinder<Path> finder = GraphAlgoFactory.shortestPath(expander, 2); Iterable<Path> paths = finder.findAllPaths(from_node, to_node); if(paths != null) { for(Path path : paths) { Relationship relationship = path.relationships().iterator().next(); Node friend_of_friend = relationship.getEndNode(); } } else { //Too far apart or not connected at all } } 

This code is a little rough and much easier to express in Cypher (taken from the Cheet Sheet in the Neo4J server console (a great way to play with Neo4J after filling the database):

 START a = (user, name, "user_a") MATCH (a)-[:FRIEND]->(friend)-[:FRIEND]->(friend_of_friend) RETURN friend_of_friend 

This will give you a list of nodes shared between other disconnected nodes. You can pass this request to the embedded server by counting the CypherParser class.

+1
source

All Articles