Skip to content

Instantly share code, notes, and snippets.

Avatar

Anders Nawroth nawroth

View GitHub Profile
View x.adoc
this is the title
MATCH (n) RETURN n
View case.adoc

The case for CASE

This is how you might model Premier League managers tenures at different clubs in Neo4j:

managers tiff

The date modeling is based on an approach described in more detail in Return partly shared path ranges.

View finding-paths.adoc

Finding Paths

Our example graph consists of movies with title and year and actors with a name. Actors have ACTS_IN relationships to movies, which represents the role they played. This relationship also has a role attribute.

We queried and updated the data so far, now let’s find interesting constellations, a.k.a. paths.

View actually-social-movie-db.adoc

Social Movie Database

Our example graph consists of movies with title and year and actors with a name. Actors have ACTS_IN relationships to movies, which represents the role they played. This relationship also has a role attribute.

So far, we queried the movie data; now let’s update the graph

View social-movie-db.adoc

Movie Database

Our example graph consists of movies with title and year and actors with a name. Actors have ACTS_IN relationships to movies, which represents the role they played. This relationship also has a role attribute.

cineasts

We’ll go with three movies and three actors:

View Orienteering.adoc

Orienteering Gist

This is the Orienteering Dataset based on the blog.neo4j.org post.

BR6XWd4ZbbfPu9Bm2c IFYWdhzACwwxLJOS3ZpAR7gmUSZE6ldzwwlcp4GnR9YR2cwdNT6AuXiUESf B5YQOy4BEDYgpEKtBRCMCbkBOwc9Q9GpriAklzO9pqg

It’s a simple, three-leg training course in an Antwerp park. Setting this up as a graph in neo4j was easy enough:

View GraphGist-Guide.adoc

Develop a Graph

There are Three APIs…​

Neo4j has a trio of programming interfaces, focused on different kinds of interaction.

api trio
  • Work with the Cypher query language over HTTP.

  • Discover raw graph primitives over REST.

View Business Rule Recommendation gist
= Business Rule / Recommendation gist =
Let's see if I can create a graphgist for business rules/simple recommendations.
//console
First, lets create the graph:
//setup
[source,cypher]
View asciidoctor.js-test
`CREATE UNIQUE` will make sure we don't create duplicate patterns.
Using this: `[r:ACTED_IN]` lets us return the relationship.
View GraphGist-create-nodes-and-rels.adoc

Create nodes and relationships

Create a node for the actor Tom Hanks:

CREATE (n:Actor {name:"Tom Hanks"});
You can’t perform that action at this time.