# Neo4j Reduce in Action

## May 7: Radio, One Month Graph Challenge

May 7 · 3 min read

# Welcome word

In this series of small posts I do one simple graph daily. Domain model of graph somehow related to day’s history, some historical event, celebration or person. I do this challenge to learn Neo4j Data Modeling and Cypher. Every day. One month. Follow me. Maybe you will be inspired and next month would be yours One Month Graph Challenge. #OMGChallenge

# Domain model

May 7th in history of science and technology as the birthday of Radio. In 1895, at a meeting of the Russian Physico-Chemical Society, the Russian physicist Alexander Stepanovich Popov made a report and demonstrate first radio receiver in the world created by him.

For my today’s session I want to touch paths.

# Graph

Today’s graph would be super simple. I grab a list of FM frequency of Moscow radio stations. Here you can find my favorite Comedy Radio on 102,5 FM and 100,1 FM of Silver Rain. Also important to notice relationships of each node (wave) have property that store a difference between neighbours.

Mostly the difference between each node (radio station wave) is 0.4 MHz. Must be easy to find a longest difference between 2 stations:

`MATCH (w1:Wave)-[d:NEXT]->(w2:Wave)RETURN max(d.diff)`

Answer is 0.5. Ok. It is easy. What about longest difference of 2 stations with one in between? To find the result manually, for example for 5 radio stations we need to sum distance of 3 paris: from 1 to 3 vs. from 2 to 4 vs. from 3 to 5.

Maybe exists more elegant way to sum the diffs. But the result of top 3 longest diffs of waves in chain anyway would be like this:

# Resume

With this small example easy to recognise the power of Cypher quering. Change the value 2 to something bigger in the last query and with same query you got result for distance between requested longness of nodes (stations). And this is awesome.

I started explore path related stuff little by little. It is a wide area and need more examples and want more investigations in future topics. Would be good to hear your suggestions of this small graph, guys.

Small musical bonus for radio lovers.

Written by