SlideShare a Scribd company logo
1 of 81
Download to read offline
Graphs, Edges &
                               Nodes
                             Untangling the social web.




Wednesday, March 9, 2011
What’s a graph?


Wednesday, March 9, 2011
Graph




Wednesday, March 9, 2011
Graph




Wednesday, March 9, 2011
Graph




Wednesday, March 9, 2011
Graph
                                                             10


                                                     19
                                                9                  7
                                                                               2   15
                                            7
                                    3
                                                    12
                                                                  13
                                                                           9
                               6
                                        6
                                                             4                          3
                                                5                  7
                           4
                                   14
                                                                       1

                                                         4




Wednesday, March 9, 2011
Graph
                                                          11                      10                    10

                                                                          19
                                        6                      9                            7
                                                                                                        2    15
                                                          7         21
                                             3                                                  8
                                                                         12
                                                         15                                13                     13
                                       17                                                           9
                                                                         22
                               6
                                                 6
                                                                                                    3
                       4                                                          4                               3
                                                     2         5                            7
                           4
                                   6        14                                         9                     12
                                                                                                1
                                                               10             4
                                                                                           19




Wednesday, March 9, 2011
Simple




                       At most one edge bet ween any pair of nodes.



Wednesday, March 9, 2011
Multigraph




                           Multiple edges bet ween vertices allowed.



Wednesday, March 9, 2011
Pseudograph




                           Self-loops are permitted.



Wednesday, March 9, 2011
G = (V, E)




Wednesday, March 9, 2011
Wednesday, March 9, 2011
What’s a node?
                                  vertex
                                   point
                                 junction
                                0-simplex



Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
What’s an edge?
                                   arc
                                 branch
                                   line
                                   link
                                1-simplex


Wednesday, March 9, 2011
Directed

Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Undirected

Wednesday, March 9, 2011
Undirected

Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Data Structures


Wednesday, March 9, 2011
1


                                                       3




                           2


                                               4



                               (Finite simple graph)



Wednesday, March 9, 2011
vertices

                           0       1       1      1

                           1       0       0      0
              vertices
                           1       0       0      1

                           1       0       1      0


                               Adjacency Matrix
                                   (2d array)


Wednesday, March 9, 2011
vertices

                           0       1       1      1

                           1       0       0      0
              vertices
                           1       0       0      1

                           1       0       1      0


                               Adjacency Matrix
                                   (2d array)


Wednesday, March 9, 2011
1


                                                       3




                           2


                                               4



                               (Finite simple graph)



Wednesday, March 9, 2011
[1, 2, 3, 4]
                            2   1       1         1
                            3           4         3
                            4

         Array entries (vertices) point to singly linked-lists




Wednesday, March 9, 2011
Visualizations


Wednesday, March 9, 2011
You are here.




Wednesday, March 9, 2011
Wednesday, March 9, 2011
(Graph does not include Justin Bieber)



Wednesday, March 9, 2011
Social Graphs


Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
Wednesday, March 9, 2011
User-based item recommendations




Wednesday, March 9, 2011
People




                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                                                                                (friends)




                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                                                                                (friends)




                                                   Items

                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                                                                                (friends)




                                                   Items

                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                             (me)                                               (friends)




                                                   Items

                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                             (me)                                               (friends)




                                                   Items

                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
People
                             (me)                                               (friends)




                                                   Items

                           Recommend items to me that are popular amongst my friends



Wednesday, March 9, 2011
2-step path on homogeneous bipartite
                                           graph.




Wednesday, March 9, 2011
Strong Connection Problem (SCP)




Wednesday, March 9, 2011
There are many of these ‘fundamental’
                  graph units:

                      -    tripartite graphs (user/asset/tag)
                      -    folksonomies
                      -    multicolor-multiparity graph
                      -    etc.




Wednesday, March 9, 2011
Graph Storage
                              Engines


Wednesday, March 9, 2011
Neo4j
    “An embedded, disk-based, fully transactional Java persistence engine that
            stores data structured in graphs rather than in tables.”


                             http://neo4j.org


Wednesday, March 9, 2011
HypergraphDB
“A general purpose, extensible, portable, distributed, embeddable, open-source
    data storage mechanism. It is a graph database designed specifically for
               artificial intelligence and semantic web projects.”


                            http://kobrix.org/hgdb.jsp


