Finding unconnected nodes

20 views
Skip to first unread message

David Rader

unread,
Jan 6, 2017, 5:41:46 PM1/6/17
to Neo4j
Have a neo4j database of a community with 1040 people, over 400 groups, parents and children (and grandparents).  328 of the groups have a person assigned to provide care to the group. People can be in multiple groups, of course.  The resulting graph is pretty dense.
I need to find the people who are not in a group with a care person assigned.  Currently doing a kludge by exporting a csv list to Excel and creating pivot tables to isolate the loners.

Almost all of the examples of graph analysis are based on tracing the connected paths.  I'm looking for tips on finding the unconnected people and groups.

Pointers to a reference book or article would be appreciated.  A reply post with some query patterns would be appreciated, too.

Thanks
Dave

Clark Richey

unread,
Jan 6, 2017, 5:43:51 PM1/6/17
to ne...@googlegroups.com
Can you provide a short graph gist of what a connected person / group would look like and what you want to find?

--------
Clark Richey
--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Hunger

unread,
Jan 6, 2017, 6:15:28 PM1/6/17
to ne...@googlegroups.com
You can use a path-expression in a WHERE condition.

MATCH (g:Group) WHERE NOT (g)<-[:CARETAKER_OF]-()
MATCH (p:Person)-[:IN_GROUP]->(g)
RETURN g, collect(p) as members

Cheers, Michael

To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.

David Rader

unread,
Jan 7, 2017, 1:01:57 PM1/7/17
to Neo4j
Perfect, Michael.  Thanks.

This is the actual query I used (with annotations):
MATCH (g:HOUSEHOLD) WHERE NOT (g)<-[:SERVES]-()         // I use secondary labels for subsets of :GROUP; deacons only serve :HOUSEHOLDS, so the other GROUPS are not included
MATCH (p:PERSON)-[:MEMBER_OF]->(g)                                  // simple substitution of relationship and node labels
RETURN g.ShortName, collect(p.GivenName) as members Order by g.ShortName  // just the names ... 

Perfect.

On Friday, January 6, 2017 at 3:15:28 PM UTC-8, Michael Hunger wrote:
You can use a path-expression in a WHERE condition.

MATCH (g:Group) WHERE NOT (g)<-[:CARETAKER_OF]-()
MATCH (p:Person)-[:IN_GROUP]->(g)
RETURN g, collect(p) as members

Cheers, Michael
On Fri, Jan 6, 2017 at 11:43 PM, Clark Richey <clark....@gmail.com> wrote:
Can you provide a short graph gist of what a connected person / group would look like and what you want to find?

--------
Clark Richey

On Jan 6, 2017, at 17:41, David Rader <rader...@gmail.com> wrote:

Have a neo4j database of a community with 1040 people, over 400 groups, parents and children (and grandparents).  328 of the groups have a person assigned to provide care to the group. People can be in multiple groups, of course.  The resulting graph is pretty dense.
I need to find the people who are not in a group with a care person assigned.  Currently doing a kludge by exporting a csv list to Excel and creating pivot tables to isolate the loners.

Almost all of the examples of graph analysis are based on tracing the connected paths.  I'm looking for tips on finding the unconnected people and groups.

Pointers to a reference book or article would be appreciated.  A reply post with some query patterns would be appreciated, too.

Thanks
Dave

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages