Neo4J

Neo4j is an open-source graph database, implemented in Java. The developers describe Neo4j as “embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables”. Neo4j is the most popular graph database.

Python Client

py2neo

# connect to graph
authenticate("localhost:7474", "neo4j", "passwd")
graph = Graph("http://localhost:7474/db/data/")

# create unique
graph.schema.create_uniqueness_constraint('Person', 'name')

# add nodes
graph.create(Node.cast('Person', {"name": "Alice"}))
graph.create(Node.cast('Person', {"name": "Bob"}))

# add relationship
source = graph.merge_one("Person", "name", "Alice")
target graph.merge_one("Person", "name", "Bob")
graph.create_unique(Relationship(source, "FRIEND", target))

# update property
alice = graph.merge_one("Person", "name", "Alice")
alice["age"] = 30
alice.push()

Graph Algorithms

shortestPath, dijkstra

POST http://localhost:7474/db/data/node/72/paths

Headers
Accept: application/json
Authorization: Basic bmVvNGo6cGFzc3dk

Body
{
  "to" : "http://localhost:7474/db/data/node/77",
  "max_depth" : 5,
  "relationships" : {
    "type" : "FRIEND",
    "direction" : "out"
  },
  "algorithm" : "shortestPath"
}

Graph Analystic

pagerank, closeness_centrality, betweenness_centrality, triangle_count,
connected_components, strongly_connected_components

kbastani/docker-neo4j

docker run -d -p 7474:7474 -v /Users//path/to/neo4j/data:/opt/data –name graphdb kbastani/docker-neo4j

kbastani/neo4j-graph-analytics/

References

#1 from DB-Engines Ranking of Graph DBMS

http://www.kennybastani.com/2014/11/using-apache-spark-and-neo4j-for-big.html

Big Data Stack: HDFS, Kibana, ElasticSearch, Neo4J, Apache Spark

Advertisements

4 thoughts on “Neo4J

  1. Pingback: Kibana | datayo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s