Wednesday, March 9, 2011
Special Purpose
                           Storage Engines


Wednesday, March 9, 2011
FlockDB
                  “FlockDB is a database that stores graph data, but it isn't a database
                optimized for graph-traversal operations. Instead, it's optimized for very
                large adjacency lists, fast reads and writes, and page-able set arithmetic
                                                 queries.”



  http://engineering.twitter.com/2010/05/introducing-flockdb.html


Wednesday, March 9, 2011
Redis
       “Redis is an advanced key-value store. [...] the dataset is not volatile, and values
       can be strings, exactly like in memcached, but also lists, sets, and ordered sets. All
       this data types can be manipulated with atomic operations to push/pop elements,
       add/remove elements, perform server side union, intersection, difference between
       sets, etc.”



                           http://code.google.com/p/redis

Wednesday, March 9, 2011
A Redis Friends/
                 Followers Example


Wednesday, March 9, 2011
Redis makes you think in terms of datastructures,
                and operations on those structures.




Wednesday, March 9, 2011
Set:
         Finite (for our cases) collection of objects in which
         order has no significance and multiplicity is generally
         ignored.
                           S = { Alice, Bob, Carol }

        List:
          Finite (for our cases) collection of objects in which
          order *is* significant and multiplicity is allowed.

                             L = [ X, Y, X, Z, Q]


Wednesday, March 9, 2011
Insert a user into a set


                            SET uid:1000:username jperras


                           Command    Key          Value




Wednesday, March 9, 2011
Use sets for denoting my followers/people
                                  I follow.




Wednesday, March 9, 2011
Adding a new follower

                            SADD uid:1000:following 1001
                            SADD uid:1001:followers 1000


                           Command     Key         Value




Wednesday, March 9, 2011
Posting Updates

                      $r = Redis();
                      $postid = $r->incr("global:nextPostId");
                      $post = $User['id'] ."|". time() ."|". $status;
                      $r->set("post:$postid", $post);
                      $followers = $r->smembers("uid:".$User['id'].":followers");

                      if ($followers === false) $followers = Array();
                      $followers[] = $User['id']; /* Add the post to our own posts too */

                      foreach($followers as $fid) {
                          $r->push("uid:$fid:posts", $postid, false);
                      }
                      # Push the post on the timeline, and trim the timeline to the
                      # newest 1000 elements.
                      $r->push("global:timeline", $postid, false);
                      $r->ltrim("global:timeline",0,1000);




Wednesday, March 9, 2011
Common followers? - Set intersections!



                           SINTER users:1000:followers users:1000:followers


                           Command       Key 1                Key 2




Wednesday, March 9, 2011
A MySQL Example
                           (simplified)




Wednesday, March 9, 2011
# Mutual Friends
                           select f.friend_id
                               from friends f
                               join friends m
                               on m.user_id = f.friend_id
                               and m.friend_id = f.user_id
                           where f.user_id = 1234

                           # Following (for directed graphs)
                           select f.friend_id
                               from friends f
                               left join friends m
                                   on m.user_id = f.friend_id
                                   and m.friend_id = f.user_id
                               where f.user_id = 1234
                                   and m.user_id is null;

                           # Followers (for directed graphs)
                           select m.friend_id
                               from friends f
                               left join friends m
                                   on m.user_id = f.friend_id
                                   and m.friend_id = f.user_id
                               where f.friend_id = 1234
                                   and m.user_id is null




Wednesday, March 9, 2011
# Mutual Friends
                           select f.friend_id
                               from friends f
                               join friends m
                               on m.user_id = f.friend_id
                               and m.friend_id = f.user_id
                           where f.user_id = 1234

                           # Following (for directed graphs)
                           select f.friend_id
                               from friends f
                               left join friends m

        Not too bad.               on m.user_id = f.friend_id
                                   and m.friend_id = f.user_id
                               where f.user_id = 1234
                                   and m.user_id is null;

                           # Followers (for directed graphs)
                           select m.friend_id
                               from friends f
                               left join friends m
                                   on m.user_id = f.friend_id
                                   and m.friend_id = f.user_id
                               where f.friend_id = 1234
                                   and m.user_id is null




