• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Github in a Graph
 

Github in a Graph

on

  • 650 views

A guide to graphs, using Github as an example data source.

A guide to graphs, using Github as an example data source.

Statistics

Views

Total Views
650
Views on SlideShare
637
Embed Views
13

Actions

Likes
0
Downloads
8
Comments
0

1 Embed 13

https://twitter.com 13

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Github in a Graph Github in a Graph Presentation Transcript

  • Github in a Graph with Neo4jAndreas Kollegger@akollegger#neo4j 1
  • 1
  • How well get the Octocat into the Graph 1.Intro to Graphs, Socially 2.Graph Database Essentials 3.Github as a Graph 4.Workshop! 2
  • Graphs... 3
  • Meet Emil...
  • Meet Emil... Emil
  • Meet Emil...๏ from: Sweden Emil
  • Meet Emil...๏ from: Sweden๏ appearance: blonde and handsome Emil
  • Meet Emil...๏ from: Sweden๏ appearance: blonde and handsome๏ personality: super friendly nerd Emil
  • Meet Emil...๏ from: Sweden๏ appearance: blonde and handsome๏ personality: super friendly nerd๏ interests: piano, pickled herring Emil
  • Emil has some friends Emil
  • Emil has some friends๏ Kerstin: his sister Emil Kerstin
  • Emil has some friends๏ Kerstin: his sister๏ Peter: his buddy Peter Emil Kerstin
  • Emil has some friends๏ Kerstin: his sister๏ Peter: his buddy๏ Andreas: me! Peter Emil Andreas Kerstin
  • His friends introduced more friends Peter Emil Andreas Kerstin
  • His friends introduced more friends๏ Michael: master hacker Michael Peter Emil Andreas Kerstin
  • His friends introduced more friends๏ Michael: master hacker๏ Johan: technology sage Michael Johan Peter Emil Andreas Kerstin
  • His friends introduced more friends๏ Michael: master hacker๏ Johan: technology sage๏ Madelene: polyglot journalist Michael Johan Peter Emil Andreas Madelene Kerstin
  • His friends introduced more friends๏ Michael: master hacker๏ Johan: technology sage๏ Madelene: polyglot journalist๏ Allison: marketing maven Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • So, we have a bunch of people Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • So, we have a bunch of people๏ how do we know they are friends? Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • So, we have a bunch of people๏ how do we know they are friends?๏ either ask each pair: are you friends? Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • So, we have a bunch of people๏ how do we know they are friends?๏ either ask each pair: are you friends?๏ or, we can add explicit connections Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • So, we have a bunch of people๏ how do we know they are friends?๏ either ask each pair: are you friends?๏ or, we can add explicit connections Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • Theres a problem here Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • Theres a problem here๏ Emil is awesome Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • Theres a problem here๏ Emil is awesome๏ What about other relationships? Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • Theres a problem here๏ Emil is awesome๏ What about other relationships?๏ We mentioned "introductions" so there mustve been at least some pre-existing connections Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • Theres a problem here๏ Emil is awesome๏ What about other relationships?๏ We mentioned "introductions" so there mustve been at least some pre-existing connections Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • This can continue... Allison Michael Johan Peter Emil Andreas Madelene Kerstin
  • This can continue... Allison Michael Johan Peter EmilAnna Andreas Adam Madelene Kerstin
  • This can continue...๏ this is how social networks grow Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can continue...๏ this is how social networks grow๏ either meet people directly Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can continue...๏ this is how social networks grow๏ either meet people directly๏ or be introduced Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can be useful Allison Michael Johan Peter EmilAnna Andreas Adam Madelene Kerstin
  • This can be useful๏ professional recommendation (LinkedIn) Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can be useful๏ professional recommendation (LinkedIn)๏ product recommendation (Amazon) Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can be useful๏ professional recommendation (LinkedIn)๏ product recommendation (Amazon)๏ restaurant recommendations (Yelp) Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This can be useful๏ professional recommendation (LinkedIn)๏ product recommendation (Amazon)๏ restaurant recommendations (Yelp)๏ same domain, or reaching across domains Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • This is really just data Allison Michael Johan Peter EmilAnna Andreas Adam Madelene Kerstin
  • This is really just data๏ its just a graph Allison Michael Johan Peter Emil Anna Andreas Adam Madelene Kerstin
  • 12
  • A graph? 12
  • Yes, a graph... 13
  • Yes, a graph...๏ you know the common data structures 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs" 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure •suitable for any connected data 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure •suitable for any connected data๏ well-understood patterns and algorithms 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure •suitable for any connected data๏ well-understood patterns and algorithms •studied since Leonard Eulers 7 Bridges (1736) 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure •suitable for any connected data๏ well-understood patterns and algorithms •studied since Leonard Eulers 7 Bridges (1736) •Codds Relational Model (1970) 13
  • Yes, a graph...๏ you know the common data structures •linked lists, trees, object "graphs"๏ a graph is the general purpose data structure •suitable for any connected data๏ well-understood patterns and algorithms •studied since Leonard Eulers 7 Bridges (1736) •Codds Relational Model (1970) •not a new idea, just an idea whos time is now 13
  • 14
  • Everyone is talking about graphs... 14
  • Everyone is talking about graphs...Facebook Open Graph 14
  • Everyone is talking about graphs...Facebook Open Graph 14
  • Emils Graph
  • Emils Graph Emil
  • Emils Graph Peter Kerstin EmilAndreas
  • Emils Graph Peter Johan KerstinMichael Emil Madelene Andreas Allison
  • Emils Graph Peter Johan star KerstinMichael Emil Madelene Andreas Allison
  • Emils Graph Peter Johan star KerstinMichael Emil Madelene Andreas Allison
  • Emils Graph Peter Johan star KerstinMichael Emil Madelene Andreas Allison butterfly
  • Emils Graph Peter Johan star KerstinMichael Emil Madelene Andreas Allison butterfly
  • Emils Graph Peter Johandiamond star Kerstin Michael Emil Madelene Andreas Allison butterfly
  • Emils Graph Peter Johandiamond star Kerstin Michael Emil Madelene Andreas Allison Anna butterfly Adam
  • Emils Graph Peter Johan diamond star Kerstin Michael Emil Madelene Andreas Allison Anna butterflybull Adam
  • 16
  • Well known named graphs 16
  • Well known named graphs star 16
  • Well known named graphs star butterfly 16
  • Well known named graphs star butterfly diamond 16
  • Well known named graphs star butterfly diamond bull 16
  • Well known named graphs star butterfly diamond bull franklin 16
  • Well known named graphs star butterfly diamond bull franklin robertson 16
  • Well known named graphs star butterfly diamond bull franklin robertson horton 16
  • Well known named graphs star butterfly diamond bull franklin robertson horton hall-janko 16
  • 16
  • Text 17
  • The best known of all possible graphs... Text 17
  • 18
  • How can you use this?With a Graph Database 18
  • A graph database... 19
  • A graph database...๏ optimized for the connections between records 19
  • A graph database...๏ optimized for the connections between records๏ really, really fast at querying across records 19
  • A graph database...๏ optimized for the connections between records๏ really, really fast at querying across records๏ a database: transactional with the usual operations 19
  • A graph database...๏ optimized for the connections between records๏ really, really fast at querying across records๏ a database: transactional with the usual operations๏ “A relational database may tell you the average age of everyone at this workshop, but a graph database will tell you who is most likely to buy you a beer.” 19
  • 20
  • You know relational 20
  • You know relational 20
  • You know relational foo 20
  • You know relational foo bar 20
  • You know relational foo foo_bar bar 20
  • You know relational foo foo_bar bar 20
  • You know relational foo foo_bar bar 20
  • You know relational foo foo_bar bar 20
  • You know relationalnow consider relationships... 20
  • You know relationalnow consider relationships... 20
  • You know relationalnow consider relationships... 20
  • You know relationalnow consider relationships... 20
  • You know relationalnow consider relationships... 20
  • You know relationalnow consider relationships... 20
  • 20
  • 21
  • Were talking about aProperty Graph 21
  • Were talking about aProperty Graph Nodes 21
  • Were talking about aProperty Graph Nodes Relationships 21
  • Were talking about aProperty Graph Em Joh il a n knows knows Alli Tob Lar Nodes son ias knows s knows And And knows knows rea rés s knows knows knows Pet Miic Mc knows Ian er knows a a knows knows De Mic lia h ael Relationships Properties (each a key+value) + Indexes (for easy look-ups) 21
  • 21
  • 22
  • And, but, so how do youquery this "graph" database? 22
  • 23
  • Cypher - a graph query language๏ a pattern-matching query language๏ declarative grammar with clauses (like SQL)๏ aggregation, ordering, limits๏ create, read, update, delete 23
  • Cypher - a graph query language๏ a pattern-matching query language๏ declarative grammar with clauses (like SQL)๏ aggregation, ordering, limits๏ create, read, update, delete // get node 1, traverse 2 steps away start a=node(1) match (a)--()--(c) return c // create a node with a name property CREATE (me {name: Andreas}) return me๏ more on this later... 23
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching 24
  • Cypher - pattern matching syntax 25
  • Cypher - pattern matching syntax 25
  • Cypher - pattern matching syntax () --> () 25
  • Cypher - pattern matching syntax 26
  • Cypher - pattern matching syntax A B 26
  • Cypher - pattern matching syntax A B (A) --> (B) 26
  • Cypher - pattern matching syntax 27
  • Cypher - pattern matching syntax A B 27
  • Cypher - pattern matching syntax A B (A) -- (B) 27
  • Cypher - pattern matching syntax 28
  • Cypher - pattern matching syntax LOVES A B 28
  • Cypher - pattern matching syntax LOVES A B A -[:LOVES]-> B 28
  • Cypher - pattern matching syntax 29
  • Cypher - pattern matching syntax A B C 29
  • Cypher - pattern matching syntax A B C A --> B --> C 29
  • Cypher - pattern matching syntax 30
  • Cypher - pattern matching syntax A B C 30
  • Cypher - pattern matching syntax A B C A --> B --> C, A --> C 30
  • Cypher - pattern matching syntax A B C A --> B --> C, A --> C A --> B --> C <-- A 30
  • 31
  • Cypher - read clauses 31
  • Cypher - read clauses // get node 1, traverse 2 steps away START a=node(1) MATCH (a)--()--(c) RETURN c // get node from an index, return it START a=node:users(login=akollegger) RETURN a // get node from an index, match, filter // with where, then return results START a=node:users(login=akollegger) MATCH (a)-[r]-(b) WHERE b.login=jakewins RETURN r,b 31
  • Cypher - CREATE a node A 32
  • Cypher - CREATE a node A // create a person named Andreas CREATE (a {name:Andreas}) 32
  • Cypher - CREATE relationships 33
  • Cypher - CREATE relationships LOVES A B 33
  • Cypher - CREATE relationships LOVES A B A -[:LOVES]-> B 33
  • Cypher - CREATE relationships LOVES A B A -[:LOVES]-> B // create love between two people START a=node:people(name=Andreas), b=node:people(name=Anna) CREATE a-[:LOVES]->(b) 33
  • Cypher - CREATE UNIQUE data 34
  • Cypher - CREATE UNIQUE data LOVES A B 34
  • Cypher - CREATE UNIQUE data LOVES A B A -[:LOVES]-> B 34
  • Cypher - CREATE UNIQUE data LOVES A B A -[:LOVES]-> B // create love between two people START a=node:people(name=Andreas), b=node:people(name=Anna) CREATE UNIQUE a-[:LOVES]->(b) 34
  • Cypher - CREATE full path 35
  • Cypher - CREATE full path LOVES A B 35
  • Cypher - CREATE full path LOVES A B A -[:LOVES]-> B 35
  • Cypher - CREATE full path LOVES A B A -[:LOVES]-> B // create an entire path at once CREATE p=(a {name:Andreas})-[:LOVES]-> (b {name:Anna}) return p 35
  • Cypher - update a Node A 36
  • Cypher - update a Node A // update the nerdiness of Andreas START a=node:people(name=Andreas) SET a.nerdiness = 10 36
  • Cypher - DELETE data 37
  • Cypher - DELETE data LOVES A B 37
  • Cypher - DELETE data LOVES A B A -[:LOVES]-> B 37
  • Cypher - DELETE data LOVES A B A -[:LOVES]-> B // Goodbye Anna! remove relationships START a=node:people(name=Anna) MATCH a-[r]-(b) DELETE a,r 37
  • Github as a Graph 38
  • Github - collaborative coding๏ Hosting of git repositories๏ Prominent social aspect • follow other coders • collaborate with other coders • branches and forks • watch repositories • star repositories 39
  • Github User Graph - simple User login: "octocat" id: 1 avatar_url: "https://github.com/images/error/octocat_happy.gif" gravatar_id: "somehexcode" url: "https://api.github.com/users/octocat" akollegger follows jakewins name: "monalisa octocat" company: "GitHub" blog: "https://github.com/blog" location: "San Francisco" email: "octocat@github.com" follows hireable: false follows bio: "There once was..." public_repos: 2 nawroth public_gists: 1 followers: 20 following: 0 html_url: "https://github.com/octocat" created_at: "2008-01-14T04:33:35Z" type: "User"details: http://developer.github.com 40
  • Github User Graph - complete akollegger follows jakewins follows follows nawrothdetails: http://developer.github.com 41
  • Github User Graph - complete akollegger follows jakewins follows follows nawrothdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of neo4j mattt follows member of akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of neo4j mattt follows member of akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of(user)-[:follows]->(users) neo4j mattt follows member of akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of(user)-[:follows]->(users) neo4j mattt(user)-[:member_of]->(org) follows member of akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of(user)-[:follows]->(users) neo4j mattt(user)-[:member_of]->(org)(user)-[:owns]->(repository) member of follows akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Github User Graph - complete heroku member of(user)-[:follows]->(users) neo4j mattt(user)-[:member_of]->(org)(user)-[:owns]->(repository) member of follows(user)-[:collaborates_on]->(repos) akollegger follows jakewins owns follows follows FEC_GRAPH nawroth follows collaborates on jexpdetails: http://developer.github.com 41
  • Workshop 42
  • Preparations๏Get on Github๏Get Neo4j 43
  • What would you like to do?A.Data ImportB.Cypher Query ChallengeC.Graph Visualization 44
  • Ready to Start? Go here...๏http://graphhub-east.github.com๏http://graphhub-west.github.com 45
  • 46
  • and, Thanks :) 46