SlideShare a Scribd company logo
NEO4J OPEN SOURCE GRAPH
DATABASE
Presented by Mark Maslyn – mmaslyn@msn.com to
Denver Open Source User Group (4/7/15) and
Graph Nerds of Boulder (5/14/15)
THREE PARTS TO THIS NEO4J PRESENTATION
• What Are Graph Databases and Why Are They
Useful
• Neo4J Application Modes and Java API Syntax
• Demo Animal Guessing Game using Neo4J
Decision Tree
WHAT ARE GRAPH DATABASES ?
• Graph Databases are a type of NoSQL ( non-
relational) database
• In a Graph Database entities (nouns) are
represented as nodes
• Relationships are represented by edges
connecting nodes
• Both nodes and relationships can have properties
FRIEND-OF EXAMPLE
FRIEND-OFFRIEND-OF
Properties:
Name: Mark M
Language: Java
Properties:
Name: Tom M
Language: Java
Properties:
Name: Tom F
Language: Scala
SOME COMPANIES AND INDUSTRIES WITH GRAPH
DATABASE APPLICATIONS
• Social Media (Facebook, LinkedIn, Twitter)
• Configuration Management (Assimilation
Systems)
• Retail Recommendation (Walmart)
• Resource Authorization (Telenor)
• Fraud Detection ( Banks and Credit Card
Companies)
• Online Education (Pearson)
• Bioinformatics (Bio4j)
WHERE GRAPH DATABASES ARE
ADVANTAGEOUS
• Can provide a more natural representation
for the data
• Can give a faster query response
• Recommendation engines
EXAMPLES WHERE A GRAPH REPRESENTATION
IS A NATURAL MODEL
FLIGHT ROUTE MAP – SF TO NY
3
4
1
2
1.5
2
3
1
1
3
1.5
FLYS-TO
FLYS-TO FLYS-TO
FLYS-TO
FLYS-TO
FLYS-TOFLYS-TO
FLYS-TO
FLYS-TO
FLYS-TO
TREE OF LIFE
http://oceanexplorer.noaa.gov/okeanos after Woese (1990)
TWO LEVEL PROTEIN NETWORK DIAGRAM
From CYTOSCAPE.ORG
Two Level Tree
p53
EXAMPLE OF QUERY SPEED-UP
FRIEND-OF-A-FRIEND-OF-A-FRIEND …
From Vukotic, et al (2014)
EXECUTION TIME RDBMS VS GRAPH DATABASE FOR
DIFFERENT DEPTHS OF FRIEND SEARCH (1000 FRIENDS)
Depth Execution Time (sec) Count Result
2 0.028 ~900
3 0.213 ~999
4 10.273 ~999
5 92.613 ~999
Depth Execution Time (sec) Count Result
2 0.04 ~900
3 0.06 ~999
4 0.07 ~999
5 0.07 ~999
MYSQL RDMS
NEO4J
From Vukotic, et al (2014)
EXAMPLES OF RECOMMENDATIONS BASED
ON GRAPH CONNECTIONS AND CONTENT
TYPICAL APPROACHES TO GENERATING
RECOMMENDATIONS (AND PREDICTIONS)
• COLLABORATIVE FILTERING – Recommendations based on
common attributes between you and / or your connections –
Online dating model
• CONTENT BASED FILTERING - Deriving a second level of
information from the data and use that to derive
recommendations – Content classification model
• GRAPH TOPOLOGY – Infer links based on graph topology.
COLLABORATIVE FILTERING RECOMMENDATION BASED ON
FRIENDS CHOICES – I WILL LIKE WHAT MY FRIENDS LIKE
FRIEND-OFFRIEND-OF
Properties:
Name: Mark M
Language: Java
Properties:
Name: Tom M
Language: Java, Scala
Movie: Empire Strikes Back
Properties:
Name: Tom F
Language: Scala, Java
Movie: Raiders of the Lost Ark
CONTENT BASED RECOMMENDATIONS BASED ON
CLASSIFICATION OF FRIENDS MOVIE SELECTION
FRIEND-OFFRIEND-OF
Properties:
Name: Mark M
Language: Java
Properties:
Name: Tom M
Language: Java, Scala
Movie: Empire Strikes Back
Properties:
Name: Tom F
Language: Scala, Java
Movie: Raiders of the Lost Ark
CONTENT CLASSIFICATION BASED ON TERMS
SPORTS CATEGORY
FOOTBALL BASEBALL
Broncos
Seahawks
Ronnie HillmanPeyton Manning
Rockies
1 .. N SPORTS
Russell Wilson
CATEGORY
SPORT
TEAM
PLAYER
1 .. N TEAMS
1 .. N PLAYERS
FINDING RELATIONSHIPS BASED ON GRAPH TOPOLOGY
FRIEND-OFFRIEND-OF
Transitive Relationship
A FRIEND OF B, B FRIEND OF C, Therefore High
Probability A FRIEND OF C
CONCLUSION: A TRIADIC CLOSURE OR MY FRIENDS ARE
LIKELY TO BE FRIENDS WITH EACH OTHER
FRIEND-OFFRIEND-OF
Properties:
Name: Mark M
Language: Java
Properties:
Name: Tom M
Language: Java
Properties:
Name: Tom F
Language: Scala
TRIADIC CLOSURE
FRIEND RELATIONSHIPS BETWEEN PARTNERS IN A
KARATE CLUB – BEFORE SPLIT INTO TWO CLUBS
From Zachary (1977)
KARATE CLUBS MEMBERSHIP AFTER SPLIT
From Zachary (1977)
PART II – NEO4J GRAPH DATABASE MODES
AND JAVA API SYNTAX
NEO4J GRAPH DATABASE MODES
• Embedded Mode Uses Local NEO4J Jar Files
• Server Mode Uses RESTFul API’s
• Browser Client Mode Using CYPHER Query
Language
EMBEDDED MODE WITH JAVA API – OPENING
A GRAPH DATABASE
private static GraphDatabaseService graphDb;
private static String ANIMAL_DATABASE_LOC =
"/home/ubuntu/animal_game/animal.db";
public AnimalGame() {
// open the graph database
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(
ANIMAL_DATABASE_LOC);
// enable clean db shutdown on Ctrl-C
registerShutdownHook( graphDb );
}
JAVA API – CREATING AN INDEX
// create index using a combination of the node label and
the name property
try (Transaction tx = graphDb.beginTx()) {
graphDb.schema().indexFor(NodeLabels.PERSON).on(
"name").create();
tx.success();
}
JAVA API – CREATING A DATABASE NODE AND
SETTING PROPERTY VALUES
// create node
Node node = graphDb.createNode();
// add label to identify what group the node belongs to
node.addLabel(nodeLabel);
// set property values
node.setProperty(AnimalConstants.NAME, name);
node.setProperty(AnimalConstants.TEXT, text);
node.setProperty(AnimalConstants.TYPE, nodeType);
// make a list of possible answers (answerList)
// these match with relationships
node.setProperty(AnimalConstants.ANSWERS, answerList);
JAVA API – CREATING RELATIONSHIPS
BETWEEN NODES
public enum RelTypes implements RelationshipType {
YES,
NO
}
public void createRelationship(Node node1,
Node node2,
RelTypes rt) {
// relationship between node1 and node2
// direction is from node1 to node2
node1.createRelationshipTo((Node) node2, rt);
}
JAVA API - QUERYING THE DATABASE FOR A
NODE BY LABEL AND NAME
public Node getNodeByLabelAndName(String nodeName) {
Node node = null;
ResourceIterable<Node>nodeList =
graphDb.findNodesByLabelAndProperty(
NodeLabels.PERSON, "name", nodeName);
If (nodeList != null) {
try (Transaction tx = graphDb.beginTx()) {
for ( Node nodeL : nodeList )
node = nodeL;
tx.success();
}
}
return node;
}
NEO4J SERVER RESTFUL API
• Neo4J Server Provides Fine-Grained REST Calls
• Returns JSON Content Type
• Higher Level Libraries Available for Java, .NET, Python,
etc. to Wrap the Lower Level Calls
NEO4J SERVER RESTFUL API REQUEST /
RESPONSE WITH DETAILED AVAILABLE URL’S
RESPONSE
{
"extensions": {},
"node": "http://localhost:7474/db/data/node",
"node_index": "http://localhost:7474/db/data/index/node",
"relationship_index": "http://localhost:7474/db/data/index/relationship",
"extensions_info": "http://localhost:7474/db/data/ext",
"relationship_types": "http://localhost:7474/db/data/relationship/types",
"batch": "http://localhost:7474/db/data/batch",
"cypher": "http://localhost:7474/db/data/cypher",
"indexes": "http://localhost:7474/db/data/schema/index",
"constraints": "http://localhost:7474/db/data/schema/constraint",
"transaction": "http://localhost:7474/db/data/transaction",
"node_labels": "http://localhost:7474/db/data/labels",
"neo4j_version": "2.1.7"
}
REQUEST (GET): http://localhost:7474/db/data
NEO4J SERVER RESTFUL API – DRILLING DOWN FOR
META-DATA FROM ANIMAL DATABASE
REQUEST: http://localhost:7474/db/data/relationship/types
JSON RESPONSE:
[
"YES",
"NO"
]
RETRIEVING A SINGLE NODE AND ITS PROPERTIES
REQUEST: http://localhost:7474/db/data/node/0
JSON RESPONSE:
{
…..
"metadata": {
"id": 0,
"labels": [
“ANIMALS"
]
},
"data": {
"text": "Does the animal live on land ?",
"name": "start",
"answers": [
"Y/YES",
"N/NO",
"Q/QUIT"
],
"type": "question"
}
}
RETRIEVING A NODE USING THE RESTFUL LIBRARY
FROM JAVA CODE
private static GraphDatabaseService graphDb;
private static String ANIMAL_DATABASE_URL =
“http://localhost:7474/db/data”;
// public constructor
public AnimalGame() {
// connect to the graph database server
graphDb = new RestGraphDatabase(
ANIMAL_DATABASE_URL);
// wrap the request and retrieve the node
Node startNode =
graphDb.findNodesByLabelAndProperty(
NODE_LABEL,
“name”,
“start”);
NEO4J BROWSER BASED WEB ADMIN CLIENT
• Browser Connects to Neo4J Server.
• Graphically Displays Database Nodes and Relationships in a
Dashboard. Can Drill Down on Each Node.
• Allows User to Execute Cypher Queries on Database From
the Browser.
NEO4J BROWSER WEB ADMIN DASHBOARD
CLICK ON A NODE FOR MORE INFO
CYPHER QUERY LANGUAGE
• Cypher is Neo4J’s version of SQL
• Queries can be entered programmatically in Java
or through the browser interface
• Queries can retrieve nodes, relationships,
property values or call functions such as return
“shortest path traversal”
• Declarative syntax using “Ascii Art”
NODES - CYPHER SYNTAX
Cypher uses “Ascii Art” syntax that reflects graph elements. Nodes
are represented by parentheses “( )”, relationships by arrows “-->”.
The arrow head indicates the direction of the relationship
Adding constraints “find two Person group nodes a and b that are
connected by a relationship”.
Match (a) –-> (b)
Return a.name, b.name
Match (a:Person) --> (b:Person)
Return a.name, b.name
RELATIONSHIPS - CYPHER SYNTAX
Anonymous relationships match all relationship and are indicated
by the arrow alone
This query syntax is used to find two nodes a and b that are
connected by the specific “ACTED_IN” relationship to match
actors with movies
Match (a) --> (b)
Match (a) –[:ACTED_IN]-> (b)
PROPERTY GRAPH EXAMPLE FOR A MOVIE
DATABASE
SIX DEGREES OF KEVIN BACON GAME – HOW
MANY LINKS ARE REQUIRED TO CONNECT AN
ACTOR TO KEVIN BACON ?
Kevin Bacon (left) and Tom Hanks in Apollo 13 (1995)
CYPHER QUERY FOR SIX DEGREES OF KEVIN BACON
FOR MEG RYAN USING NEO4J SHORTEST PATH
FUNCTION
MATCH p=shortestPath(
(b:Person {name:"Kevin Bacon"})-[*]-(m:Person {name:"Meg
Ryan"})
)
RETURN p
AND THE ANSWER IS …
Meg Ryan’s “Bacon” Number is 2
NEO4J DECISION TREE – ANIMAL GUESSING GAME
Mammal ?
Has Stripes ? Slithers ?
Does it Growl ?
Has Trunk ?
Zebra ?Tiger ?
Elephant ?
Snake?
YES
YES
YES
YES
YES
NO
NO
NO
PART III
DEMO ANIMAL GUESSING GAME – AUDIENCE
VOLUNTEER REQUESTED
A Final Comment on Connected Graphs
(Paraphrasing) Imagination is the relationship
connecting two nodes…
TWO BOOKS I RECOMMEND FOR MORE
INFORMATION ON GRAPH THEORY AND NEO4J
Graph Theory Neo4J
By Jennifer Golbeck, 2013 By Aleksa Vukotic, et al 2014

More Related Content

What's hot

How to Build your Training Set for a Learning To Rank Project
How to Build your Training Set for a Learning To Rank ProjectHow to Build your Training Set for a Learning To Rank Project
How to Build your Training Set for a Learning To Rank Project
Sease
 
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
David Fombella Pombal
 
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
Sease
 
Semantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQLSemantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQL
Daniel D.J. UM
 
Lucene And Solr Document Classification
Lucene And Solr Document ClassificationLucene And Solr Document Classification
Lucene And Solr Document Classification
Alessandro Benedetti
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLEmanuele Della Valle
 
Enhance discovery Solr and Mahout
Enhance discovery Solr and MahoutEnhance discovery Solr and Mahout
Enhance discovery Solr and Mahout
lucenerevolution
 
Two graph data models : RDF and Property Graphs
Two graph data models : RDF and Property GraphsTwo graph data models : RDF and Property Graphs
Two graph data models : RDF and Property Graphs
andyseaborne
 
Globe seminar
Globe seminarGlobe seminar
Globe seminar
Xavier Ochoa
 

What's hot (13)

How to Build your Training Set for a Learning To Rank Project
How to Build your Training Set for a Learning To Rank ProjectHow to Build your Training Set for a Learning To Rank Project
How to Build your Training Set for a Learning To Rank Project
 
4 sw architectures and sparql
4 sw architectures and sparql4 sw architectures and sparql
4 sw architectures and sparql
 
Ontologies in RDF-S/OWL
Ontologies in RDF-S/OWLOntologies in RDF-S/OWL
Ontologies in RDF-S/OWL
 
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH) Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
Neo4j Introduction (Basics, Cypher, RDBMS to GRAPH)
 
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
Rated Ranking Evaluator Enterprise: the next generation of free Search Qualit...
 
Semantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQLSemantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQL
 
Lucene And Solr Document Classification
Lucene And Solr Document ClassificationLucene And Solr Document Classification
Lucene And Solr Document Classification
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
Sparql
SparqlSparql
Sparql
 
Enhance discovery Solr and Mahout
Enhance discovery Solr and MahoutEnhance discovery Solr and Mahout
Enhance discovery Solr and Mahout
 
Two graph data models : RDF and Property Graphs
Two graph data models : RDF and Property GraphsTwo graph data models : RDF and Property Graphs
Two graph data models : RDF and Property Graphs
 
Data in RDF
Data in RDFData in RDF
Data in RDF
 
Globe seminar
Globe seminarGlobe seminar
Globe seminar
 

Viewers also liked

COSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jCOSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4j
Eric Lee
 
MyMobileWeb Certification Part II
MyMobileWeb Certification Part IIMyMobileWeb Certification Part II
MyMobileWeb Certification Part II
crdlc
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesIntegrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Mark Maslyn
 
2016 COSCUP ONOS
2016 COSCUP ONOS2016 COSCUP ONOS
2016 COSCUP ONOS
Yi Tseng
 
Document Classification with Neo4j
Document Classification with Neo4jDocument Classification with Neo4j
Document Classification with Neo4j
Kenny Bastani
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain RatioLecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Marina Santini
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesPeter Neubauer
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
Neo4j
 

Viewers also liked (8)

COSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4jCOSCUP 2016 Workshop : 快快樂樂學Neo4j
COSCUP 2016 Workshop : 快快樂樂學Neo4j
 
MyMobileWeb Certification Part II
MyMobileWeb Certification Part IIMyMobileWeb Certification Part II
MyMobileWeb Certification Part II
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesIntegrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
 
2016 COSCUP ONOS
2016 COSCUP ONOS2016 COSCUP ONOS
2016 COSCUP ONOS
 
Document Classification with Neo4j
Document Classification with Neo4jDocument Classification with Neo4j
Document Classification with Neo4j
 
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain RatioLecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
Lecture 4 Decision Trees (2): Entropy, Information Gain, Gain Ratio
 
Neo4j - 5 cool graph examples
Neo4j - 5 cool graph examplesNeo4j - 5 cool graph examples
Neo4j - 5 cool graph examples
 
Data Modeling with Neo4j
Data Modeling with Neo4jData Modeling with Neo4j
Data Modeling with Neo4j
 

Similar to Neo4J Open Source Graph Database

Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
Neo4j
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Databricks
 
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup MunichMorpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
Martin Junghanns
 
Morpheus - SQL and Cypher in Apache Spark
Morpheus - SQL and Cypher in Apache SparkMorpheus - SQL and Cypher in Apache Spark
Morpheus - SQL and Cypher in Apache Spark
Henning Kropp
 
AnzoGraph DB - SPARQL 101
AnzoGraph DB - SPARQL 101AnzoGraph DB - SPARQL 101
AnzoGraph DB - SPARQL 101
Cambridge Semantics
 
Gerry McNicol Graph Databases
Gerry McNicol Graph DatabasesGerry McNicol Graph Databases
Gerry McNicol Graph Databases
Gerry McNicol
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
proksik
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
snehapandey01
 
Applying large scale text analytics with graph databases
Applying large scale text analytics with graph databasesApplying large scale text analytics with graph databases
Applying large scale text analytics with graph databases
Data Ninja API
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
Athens Big Data
 
Neo4j (Part 1)
Neo4j (Part 1)Neo4j (Part 1)
Neo4j (Part 1)
Bibhuti Regmi
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
Sławomir Chrobak
 
Graph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemGraph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft Ecosystem
Marco Parenzan
 
Annotating search results from web databases-IEEE Transaction Paper 2013
Annotating search results from web databases-IEEE Transaction Paper 2013Annotating search results from web databases-IEEE Transaction Paper 2013
Annotating search results from web databases-IEEE Transaction Paper 2013
Yadhu Kiran
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
Myungjin Lee
 
Data translation with SPARQL 1.1
Data translation with SPARQL 1.1Data translation with SPARQL 1.1
Data translation with SPARQL 1.1andreas_schultz
 
The 2nd graph database in sv meetup
The 2nd graph database in sv meetupThe 2nd graph database in sv meetup
The 2nd graph database in sv meetup
Joshua Bae
 
Social Network Analysis, Semantic Web and Learning Networks
Social Network Analysis, Semantic Web and Learning NetworksSocial Network Analysis, Semantic Web and Learning Networks
Social Network Analysis, Semantic Web and Learning Networks
Rory Sie
 
NLP & DBpedia
 NLP & DBpedia NLP & DBpedia
NLP & DBpedia
kelbedweihy
 

Similar to Neo4J Open Source Graph Database (20)

Introduction to Graphs with Neo4j
Introduction to Graphs with Neo4jIntroduction to Graphs with Neo4j
Introduction to Graphs with Neo4j
 
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
Neo4j Morpheus: Interweaving Table and Graph Data with SQL and Cypher in Apac...
 
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup MunichMorpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
Morpheus SQL and Cypher® in Apache® Spark - Big Data Meetup Munich
 
Morpheus - SQL and Cypher in Apache Spark
Morpheus - SQL and Cypher in Apache SparkMorpheus - SQL and Cypher in Apache Spark
Morpheus - SQL and Cypher in Apache Spark
 
AnzoGraph DB - SPARQL 101
AnzoGraph DB - SPARQL 101AnzoGraph DB - SPARQL 101
AnzoGraph DB - SPARQL 101
 
Gerry McNicol Graph Databases
Gerry McNicol Graph DatabasesGerry McNicol Graph Databases
Gerry McNicol Graph Databases
 
Neo4j - graph database for recommendations
Neo4j - graph database for recommendationsNeo4j - graph database for recommendations
Neo4j - graph database for recommendations
 
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-convertedNeo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
Neo4j graphdatabaseforrecommendations-130531021030-phpapp02-converted
 
Applying large scale text analytics with graph databases
Applying large scale text analytics with graph databasesApplying large scale text analytics with graph databases
Applying large scale text analytics with graph databases
 
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
3rd Athens Big Data Meetup - 2nd Talk - Neo4j: The World's Leading Graph DB
 
Neo4j (Part 1)
Neo4j (Part 1)Neo4j (Part 1)
Neo4j (Part 1)
 
The Glory of Rest
The Glory of RestThe Glory of Rest
The Glory of Rest
 
Graph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft EcosystemGraph Databases in the Microsoft Ecosystem
Graph Databases in the Microsoft Ecosystem
 
Annotating search results from web databases-IEEE Transaction Paper 2013
Annotating search results from web databases-IEEE Transaction Paper 2013Annotating search results from web databases-IEEE Transaction Paper 2013
Annotating search results from web databases-IEEE Transaction Paper 2013
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
Semantic web
Semantic web Semantic web
Semantic web
 
Data translation with SPARQL 1.1
Data translation with SPARQL 1.1Data translation with SPARQL 1.1
Data translation with SPARQL 1.1
 
The 2nd graph database in sv meetup
The 2nd graph database in sv meetupThe 2nd graph database in sv meetup
The 2nd graph database in sv meetup
 
Social Network Analysis, Semantic Web and Learning Networks
Social Network Analysis, Semantic Web and Learning NetworksSocial Network Analysis, Semantic Web and Learning Networks
Social Network Analysis, Semantic Web and Learning Networks
 
NLP & DBpedia
 NLP & DBpedia NLP & DBpedia
NLP & DBpedia
 

Recently uploaded

Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
GetInData
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
jerlynmaetalle
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
balafet
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
eddie19851
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
slg6lamcq
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
javier ramirez
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
ahzuo
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
oz8q3jxlp
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
Timothy Spann
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Subhajit Sahu
 

Recently uploaded (20)

Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdfEnhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
Enhanced Enterprise Intelligence with your personal AI Data Copilot.pdf
 
The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...The affect of service quality and online reviews on customer loyalty in the E...
The affect of service quality and online reviews on customer loyalty in the E...
 
Machine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptxMachine learning and optimization techniques for electrical drives.pptx
Machine learning and optimization techniques for electrical drives.pptx
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
Nanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdfNanandann Nilekani's ppt On India's .pdf
Nanandann Nilekani's ppt On India's .pdf
 
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
一比一原版(Adelaide毕业证书)阿德莱德大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
The Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series DatabaseThe Building Blocks of QuestDB, a Time Series Database
The Building Blocks of QuestDB, a Time Series Database
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
一比一原版(CBU毕业证)卡普顿大学毕业证如何办理
 
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
一比一原版(Deakin毕业证书)迪肯大学毕业证如何办理
 
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
06-04-2024 - NYC Tech Week - Discussion on Vector Databases, Unstructured Dat...
 
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTESAdjusting OpenMP PageRank : SHORT REPORT / NOTES
Adjusting OpenMP PageRank : SHORT REPORT / NOTES
 

Neo4J Open Source Graph Database

  • 1. NEO4J OPEN SOURCE GRAPH DATABASE Presented by Mark Maslyn – mmaslyn@msn.com to Denver Open Source User Group (4/7/15) and Graph Nerds of Boulder (5/14/15)
  • 2. THREE PARTS TO THIS NEO4J PRESENTATION • What Are Graph Databases and Why Are They Useful • Neo4J Application Modes and Java API Syntax • Demo Animal Guessing Game using Neo4J Decision Tree
  • 3. WHAT ARE GRAPH DATABASES ? • Graph Databases are a type of NoSQL ( non- relational) database • In a Graph Database entities (nouns) are represented as nodes • Relationships are represented by edges connecting nodes • Both nodes and relationships can have properties
  • 4. FRIEND-OF EXAMPLE FRIEND-OFFRIEND-OF Properties: Name: Mark M Language: Java Properties: Name: Tom M Language: Java Properties: Name: Tom F Language: Scala
  • 5. SOME COMPANIES AND INDUSTRIES WITH GRAPH DATABASE APPLICATIONS • Social Media (Facebook, LinkedIn, Twitter) • Configuration Management (Assimilation Systems) • Retail Recommendation (Walmart) • Resource Authorization (Telenor) • Fraud Detection ( Banks and Credit Card Companies) • Online Education (Pearson) • Bioinformatics (Bio4j)
  • 6. WHERE GRAPH DATABASES ARE ADVANTAGEOUS • Can provide a more natural representation for the data • Can give a faster query response • Recommendation engines
  • 7. EXAMPLES WHERE A GRAPH REPRESENTATION IS A NATURAL MODEL
  • 8. FLIGHT ROUTE MAP – SF TO NY 3 4 1 2 1.5 2 3 1 1 3 1.5 FLYS-TO FLYS-TO FLYS-TO FLYS-TO FLYS-TO FLYS-TOFLYS-TO FLYS-TO FLYS-TO FLYS-TO
  • 10. TWO LEVEL PROTEIN NETWORK DIAGRAM From CYTOSCAPE.ORG Two Level Tree p53
  • 11. EXAMPLE OF QUERY SPEED-UP
  • 13. EXECUTION TIME RDBMS VS GRAPH DATABASE FOR DIFFERENT DEPTHS OF FRIEND SEARCH (1000 FRIENDS) Depth Execution Time (sec) Count Result 2 0.028 ~900 3 0.213 ~999 4 10.273 ~999 5 92.613 ~999 Depth Execution Time (sec) Count Result 2 0.04 ~900 3 0.06 ~999 4 0.07 ~999 5 0.07 ~999 MYSQL RDMS NEO4J From Vukotic, et al (2014)
  • 14. EXAMPLES OF RECOMMENDATIONS BASED ON GRAPH CONNECTIONS AND CONTENT
  • 15. TYPICAL APPROACHES TO GENERATING RECOMMENDATIONS (AND PREDICTIONS) • COLLABORATIVE FILTERING – Recommendations based on common attributes between you and / or your connections – Online dating model • CONTENT BASED FILTERING - Deriving a second level of information from the data and use that to derive recommendations – Content classification model • GRAPH TOPOLOGY – Infer links based on graph topology.
  • 16. COLLABORATIVE FILTERING RECOMMENDATION BASED ON FRIENDS CHOICES – I WILL LIKE WHAT MY FRIENDS LIKE FRIEND-OFFRIEND-OF Properties: Name: Mark M Language: Java Properties: Name: Tom M Language: Java, Scala Movie: Empire Strikes Back Properties: Name: Tom F Language: Scala, Java Movie: Raiders of the Lost Ark
  • 17. CONTENT BASED RECOMMENDATIONS BASED ON CLASSIFICATION OF FRIENDS MOVIE SELECTION FRIEND-OFFRIEND-OF Properties: Name: Mark M Language: Java Properties: Name: Tom M Language: Java, Scala Movie: Empire Strikes Back Properties: Name: Tom F Language: Scala, Java Movie: Raiders of the Lost Ark
  • 18. CONTENT CLASSIFICATION BASED ON TERMS SPORTS CATEGORY FOOTBALL BASEBALL Broncos Seahawks Ronnie HillmanPeyton Manning Rockies 1 .. N SPORTS Russell Wilson CATEGORY SPORT TEAM PLAYER 1 .. N TEAMS 1 .. N PLAYERS
  • 19. FINDING RELATIONSHIPS BASED ON GRAPH TOPOLOGY FRIEND-OFFRIEND-OF Transitive Relationship A FRIEND OF B, B FRIEND OF C, Therefore High Probability A FRIEND OF C
  • 20. CONCLUSION: A TRIADIC CLOSURE OR MY FRIENDS ARE LIKELY TO BE FRIENDS WITH EACH OTHER FRIEND-OFFRIEND-OF Properties: Name: Mark M Language: Java Properties: Name: Tom M Language: Java Properties: Name: Tom F Language: Scala TRIADIC CLOSURE
  • 21. FRIEND RELATIONSHIPS BETWEEN PARTNERS IN A KARATE CLUB – BEFORE SPLIT INTO TWO CLUBS From Zachary (1977)
  • 22. KARATE CLUBS MEMBERSHIP AFTER SPLIT From Zachary (1977)
  • 23. PART II – NEO4J GRAPH DATABASE MODES AND JAVA API SYNTAX
  • 24. NEO4J GRAPH DATABASE MODES • Embedded Mode Uses Local NEO4J Jar Files • Server Mode Uses RESTFul API’s • Browser Client Mode Using CYPHER Query Language
  • 25. EMBEDDED MODE WITH JAVA API – OPENING A GRAPH DATABASE private static GraphDatabaseService graphDb; private static String ANIMAL_DATABASE_LOC = "/home/ubuntu/animal_game/animal.db"; public AnimalGame() { // open the graph database graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( ANIMAL_DATABASE_LOC); // enable clean db shutdown on Ctrl-C registerShutdownHook( graphDb ); }
  • 26. JAVA API – CREATING AN INDEX // create index using a combination of the node label and the name property try (Transaction tx = graphDb.beginTx()) { graphDb.schema().indexFor(NodeLabels.PERSON).on( "name").create(); tx.success(); }
  • 27. JAVA API – CREATING A DATABASE NODE AND SETTING PROPERTY VALUES // create node Node node = graphDb.createNode(); // add label to identify what group the node belongs to node.addLabel(nodeLabel); // set property values node.setProperty(AnimalConstants.NAME, name); node.setProperty(AnimalConstants.TEXT, text); node.setProperty(AnimalConstants.TYPE, nodeType); // make a list of possible answers (answerList) // these match with relationships node.setProperty(AnimalConstants.ANSWERS, answerList);
  • 28. JAVA API – CREATING RELATIONSHIPS BETWEEN NODES public enum RelTypes implements RelationshipType { YES, NO } public void createRelationship(Node node1, Node node2, RelTypes rt) { // relationship between node1 and node2 // direction is from node1 to node2 node1.createRelationshipTo((Node) node2, rt); }
  • 29. JAVA API - QUERYING THE DATABASE FOR A NODE BY LABEL AND NAME public Node getNodeByLabelAndName(String nodeName) { Node node = null; ResourceIterable<Node>nodeList = graphDb.findNodesByLabelAndProperty( NodeLabels.PERSON, "name", nodeName); If (nodeList != null) { try (Transaction tx = graphDb.beginTx()) { for ( Node nodeL : nodeList ) node = nodeL; tx.success(); } } return node; }
  • 30. NEO4J SERVER RESTFUL API • Neo4J Server Provides Fine-Grained REST Calls • Returns JSON Content Type • Higher Level Libraries Available for Java, .NET, Python, etc. to Wrap the Lower Level Calls
  • 31. NEO4J SERVER RESTFUL API REQUEST / RESPONSE WITH DETAILED AVAILABLE URL’S RESPONSE { "extensions": {}, "node": "http://localhost:7474/db/data/node", "node_index": "http://localhost:7474/db/data/index/node", "relationship_index": "http://localhost:7474/db/data/index/relationship", "extensions_info": "http://localhost:7474/db/data/ext", "relationship_types": "http://localhost:7474/db/data/relationship/types", "batch": "http://localhost:7474/db/data/batch", "cypher": "http://localhost:7474/db/data/cypher", "indexes": "http://localhost:7474/db/data/schema/index", "constraints": "http://localhost:7474/db/data/schema/constraint", "transaction": "http://localhost:7474/db/data/transaction", "node_labels": "http://localhost:7474/db/data/labels", "neo4j_version": "2.1.7" } REQUEST (GET): http://localhost:7474/db/data
  • 32. NEO4J SERVER RESTFUL API – DRILLING DOWN FOR META-DATA FROM ANIMAL DATABASE REQUEST: http://localhost:7474/db/data/relationship/types JSON RESPONSE: [ "YES", "NO" ]
  • 33. RETRIEVING A SINGLE NODE AND ITS PROPERTIES REQUEST: http://localhost:7474/db/data/node/0 JSON RESPONSE: { ….. "metadata": { "id": 0, "labels": [ “ANIMALS" ] }, "data": { "text": "Does the animal live on land ?", "name": "start", "answers": [ "Y/YES", "N/NO", "Q/QUIT" ], "type": "question" } }
  • 34. RETRIEVING A NODE USING THE RESTFUL LIBRARY FROM JAVA CODE private static GraphDatabaseService graphDb; private static String ANIMAL_DATABASE_URL = “http://localhost:7474/db/data”; // public constructor public AnimalGame() { // connect to the graph database server graphDb = new RestGraphDatabase( ANIMAL_DATABASE_URL); // wrap the request and retrieve the node Node startNode = graphDb.findNodesByLabelAndProperty( NODE_LABEL, “name”, “start”);
  • 35. NEO4J BROWSER BASED WEB ADMIN CLIENT • Browser Connects to Neo4J Server. • Graphically Displays Database Nodes and Relationships in a Dashboard. Can Drill Down on Each Node. • Allows User to Execute Cypher Queries on Database From the Browser.
  • 36. NEO4J BROWSER WEB ADMIN DASHBOARD
  • 37. CLICK ON A NODE FOR MORE INFO
  • 38. CYPHER QUERY LANGUAGE • Cypher is Neo4J’s version of SQL • Queries can be entered programmatically in Java or through the browser interface • Queries can retrieve nodes, relationships, property values or call functions such as return “shortest path traversal” • Declarative syntax using “Ascii Art”
  • 39. NODES - CYPHER SYNTAX Cypher uses “Ascii Art” syntax that reflects graph elements. Nodes are represented by parentheses “( )”, relationships by arrows “-->”. The arrow head indicates the direction of the relationship Adding constraints “find two Person group nodes a and b that are connected by a relationship”. Match (a) –-> (b) Return a.name, b.name Match (a:Person) --> (b:Person) Return a.name, b.name
  • 40. RELATIONSHIPS - CYPHER SYNTAX Anonymous relationships match all relationship and are indicated by the arrow alone This query syntax is used to find two nodes a and b that are connected by the specific “ACTED_IN” relationship to match actors with movies Match (a) --> (b) Match (a) –[:ACTED_IN]-> (b)
  • 41. PROPERTY GRAPH EXAMPLE FOR A MOVIE DATABASE
  • 42. SIX DEGREES OF KEVIN BACON GAME – HOW MANY LINKS ARE REQUIRED TO CONNECT AN ACTOR TO KEVIN BACON ? Kevin Bacon (left) and Tom Hanks in Apollo 13 (1995)
  • 43. CYPHER QUERY FOR SIX DEGREES OF KEVIN BACON FOR MEG RYAN USING NEO4J SHORTEST PATH FUNCTION MATCH p=shortestPath( (b:Person {name:"Kevin Bacon"})-[*]-(m:Person {name:"Meg Ryan"}) ) RETURN p
  • 44. AND THE ANSWER IS … Meg Ryan’s “Bacon” Number is 2
  • 45. NEO4J DECISION TREE – ANIMAL GUESSING GAME Mammal ? Has Stripes ? Slithers ? Does it Growl ? Has Trunk ? Zebra ?Tiger ? Elephant ? Snake? YES YES YES YES YES NO NO NO
  • 46. PART III DEMO ANIMAL GUESSING GAME – AUDIENCE VOLUNTEER REQUESTED
  • 47. A Final Comment on Connected Graphs (Paraphrasing) Imagination is the relationship connecting two nodes…
  • 48. TWO BOOKS I RECOMMEND FOR MORE INFORMATION ON GRAPH THEORY AND NEO4J Graph Theory Neo4J By Jennifer Golbeck, 2013 By Aleksa Vukotic, et al 2014