Wednesday, March 9, 2011
Relational databases can work for the simplest
          of cases, but are not always the best solution for
                 many graph operations/algorithms.




Wednesday, March 9, 2011
Graphs and graph-databases are only
                            going to be more and more useful.




Wednesday, March 9, 2011
However, graph algorithms are hard.

                                So don’t write your own.

        And make sure you use a persistent storage engine
            that is best suited for the type of queries
                      you will be performing.




Wednesday, March 9, 2011
Resources


Wednesday, March 9, 2011
Resources
                           The Algorithm Design Manual,
                           Steve S. Skiena
                           Programming Collective
                           Intelligence, Toby Segaran
                           Introduction to Algorithms,
                           Cormen, Leiserson, Rivest


Wednesday, March 9, 2011
@jperras

Wednesday, March 9, 2011
Photo Credits


                           Graph of the internet, circa 2003: http://www.duniacyber.com/freebies/education/what-
                           is-internet-lookslike/ (built from partial troll of public servers using traceroute)

                           My real friends for letting me use their Facebook profile images.




Wednesday, March 9, 2011
References

                           Large Scale Graph Algorithms (class lectures), Yuri Lifshits, Steklov Institute of
                           Mathematics at St. Petersburg

                           http://mathworld.wolfram.com/Set.html

                           Programming Collective Intelligence, Toby Segaran

                           The Algorithm Design Manual, Steve S. Skiena




Wednesday, March 9, 2011

More Related Content

Viewers also liked

Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arraysAseelhalees
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURERohit Rai
 
Multi-Dimensional Lists
Multi-Dimensional ListsMulti-Dimensional Lists
Multi-Dimensional Listsprimeteacher32
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng웅식 전
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional arrayRajendran
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...widespreadpromotion
 
UX Portfolio - Kelly Ser
UX Portfolio - Kelly SerUX Portfolio - Kelly Ser
UX Portfolio - Kelly SerKelly Ser
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)EngineerBabu
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in CSmit Parikh
 

Viewers also liked (16)

Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arrays
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Multi-Dimensional Lists
Multi-Dimensional ListsMulti-Dimensional Lists
Multi-Dimensional Lists
 
One Dimentional Array
One Dimentional ArrayOne Dimentional Array
One Dimentional Array
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional array
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 
UX Portfolio - Kelly Ser
UX Portfolio - Kelly SerUX Portfolio - Kelly Ser
UX Portfolio - Kelly Ser
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Arrays
ArraysArrays
Arrays
 
Array in c language
Array in c languageArray in c language
Array in c language
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Linked list
Linked listLinked list
Linked list
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 

Similar to Graphs, Edges & Nodes: Untangling the Social Web

Future Everything Pecha Kucha 2011
Future Everything Pecha Kucha 2011Future Everything Pecha Kucha 2011
Future Everything Pecha Kucha 2011Martin Skelly
 
Drc2011 chicago my problems with insights_optimized
Drc2011 chicago my problems with insights_optimizedDrc2011 chicago my problems with insights_optimized
Drc2011 chicago my problems with insights_optimizedLuis Arnal
 
SADTU Gauteng Education Conference - IM&G
SADTU Gauteng Education Conference - IM&GSADTU Gauteng Education Conference - IM&G
SADTU Gauteng Education Conference - IM&GEducation Moving Up Cc.
 
Parallel And Perpendicular Nov 24
Parallel And Perpendicular Nov 24Parallel And Perpendicular Nov 24
Parallel And Perpendicular Nov 24DMCI
 
Nov 24 Parallel And Perpendicular
Nov 24 Parallel And PerpendicularNov 24 Parallel And Perpendicular
Nov 24 Parallel And PerpendicularDMCI
 
Transformations sailing boat v2.1
Transformations   sailing boat v2.1Transformations   sailing boat v2.1
Transformations sailing boat v2.1alan brown
 
Modelling interacting impacts of processes and decisions on ecosystem dynamic...
Modelling interacting impacts of processes and decisions on ecosystem dynamic...Modelling interacting impacts of processes and decisions on ecosystem dynamic...
Modelling interacting impacts of processes and decisions on ecosystem dynamic...weADAPT
 
Mister Maker Animal Mask A4 Template Sheet
Mister Maker Animal Mask A4 Template SheetMister Maker Animal Mask A4 Template Sheet
Mister Maker Animal Mask A4 Template SheetCastle Hill Crafts
 
