2

I have currently visualised a graph between myself and a number of other people.

My Current query is:

MATCH (p)-[:emailed]->(m) 
WITH p,count(m) as rels, collect(m) as Contact
WHERE rels > 2  
RETURN p,Contact, rels

It creates a pretty complex graph as per image below:

Messy Graph

You can manually remove them by directly clicking on them as per below:

Manually hide node from visualisation

Which then results in a very different looking graph.

Q. How do I change my query to automatically show the graph visualisation without showing the nodes that I wish to remove? (i.e by editing the query, so I dont have to manually remove each one)

By doing either

A) Adding a list of the specific Node ID's in the query to ignore, OR

B) (Ideally) Exclude all nodes that meet a criteria against the node Property

In this case: Ignore [Slug: "myname" ] where includes 'myname'

MATCH (p)-[:emailed]->(m) 
WITH p,count(m) as rels, collect(m) as Contact
WHERE rels > 2 AND NOT WHERE p.slug Contains 'Mahdi'  
RETURN p,Contact, rels

Thanks for any help!

Dave Bennett
  • 10,996
  • 3
  • 30
  • 41
MShariff
  • 41
  • 3

2 Answers2

2

I would change it slightly. If you collect the actual :emailed relationships rather than just counting the node they are connect to you can use them in your result set. Then if you turn off autocomplete as JeromeB suggests above then you will actually see some relationship. If you turn off autocomplete in your current query there will only be nodes and no relationships which I don't think you are after (unless of course you are).

You could also check to make sure that the p.slug attribute exists when testing for CONTAINS otherwise if the attribute does not exist you will not generate any results for that row.

MATCH (p:User)-[r:emailed]->(m:User) 
WITH p, COLLECT(r) as rels, COLLECT(m) as contact
WHERE (NOT p.slug CONTAINS 'Mahdi' OR NOT EXISTS(p.slug)) 
  AND size(rels) > 2 
RETURN p, contact, rels

I would also add a label to the nodes in the match and an index on the slug property.

Dave Bennett
  • 10,996
  • 3
  • 30
  • 41
  • Thanks @Jerome-B & Dave for the input. When using the 'connect result nodes' options, all relationships seem to disappear, but that isn't the case with the above solution. Appreciate the help :) – MShariff Jun 11 '17 at 16:20
2

The autocomplete is 'Connect result nodes' in the Gear tab.

Jerome_B
  • 1,079
  • 8
  • 15