'Display only nodes matched by variable length relationship query

I have a Cypher query with a variable length relationship:

MATCH p = (a1:Article)-[:REFERENCES*3..]->(a2:Article) RETURN p;

This gets me the desired results in table and text view. However, in graph view it also displays nodes with fewer relationships. How can I filter those out?



Solution 1:[1]

Can you clarify what your desired results are? Using a variable length means you get all nodes in the range.

RETURN p will return entire path, including all nodes in path.

MATCH p = (a1:Article)-[:REFERENCES*3]->(a2:Article) RETURN a2

should return the nodes 3 hops away from a1.

Solution 2:[2]

It might have something to do with your Neo4j Browser settings. The 'Connect result nodes' option is enabled by default. All relationships between the nodes matched in your query will be displayed with this enabled. This happens even if you haven't explicitly mentioned that path/pattern/realtionship in your query.

You can find this option in the Browser Settings, available in the bottom left corner of your Neo4j Browser.

Adjust the Graph Vizualization settings in the Browser Settings drawer

Connect Result Nodes

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephanie
Solution 2