Consumer Math Slides October 10, 2007
Consumer Math Slides October 10, 2007Consumer Math Slides October 10, 2007
Consumer Math Slides October 10, 2007Darren Kuropatwa
 
OLDSMOOC week 5: Storyboard example. Diana Laurillard
OLDSMOOC week 5: Storyboard example. Diana LaurillardOLDSMOOC week 5: Storyboard example. Diana Laurillard
OLDSMOOC week 5: Storyboard example. Diana LaurillardOLDSMOOC
 
Pavan sri sai 340 0642 pavan project work
Pavan sri sai  340 0642  pavan project workPavan sri sai  340 0642  pavan project work
Pavan sri sai 340 0642 pavan project workgntkptppts
 
Ch2.8 Display Data
Ch2.8 Display DataCh2.8 Display Data
Ch2.8 Display Datamdicken
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theoryTech_MX
 
TUT EDU210 State of education in South Africa
TUT EDU210 State of education in South AfricaTUT EDU210 State of education in South Africa
TUT EDU210 State of education in South AfricaEducation Moving Up Cc.
 

Similar to Graphs, Edges & Nodes: Untangling the Social Web (20)

Future Everything Pecha Kucha 2011
Future Everything Pecha Kucha 2011Future Everything Pecha Kucha 2011
Future Everything Pecha Kucha 2011
 
Drc2011 chicago my problems with insights_optimized
Drc2011 chicago my problems with insights_optimizedDrc2011 chicago my problems with insights_optimized
Drc2011 chicago my problems with insights_optimized
 
SADTU Gauteng Education Conference - IM&G
SADTU Gauteng Education Conference - IM&GSADTU Gauteng Education Conference - IM&G
SADTU Gauteng Education Conference - IM&G
 
Parallel And Perpendicular Nov 24
Parallel And Perpendicular Nov 24Parallel And Perpendicular Nov 24
Parallel And Perpendicular Nov 24
 
26 10 circulo
26 10 circulo26 10 circulo
26 10 circulo
 
Nov 24 Parallel And Perpendicular
Nov 24 Parallel And PerpendicularNov 24 Parallel And Perpendicular
Nov 24 Parallel And Perpendicular
 
Transformations sailing boat v2.1
Transformations   sailing boat v2.1Transformations   sailing boat v2.1
Transformations sailing boat v2.1
 
Story board
Story boardStory board
Story board
 
Modelling interacting impacts of processes and decisions on ecosystem dynamic...
Modelling interacting impacts of processes and decisions on ecosystem dynamic...Modelling interacting impacts of processes and decisions on ecosystem dynamic...
Modelling interacting impacts of processes and decisions on ecosystem dynamic...
 
Mister Maker Animal Mask A4 Template Sheet
Mister Maker Animal Mask A4 Template SheetMister Maker Animal Mask A4 Template Sheet
Mister Maker Animal Mask A4 Template Sheet
 
Consumer Math Slides October 10, 2007
Consumer Math Slides October 10, 2007Consumer Math Slides October 10, 2007
Consumer Math Slides October 10, 2007
 
OLDSMOOC week 5: Storyboard example. Diana Laurillard
OLDSMOOC week 5: Storyboard example. Diana LaurillardOLDSMOOC week 5: Storyboard example. Diana Laurillard
OLDSMOOC week 5: Storyboard example. Diana Laurillard
 
Pavan sri sai 340 0642 pavan project work
Pavan sri sai  340 0642  pavan project workPavan sri sai  340 0642  pavan project work
Pavan sri sai 340 0642 pavan project work
 
Ch2.8 Display Data
Ch2.8 Display DataCh2.8 Display Data
Ch2.8 Display Data
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
 
TeachSA Panel discussion
TeachSA Panel discussionTeachSA Panel discussion
TeachSA Panel discussion
 
TUT EDU210 State of education in South Africa
TUT EDU210 State of education in South AfricaTUT EDU210 State of education in South Africa
TUT EDU210 State of education in South Africa
 
Carte 1 2010.Jpg
Carte 1 2010.JpgCarte 1 2010.Jpg
Carte 1 2010.Jpg
 
