Prev |  | Next

## 7.16. Complex similarity computations

### 7.16.1. Calculate similarities by complex calculations

Here, a similarity between two players in a game is calculated by the number of times they have eaten the same food.

Query.

    START me=node:node_auto_index(name = "me")
    MATCH me-[r1:ATE]->food<-[r2:ATE]-you
    ==== me,count(distinct r1) as H1,count(distinct r2) as H2,you ====
    MATCH me-[r1:ATE]->food<-[r2:ATE]-you
    RETURN sum((1-ABS(r1.times/H1-r2.times/H2))*(r1.times+r2.times)/(H1+H2)) as similarity

The two players and their similarity measure.

Result

similarity
1 row
0 ms
`-30.0`

Figure 7.20. Graph

Copyright © 2013 Neo Technology

Prev | Up | Next
| Home |