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 On 04/25/2016 08:28 AM, Alan Robertson wrote: > Hi, > > Is there a way to specify a query which returns an intact subgraph? > > For example: > > starting from node "X" (by some specification), return the subgraph > reachable through a collection of relationship types {T}, through some > maximum distance (d), return a JSON representation of this subgraph - > possibly with some WHERE specifications, but possibly not. In our > nodes we include a nodetype in every node, we might want to say "WHERE > node.nodetype IN {N}" as our where clause. > > Result should be in some JSON graph format, perhaps like JSON Graph > Format (JGF) http://jsongraphformat.info/ or > https://github.com/bruth/json-graph-spec. > > This is exactly what's needed for visualization of a subgraph from a > Javascript program. Since Neo4j graphs are often huge, even monstrous, > having a query that does this would be incredibly handy... > > Otherwise you have to go through and put this graph together a piece > at a time (or so it seems to me). > > I think I can write a query which returns all the paths through this > subgraph, but then I have to do the duplication elimination and so on > myself. A single node might be returned many times in the possible > paths result. Not an ideal situation... > > This seems like a very common thing to want to do... > > -- > 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 neo4j+unsubscr...@googlegroups.com > <mailto:neo4j+unsubscr...@googlegroups.com>. > 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 neo4j+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.