Groupe Avance.Jpg
Groupe Avance.JpgGroupe Avance.Jpg
Groupe Avance.Jpg
 
Calendrier Am
Calendrier AmCalendrier Am
Calendrier Am
 

More from ConFoo

Debugging applications with network security tools
Debugging applications with network security toolsDebugging applications with network security tools
Debugging applications with network security toolsConFoo
 
The business behind open source
The business behind open sourceThe business behind open source
The business behind open sourceConFoo
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?ConFoo
 
OWASP Enterprise Security API
OWASP Enterprise Security APIOWASP Enterprise Security API
OWASP Enterprise Security APIConFoo
 
Opensource Authentication and Authorization
Opensource Authentication and AuthorizationOpensource Authentication and Authorization
Opensource Authentication and AuthorizationConFoo
 
Introduction à la sécurité des WebServices
Introduction à la sécurité des WebServicesIntroduction à la sécurité des WebServices
Introduction à la sécurité des WebServicesConFoo
 
Le bon, la brute et le truand dans les nuages
Le bon, la brute et le truand dans les nuagesLe bon, la brute et le truand dans les nuages
Le bon, la brute et le truand dans les nuagesConFoo
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHPConFoo
 
Décrire un projet PHP dans des rapports
Décrire un projet PHP dans des rapportsDécrire un projet PHP dans des rapports
Décrire un projet PHP dans des rapportsConFoo
 
Server Administration in Python with Fabric, Cuisine and Watchdog
Server Administration in Python with Fabric, Cuisine and WatchdogServer Administration in Python with Fabric, Cuisine and Watchdog
Server Administration in Python with Fabric, Cuisine and WatchdogConFoo
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+ConFoo
 
Think Mobile First, Then Enhance
Think Mobile First, Then EnhanceThink Mobile First, Then Enhance
Think Mobile First, Then EnhanceConFoo
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in RubyConFoo
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101ConFoo
 
As-t-on encore besoin d'un framework web ?
As-t-on encore besoin d'un framework web ?As-t-on encore besoin d'un framework web ?
As-t-on encore besoin d'un framework web ?ConFoo
 
Pragmatic Guide to Git
Pragmatic Guide to GitPragmatic Guide to Git
Pragmatic Guide to GitConFoo
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.jsConFoo
 
An Overview of Flash Storage for Databases
An Overview of Flash Storage for DatabasesAn Overview of Flash Storage for Databases
An Overview of Flash Storage for DatabasesConFoo
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump StartConFoo
 
Develop mobile applications with Flex
Develop mobile applications with FlexDevelop mobile applications with Flex
Develop mobile applications with FlexConFoo
 

More from ConFoo (20)

Debugging applications with network security tools
Debugging applications with network security toolsDebugging applications with network security tools
Debugging applications with network security tools
 
The business behind open source
The business behind open sourceThe business behind open source
The business behind open source
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
 
OWASP Enterprise Security API
OWASP Enterprise Security APIOWASP Enterprise Security API
OWASP Enterprise Security API
 
Opensource Authentication and Authorization
Opensource Authentication and AuthorizationOpensource Authentication and Authorization
Opensource Authentication and Authorization
 
Introduction à la sécurité des WebServices
Introduction à la sécurité des WebServicesIntroduction à la sécurité des WebServices
Introduction à la sécurité des WebServices
 
Le bon, la brute et le truand dans les nuages
Le bon, la brute et le truand dans les nuagesLe bon, la brute et le truand dans les nuages
Le bon, la brute et le truand dans les nuages
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHP
 
Décrire un projet PHP dans des rapports
Décrire un projet PHP dans des rapportsDécrire un projet PHP dans des rapports
Décrire un projet PHP dans des rapports
 
Server Administration in Python with Fabric, Cuisine and Watchdog
Server Administration in Python with Fabric, Cuisine and WatchdogServer Administration in Python with Fabric, Cuisine and Watchdog
Server Administration in Python with Fabric, Cuisine and Watchdog
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+Marrow: A Meta-Framework for Python 2.6+ and 3.1+
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
 
Think Mobile First, Then Enhance
Think Mobile First, Then EnhanceThink Mobile First, Then Enhance
Think Mobile First, Then Enhance
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101
 
As-t-on encore besoin d'un framework web ?
As-t-on encore besoin d'un framework web ?As-t-on encore besoin d'un framework web ?
As-t-on encore besoin d'un framework web ?
 
