Skip to content

Instantly share code, notes, and snippets.

@loveboat
Last active August 29, 2015 14:01
Show Gist options
  • Save loveboat/acf32cddabf265aa5983 to your computer and use it in GitHub Desktop.
Save loveboat/acf32cddabf265aa5983 to your computer and use it in GitHub Desktop.
= Cocktail Recipes
:neo4j-version: 2.1.0
:author: David Lusby
:twitter: @lusbyd
:tags: domain:drinking, use-case:fun
This interactive Neo4j graph tutorial covers making drinking fun.
Well not 'fun' that would be terrible.. more fun maybe?! Yeah more fun!
'''
=== A what now?
So the idea is to model the relationships between the ingredients in a cocktail.
So say you want to make a Gin & Tonic, how do we do that exactly? Well you'll need some gin, and some tonic - but I'm not familiar with these things, maybe we can find out what the brand names are to look for in the shops? Oh and then you'll need a glass to put your drink in - but what if I make a terrible faux-pas and use the wrong sort? Oh dear oh dear.. Well there's no need to fret as that's something we'll be looking at too.
And then I'll quickly be firing out an apology (right now in fact) about the limited data set I produced due to running out of time (and steam) on the day.
'''
=== The recipes
The recipes have been borrowed from data found on Wikipedia, namely:
* http://en.wikipedia.org/wiki/White_Russian_(cocktail)[White Russian]
* http://en.wikipedia.org/wiki/Black_Russian[Black Russian]
* http://en.wikipedia.org/wiki/Gin_and_tonic[Gin & Tonic]
* http://en.wikipedia.org/wiki/Martini_(cocktail)[Martini]
* http://en.wikipedia.org/wiki/Vodka_martini[Vodka Martini]
'''
=== Ideas for expansion
Turn the model here into an application to allow users to build a list of known cocktails.
This could then be used to search for:
* a recipe to make a known cocktail
* cocktails you can make with the ingredients you have to hand
* a random cocktail selector based on zero or more ingredients
And maybe this could also be turned into a means of:
* modelling users cocktail drinking and making suggestions based on drinks they seem to enjoy (or well at least drink a lot of!)
* generating new combinations of existing ingredients to make new (and hopefully not disgusting) cocktails. The obvious benefit here is that _someone_ gets to enjoy the tasting sessions (woot!)
* adding some prices to the model to allow fairly accurate estimates of a drinks' cost
* adding some best-guess wait-times you might have to endure in a busy bar for fiddly drinks to be made (cough 'mojito' cough)
Please leave your suggestions for improvements in the comments section below, thank you
'''
== Let's make some drinks then shall we?
//setup
[source,cypher]
----
// Lets make the drinks
CREATE (whiteRussian:Drink {name:"White Russian", preparation:"Pour coffee liqueur and vodka into an Old Fashioned glass filled with ice. Float fresh cream on top and stir slowly."})
CREATE (blackRussian:Drink {name:"Black Russian", preparation:"Pour the ingredients into an old fashioned glass filled with ice cubes. Stir gently."})
CREATE (ginAndTonic:Drink {name:"Gin & Tonic", preparation:"In a glass filled with ice cubes, add gin and tonic."})
CREATE (martini:Drink {name:"Martini", preparation:"Straight: Pour all ingredients into mixing glass with ice cubes. Stir well. Strain in chilled martini cocktail glass. Squeeze oil from lemon peel onto the drink, or garnish with olive."})
CREATE (vodkaMartini:Drink {name:"Vodka Martini", preparation:"Straight: Pour all ingredients into mixing glass with ice cubes. Stir well. Strain in chilled martini cocktail glass. Squeeze oil from lemon peel onto the drink, or garnish with olive."})
// First get the ingredients
CREATE (vodka:Ingredient {name:"Vodka"})
CREATE (coffeeLiqueur:Ingredient {name:"Coffee Liqueur"})
CREATE (freshCream:Ingredient {name:"Fresh Cream"})
CREATE (gin:Ingredient {name:"Gin"})
CREATE (tonic:Ingredient {name:"Tonic Water"})
CREATE (vermouth:Ingredient {name:"Vermouth"})
// Measure it out..
CREATE (whiteRussian)-[:MADE_OF{cl:5, parts:5}]->(vodka)
CREATE (whiteRussian)-[:MADE_OF{cl:2, parts:2}]->(coffeeLiqueur)
CREATE (whiteRussian)-[:MADE_OF{cl:5, parts:5}]->(freshCream)
CREATE (blackRussian)-[:MADE_OF{cl:5, parts:5}]->(vodka)
CREATE (blackRussian)-[:MADE_OF{cl:2, parts:2}]->(coffeeLiqueur)
CREATE (ginAndTonic)-[:MADE_OF]->(gin)
CREATE (ginAndTonic)-[:MADE_OF]->(tonic)
CREATE (martini)-[:MADE_OF{cl:6, parts:12}]->(gin)
CREATE (martini)-[:MADE_OF{cl:1, parts:2}]->(vermouth)
CREATE (vodkaMartini)-[:MADE_OF{cl:6, parts:12}]->(vodka)
CREATE (vodkaMartini)-[:MADE_OF{cl:1, parts:2}]->(vermouth)
// What fancy brands are you rocking?
CREATE (stolichnaya:Brand {name:"Stolichnaya"})-[:TYPE_OF]->(vodka)
CREATE (greyGoose:Brand {name:"Grey Goose"})-[:TYPE_OF]->(vodka)
CREATE (kahlua:Brand {name:"Kahlua"})-[:TYPE_OF]->(coffeeLiqueur)
CREATE (tiaMaria:Brand {name:"Tia Maria"})-[:TYPE_OF]->(coffeeLiqueur)
CREATE (tanqueray:Brand {name:"Tanqueray No.10"})-[:TYPE_OF]->(gin)
CREATE (gordons:Brand {name:"Gordon's"})-[:TYPE_OF]->(gin)
CREATE (bombay:Brand {name:"Bombay Saphire"})-[:TYPE_OF]->(gin)
CREATE (schweppesIndianTonicWater:Brand {name:"Schweppes Indian Tonic Water"})-[:TYPE_OF]->(tonic)
// Best clean the glasses
CREATE (oldFashionedGlass:Glass {name:"Old Fashioned"})
CREATE (highballGlass:Glass {name:"Highball"})
CREATE (rocksGlass:Glass {name:"Rocks"})
CREATE (cocktailGlass:Glass {name:"Cocktail"})
// And pour the drinks
CREATE (whiteRussian)-[:SERVED_IN]->(oldFashionedGlass)
CREATE (blackRussian)-[:SERVED_IN]->(oldFashionedGlass)
CREATE (ginAndTonic)-[:SERVED_IN]->(highballGlass)
CREATE (ginAndTonic)-[:SERVED_IN]->(rocksGlass)
CREATE (martini)-[:SERVED_IN]->(cocktailGlass)
CREATE (vodkaMartini)-[:SERVED_IN]->(cocktailGlass)
----
//graph
'''
== Use cases
=== Which drinks have lovely lovely vodka in them?
[source,cypher]
----
MATCH (i:Ingredient { name:"Vodka" })-[:MADE_OF]-(cocktail:Drink)
RETURN cocktail.name as name, cocktail.preparation as instructions
ORDER BY cocktail.name
----
//table
//output
@loveboat
Copy link
Author

replaced single-quotes with double-quotes

@loveboat
Copy link
Author

added a black russian recipe

@loveboat
Copy link
Author

added quantities to the drinks

@loveboat
Copy link
Author

renamed the ugly DrinkBrand type

@loveboat
Copy link
Author

added two martini drinks

@loveboat
Copy link
Author

oops made a vodka martini with gin!

@loveboat
Copy link
Author

fleshed out the rather sparse description section - esp adding more sarcasm which is always necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment