Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
rvanbruggen / BeerGraph with in-graph alcoholpercentage-index
Last active December 17, 2015 17:08
Beergraph with in-graph index
***
*** SHOW ME THE IN-GRAPH-ALCOHOLINDEX
***
start
alcperc=node:node_auto_index(type="AlcoholPercentage")
match
p=(alcperc-[:PRECEDES]->())
return p;
*************************************************
**** BEER DATASET - CYPHER Query Examples ****
*************************************************
**** Beers from same brewery as DUVEL ****
START duvel=node:node_auto_index(name="Duvel")
MATCH
duvel<-[:BREWS]-brewery,
******************************************
*** Some cool ConceptNet Graph Queries ***
******************************************
*** Look up a concept in the Graph ***
START beer=node:Concepts(id="/c/en/beer")
return beer;
*** Figure out the relations of a concept to other concepts ***
@rvanbruggen
rvanbruggen / My first BeerGist
Last active December 19, 2015 04:39 — forked from nawroth/tutorial-graphgist
BeerGraph GraphGist
= My simple BeerGraph Datamodel =
Let's see if I can create a graphgist for my beers
[source,cypher]
----
CREATE (brewery:brewery{name:'Brewery'}), (beerbrand:beerbrand{name:'BeerBrand'}), (alcperc:alcoholpercentage{name:'Percentage'}), (beertype:beertype{name:'BeerType'})
CREATE (alcpercbefore:alcoholpercentage{name:'PercentageBefore'}), (alcpercafter:alcoholpercentage{name:'PercentageAfter'})
CREATE brewery-[:BREWS]->beerbrand<-[:HAS_ALCHOLHOL_PERCENTAGE]-alcperc
CREATE alcpercbefore-[:PRECEDES]->alcperc-[:PRECEDES]->alcpercafter
@rvanbruggen
rvanbruggen / Business Rule Recommendation gist
Last active December 19, 2015 12:59
Business Rules / Recommendation gist
= Business Rule / Recommendation gist =
In this simple example, we want to highlight the power of graphs to describe, discover, visualise and implement powerful business rule-based recommendations.
In the example, we will create a simple graph containing
- a +person+ ("Rik")
- a +city+ ("London")
- an +age+ ("39")
- a +child+ ("Toon")
and all the required relationships from the person to the city, to his age, and his child.
@rvanbruggen
rvanbruggen / Last.fm Dataset Overview Gist
Last active May 25, 2016 07:26
Last.fm Dataset Overview Gist
= Last.fm Dataset Gist =
Earlier this month, I published http://blog.neo4j.org/2013/07/fun-with-music-neo4j-and-talend.html[a blog post] about my fun with some self-exported http://last.fm[Last.fm] data. With this Gist, I would like to provide a bit more practical detail on the dataset and how you could use it.
Let's first create an overview graph of the model.
image::http://2.bp.blogspot.com/-uNPggNP9A3c/Ud7HDhwpkbI/AAAAAAAAAK4/AZd25Q0h-j4/s640/Screen+Shot+2013-07-11+at+16.52.59.png[]
[source,cypher]
----
@rvanbruggen
rvanbruggen / linkedin-query.py
Last active March 28, 2024 19:53 — forked from ThomasCabrol/linkedin-2-query.py
Python script to query your LinkedIn network and get all your network's connections and their interconnections.
#!/usr/bin/env python
# encoding: utf-8
"""
linkedin-query.py
Created by Thomas Cabrol on 2012-12-03.
Customised by Rik Van Bruggen
Copyright (c) 2012 dataiku. All rights reserved.
Building the LinkedIn Graph
@rvanbruggen
rvanbruggen / linkedin cypher.cql
Created August 9, 2013 06:16
Example queries to interactively query a linkedin-based neo4j database.
// Find Shortest paths between two contacts
START
n=node:node_auto_index(name='Emil Eifrem'),
m=node:node_auto_index(name='Steven Noels')
MATCH
p = AllShortestPaths(n-[*]-m)
RETURN p;
// Find all the relationships between two "first degree" contacts of RVB
@rvanbruggen
rvanbruggen / Orienteering.adoc
Last active August 24, 2016 20:12
Orienteering Gist

Orienteering Gist

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

XrXYFfsENq 5EpcOtyGN1UU7Z3RGhYdqfnWAjEafGjmmh0nCYdu8 LfImLcm7c3bjRIX8wJUnYaIpKFoAoMO3igUiVre3HKoYkqG5fHVkdmBfudfT7qlF7QbeA

It’s a simple, three-leg training course in an Antwerp park. The graph is really simple: it contains * the Controls of the simple course that I have here * the different route choices (in the form of a series of Waypoints) that an Orienteer could make to go from start to control point, to control point, to finish. Each of the "legs" of the course, and every route choice of that "leg", has a certain distance and runnability score (value from 0,1 to 1). We are thus dealing with a classic pathfinding problem, where we want to find the best route choice to complete the course.

@rvanbruggen
rvanbruggen / IKEA graph nodes
Last active December 23, 2015 04:09
Setting up & querying the IKEA graph
create ({id:'1',name:'DeepPAX',type:'ShopArticle'});
create ({id:'112996',name:'Screw',type:'Component'});
create ({id:'124593',name:'Nail',type:'Component'});
create ({id:'113434',name:'ScrewLock',type:'Component'});
create ({id:'101375',name:'WoodStick',type:'Component'});
create ({id:'100402',name:'Screw',type:'Component'});
create ({id:'100644',name:'Screw',type:'Component'});
create ({id:'100347',name:'Screw',type:'Component'});
create ({id:'103693',name:'LockPlate',type:'Component'});
create ({id:'123773',name:'CornerCover',type:'Component'});