# Chasing cats on the London Underground

James Whisnant

## How cats see the world

http://img.ifcdn.com/images/0e8e7cb3756b171bb1f5162c72e5bd079515127ac56e2f8efdf2d797dd805903_1.jpg

http://colouringbook.org/Holidays/Xmas/CAT/cat_line_art_kitty_icon_black_white_line_art_christmas_xmas_stuffed_animal_coloring_book_colouring-1331px.png

## I am qualified!

• I have an Oyster card.
• I own (*) two cats.
• I have heard of (*) Neo4j.

# Rosemary

`https://i.chzbgr.com/full/2252433152/h554CB824/`

## What this talk is about.

• Chasing cats.
• Graph databases? Do I need one?
• Neo4j and Cypher.
• Python and py2neo.
• Viewing simulations in a browser.
• Looking at python code.

http://www.roflcat.com/images/cats/Wise_Cat.gif

## What this talk is not about.

• An optimal solution.
• The inner workings of Neo4j.
• Graph theory.
• Dogs.

http://orig03.deviantart.net/a3b0/f/2013/194/f/2/cat_vs_dog_by_candyboy123-d6d9wic.jpg

## Neo4j

• Graph database (Java)
• Services  on different ports
• Browser
• Shell
• REST API

http://neo4j.com/blog/caching-partial-traversals-in-neo4j/

## Problem

• Use provided stations and connections.
• There are n (humans, cat) pairs.
• Randomly placed, different one to another.
• Cats move randomly (*).
• Humans are smart (*).
• "Must move" each round.
• Stations can close.
• Isolation happens.
• Run 100k iterations (*).
https://xkcd.com/231

# Furball

http://previews.123rf.com/images/fieldsphotos/fieldsphotos1202/fieldsphotos120200073/12533583-A-cute-Egyptian-Mau-cat-plays-with-a-red-ball-of-yarn--Stock-Photo.jpg

## Guess the outcome (1 pair).

• One node
• Two nodes
• Three nodes
• Four nodes
• ...

http://i.telegraph.co.uk/multimedia/archive/03188/maru_the_cat__3188629b.jpg

Cat trap.

• Human finds cat always.
• Human finds cat sometimes.
• Human never finds cat.
• ...

## One node (oh noes!)

https://s-media-cache-ak0.pinimg.com/736x/86/0d/bb/860dbbeff31df9a6954e359b3c230009.jpg

## Three node case

Four node case

http://cl.jroo.me/z1/Q/x/A/e/a.daa-small-Cat-play-golf.jpg

Fore!

## Interactive Neo4j demo

• Bullet One
• Bullet Two
• Bullet Three

http://garak.wimp.com/images/sthumbs/2015/09/a7532559b6822582e6358f4462877572_5.jpg

# neo4j-shell

## py2neo

• Node, Relationship, Graph
• Relationship directionality
• Bound vs Unbound objects

https://i.imgur.com/OB3o0tv.jpg

## Gotcha!

• REST is slow (*).
• py2neo Batch API is confusing.
• Subgraph analysis to end early (*).

https://i.ytimg.com/vi/MoE1uc27aww/maxresdefault.jpg

# Questions

https://s-media-cache-ak0.pinimg.com/736x/d6/f3/4c/d6f34c348d4e9fb7791099f0f112a448.jpg

# Lightning talks

http://laughingsquid.com/lightning-cat-vs-the-iceland-volcano/

# After meeting-beer.

#### cats

By James Whisnant

# cats

Chasing cats around the Underground, using Python and Neo4j.

• 4,749