Remove automorfism in cypher result

28 views
Skip to first unread message

Jaroslav Ramba

unread,
Mar 3, 2015, 7:08:21 AM3/3/15
to ne...@googlegroups.com
Hi,

how can I remove automorfism in cypher result? This example http://console.neo4j.org/?id=tz1lwc has 12 rows in result and 10 are "duplicity" (automorfism). I want only 2 triangles in result, which actually are in the database.  As you can see in the result graph, there are only two triangles, but table has 12 rows. 

I know that it is propably caused by traversing, but all I need these 2 unique triangles.

Michael Hunger

unread,
Mar 3, 2015, 2:26:17 PM3/3/15
to ne...@googlegroups.com
MATCH (a)-[r]-(b)-[q]-(c)-[o]-(a)
WHERE id(a)<id(b) AND id(b)< id(c)
RETURN a,r,b,q,c,o

--
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.

Jaroslav Ramba

unread,
Mar 4, 2015, 7:15:40 AM3/4/15
to ne...@googlegroups.com
Thank you Michael

Jaroslav Ramba

unread,
Mar 5, 2015, 2:24:38 PM3/5/15
to ne...@googlegroups.com
I need to apply this for any cypher query though. It means that I do not know what graph pattern will be in MATCH clause (I am developing a method that accepts any cypher query and returns only unique results of the query - without duplicates). I could not apply the query above unless I would parse MATCH clause.

So I am looking for a general part of query (some kind of WHERE clause I guess) that I could add to user’s cypher query to preserve from returning duplicates.

Jared Beekman

unread,
Mar 8, 2015, 7:46:09 AM3/8/15
to ne...@googlegroups.com
I modified your query to this:
MATCH (a)-[r]->(b)-[q]->(c)-[o]->(a)
RETURN a,r, b,q,c,o
and returned 6 rows. the DISTINCT modifier didn't help in the return (in either query I may add).

Hopefully this is what you are looking for. Note, sans arraows (>) you are getting bi-directional graphs which is probably why it's doubling.
Reply all
Reply to author
Forward
0 new messages