Monday, 7 March 2016

Qcon 2016 obviously has a SCHEDULE GRAPH

Today is the start of an ANNIVERSARY edition of a great developer conference in London that most of us at Neo4j really like: QCON London is a yearly gathering of all kinds of software professionals in London, and is usually a great place to meet and learn lots of cool new things. It also marks that anniversary of our Graphistania podcast (which we started last year at the conference!), so I can honestly say that I am really looking forward.

Just like last year of course, I also wanted to share a "Schedule graph" of the conference schedule. As you can tell from the tabular webpage, we would need to do some conversions here and there to make it work:


But of course, we made it work. You can find all of the queries github of course.

Loading the QCON Schedule Graph

In order to get the data loaded, I first put everything into a nice little google sheet, with some furious copying and pasting:
It worked really well, and you can view the data over here now.

Then of course, I had to write a couple of queries to load the data. On github you will find two versions of these "load queries", and I am including the concise, all-i-one-go-version below:

load csv with headers from "https://docs.google.com/spreadsheets/d/1aFhc5zcxCEEPnS0FWmlcltcaYX6wCqhhbtsoZiRGu3A/export?format=csv&id=1aFhc5zcxCEEPnS0FWmlcltcaYX6wCqhhbtsoZiRGu3A&gid=1550249063" as hosts
merge (p:Person {name: hosts.Name, title: hosts.Title})
merge (c:Company {name: hosts.Company})
merge (p)-[:WORKS_FOR]->(c)
with hosts
load csv with headers from "https://docs.google.com/spreadsheets/d/1aFhc5zcxCEEPnS0FWmlcltcaYX6wCqhhbtsoZiRGu3A/export?format=csv&id=1aFhc5zcxCEEPnS0FWmlcltcaYX6wCqhhbtsoZiRGu3A&gid=0" as csv
merge (d:Day {date: toInt(csv.day)})
with csv
match (d:Day), (d2:Day)
where d.date = d2.date-1
merge (d)-[:PRECEDES]-(d2)
with csv
merge (r:Room {name: csv.room})
merge (t:Track {name: csv.track})
merge (p:Person {name: csv.speaker, title: csv.title})
merge (c:Company {name: csv.company})
merge (p)-[:WORKS_FOR]->(c)
with csv
match (d:Day {date: toInt(csv.day)})
merge (t1:Time {time: toInt(csv.starttime)})-[:PART_OF]->(d)
merge (t2:Time {time: toInt(csv.endtime)})-[:PART_OF]->(d)
with csv
match (t2:Time {time: toInt(csv.endtime)})-[:PART_OF]->(d:Day {date: toInt(csv.day)})<-[:PART_OF]-(t1:Time {time: toInt(csv.starttime)}), (r:Room {name: csv.room}), (t:Track {name: csv.track}), (p:Person {name: csv.speaker, title: csv.title}), (h:Person {name: csv.host})
merge (s:Session {title: csv.talk})
merge (s)<-[:SPEAKS_IN]-(p)
merge (s)-[:IN_ROOM]->(r)
merge (s)-[:STARTS_AT]->(t1)
merge (s)-[:ENDS_AT]->(t2)
merge (s)-[:IN_TRACK]->(t)
merge (h)-[:HOSTS]->(t);

Once I ran that query, and added the meta-graph, I had the following model lined up:


Obviously it is not a very big graph, but now we can do some exploring.

Exploring the QCON Schedule Graph

Let's take a look at some queries here:

//Look at day 1
match (d:Day {date:20160307})<--(t:Time)<--(s:Session)--(connections)
return d,t,s,connections
limit 50

gives us the following graph.

Then we can also start looking at some connections between people, and explore the surrounding area of the graph:

//Look at two people
match (p1:Person), (p2:Person),
path = allshortestpaths( (p1)-[*]-(p2) )
where p1.name contains "Hunger"
and p2.name contains "Webber"
return path

Then we start seeing some interesting links:

And then we can of course also explore similar links between people and companies:

//Look at a person and a company
match (c:Company {name:"ThoughtWorks"}), (p:Person {name:"Jim Webber"}),
path = allshortestpaths( (c)-[*]-(p) )
return path

Gets us the "conference"-style links between Jim Webber and his former and current employer:

And then finally, a query that I always tend to run for the heck of it - the conference session that have more than one speaker:

//Look at sessions with more than one speaker
match (s:Session)-[r:SPEAKS_IN]-(p:Person)
with s, collect(p) as person, count(p) as count
where count > 1
return s,person

Looks like this - we can obviously explore this a lot further.


Cool. Again - this is just an example of the type of nice little graph explorations that you can easily set up on your local machines. If you have any questions or want to explore this further, then please don't hesitate to drop by the Neo4j booth!

Have fun at the conference!

Cheers

Rik

No comments:

Post a Comment