Andmestruktuur
Võtame kõik ahelad, mis on toodete vahel (läbi ostude) e kahe ostulised ahelad.
Meil on kolm kahe ostulist ahelat – punane (42 -> 43), sinine (42 ->43) ja rohelin (43 -> 48)
neo4j-sh (23,40)$ START a=node(*) MATCH a<-[:RELATED_TO]-(b)-[:FOLLOWED_TO]->(c)-[:RELATED_TO]-(d) RETURN a, d;
+-----------------------------------------------------------------------------+
| a | d |
+-----------------------------------------------------------------------------+
| Node[42] | Node[43] |
| Node[42] | Node[43] |
| Node[43] | Node[48] |
+-----------------------------------------------------------------------------+
3 rows
Saame kolm teekonda.
Unikaalsed teekonnad:
neo4j-sh (23,40)$ START a=node(*) MATCH a<-[:RELATED_TO]-(b)-[:FOLLOWED_TO]->(c)-[:RELATED_TO]-(d) RETURN DISTINCT a, d;
+—————————————————————————–+
| a | d |
+—————————————————————————–+
| Node[42] | Node[43] |
| Node[43] | Node[48] |
+—————————————————————————–+
2 rows
Loendame teekonnad:
neo4j-sh (EE-EE000023,40)$ START a=node(*) MATCH a<-[:RELATED_TO]-(b)-[:FOLLOWED_TO]->(c)-[:RELATED_TO]-(d) RETURN DISTINCT a, d, COUNT(a);
+—————————————————————————————-+
| a | d | COUNT(a) |
+—————————————————————————————-+
| Node[43]} | | 1 |
| Node[42] | Node[43] | 2 |
+—————————————————————————————-+
2 rows
Kolme ostuline ahel.
neo4j-sh (23,40)$ START a=node(*) MATCH a<-[:RELATED_TO]-(b)-[:FOLLOWED_TO*2]->(c)-[:RELATED_TO]-(d) RETURN DISTINCT a, d, COUNT(a);
+————————————————————————————–+
| a | d | COUNT(a) |
+————————————————————————————–+
| Node[42] | Node[48] | 1 |
+————————————————————————————–+
1 row