Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
Created March 23, 2014 19:22
Show Gist options
  • Save rvanbruggen/9728315 to your computer and use it in GitHub Desktop.
Save rvanbruggen/9728315 to your computer and use it in GitHub Desktop.
TalkshowQueries
//Total number of visits by guests to shows
match (g:GUEST)-[v:VISITED]->(sh:SHOW)
return count(v);
//Number of visits by show
match (g:GUEST)-[v:VISITED]->(sh:SHOW)
return sh.id as Show, count(v) as NrOfVisits
order by NrOfVisits desc;
//Number of Politicians by show
match (g:GUEST)-[v:VISITED]->(sh:SHOW),
g-[:AFFILIATED_WITH]->(p:PARTY)
return sh.id as Show, count(v) as NrOfVisits
order by NrOfVisits desc;
//number of male/female guests
match (g:GUEST)-[:HAS_GENDER]->(gen:GENDER),
(g:GUEST)-[v:VISITED]->(sh:SHOW)
return gen.name, count(v)
order by gen.name ASC;
//Number of male/female guests per show
match (g:GUEST)-[:HAS_GENDER]->(gen:GENDER),
(g:GUEST)-[v:VISITED]->(sh:SHOW)
return sh.id, gen.name, count(v)
order by sh.id ASC;
match (g:GUEST)-[v:VISITED]->(sh:SHOW)
with v,g as Guests, sh.id as Show, count(v) as TotalGuests
match g-[:HAS_GENDER]->(gen:GENDER)
return Show, gen.name, count(v)/TotalGuests as Percentage
order by Show.id ASC
//Number of male/female guests
match (g:GUEST)-[:HAS_GENDER]->(gen:GENDER),
(g)-[v:VISITED]->(sh:SHOW)
return gen.name, count(v)
order by gen.name ASC;
//Number of male/female guests from political parties
match (g:GUEST)-[:HAS_GENDER]->(gen:GENDER),
(g)-[v:VISITED]->(sh:SHOW),
(g)-[:AFFILIATED_WITH]->(p:PARTY)
return gen.name, count(v)
order by gen.name ASC;
//Number of guests from political parties/show
match (g:GUEST)-[v:VISITED]->(sh:SHOW),
g-[a:AFFILIATED_WITH]->(p:PARTIJ)
return p.name as Partij, sh.id as Show, count(v) as NrofVisits
order by Show ASC, Partij ASC;
//Which shows are most important for a party
match (g:GUEST)-[v:VISITED]->(sh:SHOW),
g-[a:AFFILIATED_WITH]->(p:PARTIJ)
return p.name as Partij, sh.id as Show, count(v) as NrofVisits
order by Partij ASC,NrofVisits DESC;
//Which parties are most important for a show
match (g:GUEST)-[v:VISITED]->(sh:SHOW),
g-[a:AFFILIATED_WITH]->(p:PARTIJ)
return sh.id as Show, p.name as Partij, count(v) as NrofVisits
order by Show ASC,NrofVisits DESC;
//Links between Paul Witteman and Eva Jinek
match p = AllShortestPaths((g1:GUEST {id:"Paul Witteman"})-[*..4]-(g2:GUEST {id:"Eva Jinek"}))
return p;
//Links between DWDD and P&W
match p = AllShortestPaths((s1:SHOW {id:"DWDD"})-[*..2]-(s2:SHOW {id:"P&W"}))
return p
limit 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment