Exploring homonymous cities for deeper insights with Neo4j

Rajesh Gaddipati
3 min readOct 26, 2020

Exploring correlated data in any context is quite interesting. Neo4j is an amazing tool, which is useful for such exploration and insights. By relating key words mapped with correlations, we can share knowledge articles or research papers spread across various locations.

Let us dive into an interesting example, which validates this:

You will find that there are various cities around the world, which share the same name, homonymous cities. By finding the link between cities or states/prefectures across world, we can explore history with geographical data.

If you are curious to know about homonymous cities, my talk at NODES2020 can be watched here:

https://www.youtube.com/watch?v=Fm2rLzJNN8s&t=642s

Are you interested to build instantly a knowledge graph and know more about homonymous cities in your country, you can do it in 5 steps, and in less than 15 mins to create your own visualization and enhance further.

Let’s start building our knowledge graph on homonymous cities.

Step1: Install Neo4j Desktop

Download: https://neo4j.com/download/

Step2: Create Graph Database, Start it and open Neo4j Browser

Ref: https://neo4j.com/developer/neo4j-desktop/

Fig1. Open Neo4j Browser

Step3: Execute below Cypher query to load data in Neo4j Browser query pane:

LOAD CSV WITH HEADERS
FROM ‘https://docs.google.com/spreadsheets/d/e/2PACX-1vSU95vVX-2lNrGyqQjeg0PHsY20hsBmNMDWsg092i6KlBMjLJUeeuIBMJe_5P76QhplTYM8cLJtArU3/pub?gid=925600830&single=true&output=csv
AS row
MERGE (Ci:City{name:row.City})
MERGE (Na:Nation{name:row.Nation})
CREATE (St:State{name:row.State})
MERGE (Ci)-[:City_of]-> (St)
MERGE (St)-[:State_of]->(Na)

Fig2. Execute cypher query to load homonymous cities data

Step4: Open Neo4j Bloom and create new perspective, and enter expression in search bar:

Fig3. Open Neo4j Bloom

Example: City State United Kingdom

Fig4. Enter expression to visualize
Fig 5. Homonymous cities in United Kingdom

All the cities in above graph are homonymous.

For Example:

Right click on city “Nelson”, then Expand , click on relationship “City_of” to see state name which also has a city with same name “Nelson”.

Fig6. Deep insights on a single city
Fig7. Exploring correlations

Follow same process, to expand State “Nelson” with relationship “State_of”, we see that Nelson is state in New Zealand.

(Or) City State “$Nation”, Enter Nation name.

Step5: Register to Neo4j community for great content from Neo4j Graph experts around world to improve your skills.

https://community.neo4j.com/

Please check below article in neo4j community page on exploring correlated data.

Disclaimer: Due to Geographical or Political conditions, city names are tend to change.

--

--