Skip to content

Instantly share code, notes, and snippets.

View peterneubauer's full-sized avatar

Peter Neubauer peterneubauer

View GitHub Profile

Tic Tac Toe !

To play Tic Tac Toe ! with Cypher queries.

wargames
//console
//setup
//hide
Initialize Graph
[source,cypher]
----
CREATE
( socrates:Philosopher {name:'Socrates', uri: 'http://dbpedia.org/resource/Socrates' })
, ( plato:Philosopher {name:'Plato', uri: 'http://dbpedia.org/resource/Plato' })
= MotoGp Graph Gist
These queries are my first attempts at Cypher and using Neo4j, I am just begining my journey so if you can identify ways to improve the queries then please post a comment to help me improve.
OK with that out of the way where did I begin? I love bike racing and thought the interrelated domains of championships, circuits, riders and teams would be a great place to start. I thought it would be cool to come up with a model that allowed to me to extrapolate bizarre facts from this years MotoGP championship (just in case anyone asked me to commentate on a upcoming race).
What sort of facts would I want to dazzle people with?
* What is the total race distance for the year?
* Which is the longest race?

A simple GraphGist

CREATE (n{name:'cypher'})-[r:LIKES]->({name:'icecream'}) return n.name, r
= Eras and Schools
== Eras and schools
== Initialize Graph
//hide
[source,cypher]
----
CREATE
== Initialize Graph
[source,cypher]
----
CREATE
( plato:Philosopher {name:'Plato', uri: 'http://dbpedia.org/resource/Plato' })
, ( aristotle:Philosopher { name: 'Aristotle' , uri: 'http://dbpedia.org/resource/Aristotle' })
, ( platonism_school:School { name: 'Platonism', uri: 'http://dbpedia.org/resource/Platonism' })
, ( peripatetic_school:School { name: 'Peripatetic school', uri: 'http://dbpedia.org/resource/Peripatetic_school' })
, ( philo_tradition:SchoolType { name: 'Philosophical traditions', uri: 'http://dbpedia.org/class/yago/PhilosophicalTraditions' })
, ( philo_movement:SchoolType { name: 'Philosophical movements', uri: 'http://dbpedia.org/class/yago/PhilosophicalMovements' })
= Influence within the same Philosophic school type
== The setup
[source,cypher]
----
CREATE
( plato:Philosopher {name:'Plato', uri: 'http://dbpedia.org/resource/Plato' })
, ( aristotle:Philosopher { name: 'Aristotle' , uri: 'http://dbpedia.org/resource/Aristotle' })
= Working examples for the 'Graph Databases' book
image::http://assets.neo4j.org/img/books/graphdatabases_thumb.gif["frontpage thumbnail",align="left"]
The examples in the 'Graph Databases' book don't work out of the box. I've modified them, so that they do work (for chapter 3, that is).
This is a graphgist version of my https://baach.de/Members/jhb/working-examples-for-the-graph-databases-book/[blog post].
If you click one of the green play buttons in the examples below, they will show in this console. Usually the code formatting is messed up, so it might be a bit ugly.

Mystery Science Theater 3000 Actors and Characters - GraphGist for the Neo4j GraphGist challenge

This Graph is based on the MST3K TV-series that ran during the 1990s. Awesome TV-serie, my favourite actually. I created this Graph based on the characters of the show and where they live/reside/hunt, and which actors played them. As the Actors usually played several characters, and many characters were played by several actors, the graph get’s a bit interesting :) Enjoy!

1380475993
= Models Sports Leagues
Aravind R. Yarram <[email protected]>
v1.0, 08-Sep-2013
== Domain Model
Each *League* has multiple *Level*s like playoffs, quarter-finals etc. The levels are ordered: first is playoffs, +NEXT+ is quarter-finals, +NEXT+ is semi-finals and then the next and last one is the finals. The ordering is represented using a http://docs.neo4j.org/chunked/milestone/cookbook-linked-list.html[linked-list].
A *Player* can play for more than one team over multiple leagues but can only play for a single team in a given league. This is captured by the +PLAYED_IN_FOR_LEAGUE+ http://docs.neo4j.org/chunked/milestone/cypher-cookbook-hyperedges.html[hyperedge] between player, team and league using http://docs.neo4j.org/chunked/milestone/cypher-cookbook-hyperedges.html[hypernode] *PlayerTeamLeague* . A team can register in a new league with a different name in which case, we want to know what it was +PREVIOUSLY_KNOWN_AS+.The fact that a player had for a given team (irrespective of which league) is capture