Hi,
I am trying to figure out how to efficiently calculate the number of
distinct triangles in a undirected sub-graph.
For example number of triangles in a users graph which include him and his
friends.
Count should include triangles including user
(me)-[:KNOWS]-(a)-[:KNOWS]-(b) but also (c)-[:KNOWS]-(a)-[:KNOWS]-(b) as
long as a,b,c are all my(me) friends
If (a)-(b)-(c) is included in count, (b)-(a)-(c) should not (undirected,
distinct).
So far I have reached the following query, but it is inefficient and times
out very quickly as size of graph increases:
//Get user and all his friends
match (a)-[:FRIENDS*0..1]-(me:User{Id:"1234"}),
//need to get user again since we filter by Id
(b)-[:FRIENDS*0..1]-(me),
(c)-[:FRIENDS*0..1]-(me)
where (a:User)-[:FRIENDS]-(b:User)-[:FRIENDS]-(c:User)-[:FRIENDS]-(a:User)
//need to filter out same triangles with different order, distinct is not
enough
and (a.Id > b.Id) and (b.Id > c.Id)
return distinct a.UserName, b.UserName, c.UserName
I would like to know if there is better option, or optimizations that can
be run on this query.
Thanks,
Shmulik
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.