3
votes

I am having trouble evaluating when to use which Neo4j query-mechanism (Gremlin, Cypher, traversals, build-in algorithms). For instance, I would like to select the single node in the entire graph

  • with the highest number of edges;
  • within a certain path-lenght from one of 4 starting nodes;
  • having a certain value for a property.

I am using the Python neo4jrestclient, and can execute basic Gremlin/Cypher scripts & traversals for some of the requirements individually (e.g. calculating In/OutDegree with Gremlin), but am missing the bigger picture on how to combine them.

Any suggestions?

1
But the problem is with the neo4jrestclient or the query itself? - Javier de la Rosa
The client is working OK, I am more wondering what query-mechanism to use where. - mhermans
It mostly depends on you preferences, traversals are fastest, cypher is more convenient. But you should watch out as some of what you want to do are graph-global queries which are not the optimal use-case for Neo4j. - Michael Hunger
Are you indexing the property? - ERR0

1 Answers

1
votes

In Cypher it would look like this:

start n=node:index(indicator="startnode-value")
match n-[:REL*..10]->target
where target.prop = "value"
return target