It should be simple to do it within one query match (u:Port1) WITH u, size( (u)-->() ) as outDegree, size ( (u)<--() ) as inDegree WHERE inDegree = 0 // root nodes RETURN u ORDER BY outDegree DESC LIMIT 5
On Fri, Jul 28, 2017 at 8:34 AM, Krishna Mahi <[email protected]> wrote: > I want to find out the common node between 2 different queries. I am > trying hard to find out, but could not think of a solution. My motive is to > collect top 5 outdegree nodes, collect top 5 root nodes, and return nodes > that are common between top 5 outdegree and root nodes. I don't know how to > merge the results, because after using "return" option in first query, no > further statements would be executed, but without "return" option we cannot > collect results. (Please do correct me, if I am thinking wrong). Following > are the queries, > // for root nodes > match (u:Port1)<-[r]-(root) > where not((root)<--()) > return distinct(root.id) as Node, count(r) as Outdegree > ORDER BY count(r) desc limit 5 > // for outdegree nodes > match (n:Port1)-[r]->() > return n.id as Node, count(r) as Outdegree > order by Outdegree DESC > union > match (a:Port1)-[r]->(leaf) > where not((leaf)-->()) > return leaf.id as Node, 0 as Outdegree limit 5 > > How should I combine both results, and get the output of list of nodes > that are common? Please do help me. Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
