Hello,
I have a sample graph generated by the following command
CREATE p = (:x {name: 'a'}) -[:next]-> (:y {name: 'b'})-[:next]-> (:x {name: 'c'})-[:next]-> (:y {name: 'd'}), q = (:y {name: 'b'})-[:next]-> (:x {name: 'c'})-[:next]-> (:y {name: 'd'}), r = (:x {name: 'a'}) -[:next]-> (:y {name: 'b'})-[:next]-> (:x {name: 'c'})-[:next]-> (:y {name: 'e'}) RETURN *
For some analysis I am doing, I want a cartesian product of the paths. Just to check whether the cartesian product is working, I do
MATCH (n), (m)
RETURN id(n), id(m)
And get
id(n) | id(m) |
---|---|
190 | 190 |
190 | 191 |
190 | 192 |
190 | 193 |
... | ... |
This is all as expected. Then I want to check that the cartesian product of paths is working fine and run
MATCH p = ()-[*]->(), q = ()-[*]->()
WITH nodes(p) as np, nodes(q) as nq
RETURN id(np[0]), id(nq[0])
And get
id(np[0]) | id(nq[0]) |
---|---|
190 | 191 |
190 | 191 |
190 | 192 |
190 | 194 |
190 | 194 |
190 | 195 |
... | ... |
This is weird. I was expecting that the starting node of the paths should be repeated at least once. It isn't repeated anywhere in the whole table of results.
It should be repeated since if we have p = q = [190->191,191->192]
Then we have p x q = [ (190->191, 190->191), (190->191, 191->192), (191->192, 190->191), (191->192, 191->192) ].
Can someone explain why this result is not present in the real query?
Thanks
- Neo4j 4.3.1 Enterprise, Desktop 1.3.11, browser 4.2.0
- Using browser