Building a Heavyweight Boxing Graph

Yuvan Hirani
Neo4j Developer Blog
2 min readAug 17, 2018

For the past week I have been doing a work placement at Neo4j in London. This week I have been doing Cypher, Python, and HTML programming.

I’m a big fan of heavyweight boxing so I wanted to make a graph on this. I created CSV files of some boxers and the fights between them. You can see the CSV files below:

Heavyweight Boxers — contains personal information about fighters and the belts they hold
Heavyweight Fights — contains winner, loser, and YouTube highlights link

This is how I loaded the CSV files into Neo4j:

load csv with headers from "https://raw.githubusercontent.com/WATFORD4LIFE/boxing_rec2.0/master/boxer.csv" AS row
merge(boxer:Boxer{name:row.boxer})
set boxer += row
set boxer.dob = datetime(row.dob)
LOAD CSV WITH HEADERS FROM "https://raw.githubusercontent.com/WATFORD4LIFE/boxing_rec2.0/master/fights.csv" AS rowMATCH (winner:Boxer {name: row.winner})
MATCH (loser:Boxer {name: row.loser})
MERGE (winner)-[beat:BEAT]->(loser)
SET beat.highlights = row.highlights
Neo4j Browser visualisation of the whole graph

After that I wrote some queries on the Neo4j browser against the boxing graph.

This query finds Wladimir Klitschko:

MATCH (boxer:Boxer {name:”Wladimir Klitschko”})
RETURN boxer

And this one finds the fights that Anthony Joshua participated in:

MATCH (aj:Boxer {name: 'Anthony Joshua'})-[:BEAT]-(opponent)
RETURN aj.name, opponent.name, aj.dob, opponent.dob
Anthony Joshua’s fights

I also created a Python application that queries this database. Below is a screenshot of all the fights:

The code for the application is in this GitHub repository.

Summary

This week was very fun and I learnt a lot. One of the challenges was the Python aspect but after a few day it was a lot better .

--

--