1
votes

I have a graph database with a one-to-many relationship. There is a single central node which has one or more relationships of the same kind (but with different properties but in the same direction. ie: away from central node) to every other remaining node.

When I query all nodes in Neo4j browser, the visualization shows multiple relationship between node pairs. How can I limit it to only one relationship.

I found this related question , but it does not satisfy my purpose. The following query still shows multiple relationships

MATCH p=()-[r:AT_THE_SAME_TIME_AS]->() RETURN p, collect(r)[0] AS r LIMIT 25

So I tried the following, but then it doesn't show relationships, but only nodes:

MATCH p=()-[r:AT_THE_SAME_TIME_AS]->(s) RETURN s, collect(r)[0] AS r LIMIT 25

How to accomplish this?

1
Have you tried disabling the "connect result nodes" option? Take a look hereBruno Peres

1 Answers

-1
votes

So here's a small example dataset (correct me if this is not correct) :

CREATE (t1:Test {id: 1})
CREATE (t2:Test {id: 2})
CREATE (t1)-[:AT_THE_SAME_TIME_AS {counter: 1}]->(t2)
CREATE (t1)-[:AT_THE_SAME_TIME_AS {counter: 2}]->(t2);

And here's the query that gets only the first relationship between the two :

MATCH (t1:Test {id: 1})-[r:AT_THE_SAME_TIME_AS]->(t2:Test) RETURN t1.id, collect(r)[0] as r;

Hope that helps !

Regards, Tom