Pragmatic Guide to Git
Pragmatic Guide to GitPragmatic Guide to Git
Pragmatic Guide to Git
 
Building servers with Node.js
Building servers with Node.jsBuilding servers with Node.js
Building servers with Node.js
 
An Overview of Flash Storage for Databases
An Overview of Flash Storage for DatabasesAn Overview of Flash Storage for Databases
An Overview of Flash Storage for Databases
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump Start
 
Develop mobile applications with Flex
Develop mobile applications with FlexDevelop mobile applications with Flex
Develop mobile applications with Flex
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

Graphs, Edges & Nodes: Untangling the Social Web

  • 1. Graphs, Edges & Nodes Untangling the social web. Wednesday, March 9, 2011
  • 6. Graph 10 19 9 7 2 15 7 3 12 13 9 6 6 4 3 5 7 4 14 1 4 Wednesday, March 9, 2011
  • 7. Graph 11 10 10 19 6 9 7 2 15 7 21 3 8 12 15 13 13 17 9 22 6 6 3 4 4 3 2 5 7 4 6 14 9 12 1 10 4 19 Wednesday, March 9, 2011
  • 8. Simple At most one edge bet ween any pair of nodes. Wednesday, March 9, 2011
  • 9. Multigraph Multiple edges bet ween vertices allowed. Wednesday, March 9, 2011
  • 10. Pseudograph Self-loops are permitted. Wednesday, March 9, 2011
  • 11. G = (V, E) Wednesday, March 9, 2011
  • 13. What’s a node? vertex point junction 0-simplex Wednesday, March 9, 2011
  • 16. What’s an edge? arc branch line link 1-simplex Wednesday, March 9, 2011
  • 27. 1 3 2 4 (Finite simple graph) Wednesday, March 9, 2011
  • 28. vertices 0 1 1 1 1 0 0 0 vertices 1 0 0 1 1 0 1 0 Adjacency Matrix (2d array) Wednesday, March 9, 2011
  • 29. vertices 0 1 1 1 1 0 0 0 vertices 1 0 0 1 1 0 1 0 Adjacency Matrix (2d array) Wednesday, March 9, 2011
  • 30. 1 3 2 4 (Finite simple graph) Wednesday, March 9, 2011
  • 31. [1, 2, 3, 4] 2 1 1 1 3 4 3 4 Array entries (vertices) point to singly linked-lists Wednesday, March 9, 2011
  • 33. You are here. Wednesday, March 9, 2011
  • 35. (Graph does not include Justin Bieber) Wednesday, March 9, 2011
  • 47. People Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 48. People (friends) Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 49. People (friends) Items Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 50. People (friends) Items Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 51. People (me) (friends) Items Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 52. People (me) (friends) Items Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 53. People (me) (friends) Items Recommend items to me that are popular amongst my friends Wednesday, March 9, 2011
  • 54. 2-step path on homogeneous bipartite graph. Wednesday, March 9, 2011
  • 55. Strong Connection Problem (SCP) Wednesday, March 9, 2011
  • 56. There are many of these ‘fundamental’ graph units: - tripartite graphs (user/asset/tag) - folksonomies - multicolor-multiparity graph - etc. Wednesday, March 9, 2011
  • 57. Graph Storage Engines Wednesday, March 9, 2011
  • 58. Neo4j “An embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables.” http://neo4j.org Wednesday, March 9, 2011
  • 59. HypergraphDB “A general purpose, extensible, portable, distributed, embeddable, open-source data storage mechanism. It is a graph database designed specifically for artificial intelligence and semantic web projects.” http://kobrix.org/hgdb.jsp Wednesday, March 9, 2011
  • 60. Special Purpose Storage Engines Wednesday, March 9, 2011
  • 61. FlockDB “FlockDB is a database that stores graph data, but it isn't a database optimized for graph-traversal operations. Instead, it's optimized for very large adjacency lists, fast reads and writes, and page-able set arithmetic queries.” http://engineering.twitter.com/2010/05/introducing-flockdb.html Wednesday, March 9, 2011
  • 62. Redis “Redis is an advanced key-value store. [...] the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists, sets, and ordered sets. All this data types can be manipulated with atomic operations to push/pop elements, add/remove elements, perform server side union, intersection, difference between sets, etc.” http://code.google.com/p/redis Wednesday, March 9, 2011
  • 63. A Redis Friends/ Followers Example Wednesday, March 9, 2011
  • 64. Redis makes you think in terms of datastructures, and operations on those structures. Wednesday, March 9, 2011
  • 65. Set: Finite (for our cases) collection of objects in which order has no significance and multiplicity is generally ignored. S = { Alice, Bob, Carol } List: Finite (for our cases) collection of objects in which order *is* significant and multiplicity is allowed. L = [ X, Y, X, Z, Q] Wednesday, March 9, 2011
  • 66. Insert a user into a set SET uid:1000:username jperras Command Key Value Wednesday, March 9, 2011
  • 67. Use sets for denoting my followers/people I follow. Wednesday, March 9, 2011
  • 68. Adding a new follower SADD uid:1000:following 1001 SADD uid:1001:followers 1000 Command Key Value Wednesday, March 9, 2011
  • 69. Posting Updates $r = Redis(); $postid = $r->incr("global:nextPostId"); $post = $User['id'] ."|". time() ."|". $status; $r->set("post:$postid", $post); $followers = $r->smembers("uid:".$User['id'].":followers"); if ($followers === false) $followers = Array(); $followers[] = $User['id']; /* Add the post to our own posts too */ foreach($followers as $fid) {     $r->push("uid:$fid:posts", $postid, false); } # Push the post on the timeline, and trim the timeline to the # newest 1000 elements. $r->push("global:timeline", $postid, false); $r->ltrim("global:timeline",0,1000); Wednesday, March 9, 2011
  • 70. Common followers? - Set intersections! SINTER users:1000:followers users:1000:followers Command Key 1 Key 2 Wednesday, March 9, 2011
  • 71. A MySQL Example (simplified) Wednesday, March 9, 2011
  • 72. # Mutual Friends select f.friend_id from friends f join friends m on m.user_id = f.friend_id and m.friend_id = f.user_id where f.user_id = 1234 # Following (for directed graphs) select f.friend_id from friends f left join friends m on m.user_id = f.friend_id and m.friend_id = f.user_id where f.user_id = 1234 and m.user_id is null; # Followers (for directed graphs) select m.friend_id from friends f left join friends m on m.user_id = f.friend_id and m.friend_id = f.user_id where f.friend_id = 1234 and m.user_id is null Wednesday, March 9, 2011
  • 73. # Mutual Friends select f.friend_id from friends f join friends m on m.user_id = f.friend_id and m.friend_id = f.user_id where f.user_id = 1234 # Following (for directed graphs) select f.friend_id from friends f left join friends m Not too bad. on m.user_id = f.friend_id and m.friend_id = f.user_id where f.user_id = 1234 and m.user_id is null; # Followers (for directed graphs) select m.friend_id from friends f left join friends m on m.user_id = f.friend_id and m.friend_id = f.user_id where f.friend_id = 1234 and m.user_id is null Wednesday, March 9, 2011
  • 74. Relational databases can work for the simplest of cases, but are not always the best solution for many graph operations/algorithms. Wednesday, March 9, 2011
  • 75. Graphs and graph-databases are only going to be more and more useful. Wednesday, March 9, 2011
  • 76. However, graph algorithms are hard. So don’t write your own. And make sure you use a persistent storage engine that is best suited for the type of queries you will be performing. Wednesday, March 9, 2011
  • 78. Resources The Algorithm Design Manual, Steve S. Skiena Programming Collective Intelligence, Toby Segaran Introduction to Algorithms, Cormen, Leiserson, Rivest Wednesday, March 9, 2011
  • 80. Photo Credits Graph of the internet, circa 2003: http://www.duniacyber.com/freebies/education/what- is-internet-lookslike/ (built from partial troll of public servers using traceroute) My real friends for letting me use their Facebook profile images. Wednesday, March 9, 2011
  • 81. References Large Scale Graph Algorithms (class lectures), Yuri Lifshits, Steklov Institute of Mathematics at St. Petersburg http://mathworld.wolfram.com/Set.html Programming Collective Intelligence, Toby Segaran The Algorithm Design Manual, Steve S. Skiena Wednesday, March 9, 2011