I started playing with Neo4J (the graph database). It seems like great software, but I found the documentation pretty sparse and opaque. It took me 16 hours to do all of this, so I’m hoping it will save you 15.5 hours of fumbling around the Internet.
Why is Neo4j powerful?
“A traditional relational database may tell you the average age of everyone in this pub, but a graph database will tell you who is most likely to buy you a beer.”
To install on Mac, use homebrew on terminal:
“brew install neo4j”
Start the server.
Note: stop the server with the “neo4j stop” command
The database exists in the “/usr/local/Cellar/neo4j/1.9.4/libexec/data/graph.db/” directory. If you delete the files in here, you’ve deleted your database (and can repopulate it). I’ve nuked by database a few times while debugging. Note that homebrew install Neo4j version 1.9.4 and that the latest version is currently 2.0.
Getting Data In
I tried using Gephi and the Neo4j plugin that is available. I wasn’t quite able to get the data to look the way I wanted. I would have loved to use this plugin, but I just couldn’t figure out how to get everything to play together nicely. Plus, whenever I’d export the neo4j database it would corrupt the files and the server would crash–I’m sure this had more to do with what I was doing and less with the software though.
“pip install neo4jrestclient” or “easy_install neo4sjrestclient”
Here is my code to get the data into the database (Python):
We can watch the number of nodes and relationships grow.
Now we can run a basic query on the data from node to node using Cypher. Here is the code:
And here is the output:
And another example:
I’m planning on eventually visualizing this data in D3. If you want to stay in the loop, sign up and I’ll keep you updated (your email won’t be shared with anyone else):