Chasing cats on the London Underground

James Whisnant

Using Python and Neo4j

http://adailypinch.com/wp-content/uploads/Screen-Shot-2015-01-24-at-11.30.28-PM.png

How cats see the world

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

http://www.bbc.co.uk/london/travel/downloads/tube_map.html

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.

http://www.mike2.com/wp-content/uploads/2013/01/Ceiling-Cat-Visa.jpg

Basil

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

What is a graph database?

 

http://blog.recursiveprocess.com/wp-content/uploads/2013/09/cat_with_calculator-600x450.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

Show me the Data!

https://www.starbase118.net/ufc913/wp-content/uploads/2015/04/data_spot_work_TNG.jpg

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

Two node case

http://relaxedcat.com/wp-content/uploads/2013/02/confused-cat.jpg

Three node case

http://fadmagazine.com/wp-content/uploads/idea-cat.jpg

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

http://zootcadillac.deviantart.com/art/My-god-It-s-full-of-stars-58121966

You're doing it wrong!

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

Look at some python code.

http://img2.wikia.nocookie.net/__cb20131016174949/animaljam/images/3/34/Cat-fixing-computer-engineer.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.

http://www.bordobello.com/wp-content/uploads/2013/05/beer-cat-15.jpg

cats

By James Whisnant

cats

Chasing cats around the Underground, using Python and Neo4j.

  • 2,402
Loading comments...

More from James Whisnant