The query isn't quite right. It has an error in it (variable n already
used) and something about the order of operations causes it to return
more than one row - with duplicates ;-)

But this one seems to do the trick:

|match path = shortestPath( (n)-[*]->(m) ) return collect(distinct
unwind(nodes(path))), collect(distinct unwind(rels(path)))|


What do you think?



On 04/28/2016 07:59 AM, Alan Robertson wrote:
> Hi,
>
> Michael Hunger separately provided me this query - which is a
> prototype query which looks like it will do what I want. It includes
> features of Cypher I was not familiar with (particularly unwind):
>
>> |.... match path = shortestPath( (n)-[*]->(m) ) unwind nodes(path) as
>> n with collect(distinct n) as nodes unwind rels(path) as r return
>> collect(distinct r), nodes|
> If I understand it correctly, this returns a single tuple with two
> elements:
>
>  1. List of all individual relationships (no duplicates)
>  2. List of all individual nodes (no duplicates)
>
> I'll have to try this out!
>
> I kind of wonder how this gets mapped into py2neo - what type are the
> tuple elements -- list(Relationship) and list(Node) or something like
> that...
>
> *Nigel?*
>
> I know my code won't currently handle this - but I can fix that ;-)
>
>     -- Alan
>


-- 

Alan Robertson / CTO
[email protected] <mailto:[email protected]>/ +1
303.947.7999

Assimilation Systems Limited
http://AssimilationSystems.com

Twitter <https://twitter.com/ossalanr> Linkedin
<https://www.linkedin.com/in/alanr> skype
<https://htmlsig.com/skype?username=alanr_unix.sh>

-- 
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.

Reply via email to