I want to do a request that return all the loops in the graph (all the paths), where all the node have two relations, one that leave and one that arrive (one :NEED and one :OFFEREDBY).
How can I restrict (write) the request ? I didn't manage to do it with [:RELTYPE'*1] or [:RELTYPE'*1..1]
Can you elaborate on this? What constitutes a valid result vs an invalid result? Some examples showing what you want, and what you don't want may help.
In a previous edit I saw you had a query already that generated the patterns, it looks like you want to refine that query?
Will something like this work for you?
(start)-[:NEED|OFFEREDBY*..16]->(start)
With some acceptable upper bound of course. This traverses all outgoing :NEED and :OFFEREDBY relationships, and the results back will be those that loop back to the start.
Oh, so you want the graph to show the same node per pattern where it's matched?
That can't currently be done by the Neo4j visualizer. Nodes are distinct, it can't display the same node multiple times in different contexts. The graphical results are a union of the query results. You would need to execute separate queries (maybe using SKIP and LIMIT) to visualize each graph separately.
Unfortunately Neo4j has a built-in behaviour by MATCH clause to avoid passing 2 times on the same relationship. But you can use this behaviour for your self, knowing that neo4j will always short the result the same way.
As Andrew said ( I didn't know ), the visualiser can only show a node one time, so from the Neo4j desktop API you have no choice to do two or more queries.
I considered your A,B... and R1,R2... as labels to simplify my example.
Query:
MATCH paths = (:A)-[*]->(:A)
RETURN paths SKIP x LIMIT 1
Increment x for each loop (request ) you want to see in your graph begin by 0
From a home made visualiser:
MATCH paths = (:A)-[*]->(:A)
RETURN paths
And use the json or csv result showing all your paths "loops".
You can export the json or csv from the neo4j desktop app dedicated button.