this is a screenshot of a sample graph:

sample graph

if my query looks like this:

MATCH (f:Node {key:'someid'}) 
CALL apoc.path.expand(f, 'RELATIONSHIPS', 'FINAL_NODE',-1,-1) yield path as p

RETURN p

when using the browser and looking at the table view, it looks like the data gets returned as singular paths in an array. So an array within an array.

[
  [
     {red},
     {relationship},
     {teal},
     {relationship},
     {red},
     {relationship},
     {blue},
     {relationship},
     {green}
  ],
  [
     {red},
     {relationship},
     {teal},
     {relationship},
     {red},
     {relationship},
     {blue},
     {relationship},
     {green}
  ],
  etc
]

the {} being the properties of each node and relationship.

If I use

RETURN Nodes(p)

it just gives me a list of all items without the depth and if I try and use size or length with path, they all are 5 in this instance and doesn't give me the individual nodes.

What I really would like is to be able to recreate the levels of the graph so ideally the data would be returned like this:

[
  [
    {red}
  ],[
    {teal},
    {teal},
    {teal},
    {teal},
    {teal},
    {teal}
  ],[
    {red}
  ],[
    {blue},
    {blue},
    {blue},
    {blue},
    {blue},
    {blue},
    {blue}
  ],[
    {green}
  ]
]

Is this possible using the expand function or do I need to figure out how to do the same thing with a stand pattern through cypher?

0 Answers