Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j: which query-approach for selecting single node based on node property and position?

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?

like image 661
mhermans Avatar asked Dec 10 '25 02:12

mhermans


1 Answers

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
like image 191
Michael Hunger Avatar answered Dec 12 '25 16:12

Michael Hunger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!