SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
GRAPH DATABASES
   IN PYTHON
      Javier de la Rosa
            @versae
       The CulturePlex Lab
  Western University, London, ON

      PyCon Canada 2012
WHO I AM
●
    Javier de la Rosa
●
     versae
●
     versae
●
    Computer Scientist and
    Humanist
●
    CulturePlex Lab
●
     CulturePlex


               Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   2
FIRST OF ALL

“You do not really understand something
         unless you can explain it to your
                           grandmother”

                – (Frequently attributed to) Richard Feynman




     Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   3
DATABASES (in the last 30 years)
●
    Data in tables, rows and columns


●
    Pretty basic mechanism to make connections:
    –   Primary keys, Foreign keys, and... that's all


●
    Relational, ahem, really?




                  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   4
DATABASES (in the last 30 years)
●
    Rigid data schemas
    –   Have you ever tried to make a schema migration?


●
    Relational Algebra and SQL
    –   Terrible for highly interconnected data
    –   JOIN's can take a life to end (a bit overdramatized)




                  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   5
NoSQL, Not Only SQL
●
    Document                                      ●
                                                      Anaylitc
    –   MongoDB, CouchDB, etc.                         –   Hadoop


●
    Key-value stores                              ●
                                                      Graph
    –   Redis, Riak, Voldemort,                        –   Neo4j, OrientDB,
        Dynamo, etc.                                       HyperGraphDB, Titan, etc.


●
    Big Tables                                    ●
                                                      Other
    –   Cassandra, Hbase, etc                          –   Objectivity/DB, ZODB, etc.

                  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   6
DATABASES LANDSCAPE




                                          Source: 451Research, https://451research.com/report-long?icid=2289

Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                        7
WHO IS USING GRAPHS?
●
    Mozilla with Pancake and Pacer
    –   https://wiki.mozilla.org/Pancake &
        http://pangloss.github.com/pacer/
●
    Twitter with FlockDB
    –   https://github.com/twitter/flockdb
●
    Facebook with Open Graph
    –   https://developers.facebook.com/docs/opengraph/
●
    Google with Knowledge Graph
    –   http://www.google.ca/insidesearch/.../knowledge.html
                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   8
WHY GRAPHS?
●
    Data is getting more and more connected
    –   From text documents, to wikis, to ontologies, to
        folksonomies, etc


●
    And more semi-structured
    –   Think about the decentralization of content generation


●
    And more complex
    –   Social networks, semantic trending, etc
                             Source: Neo Technology, http://www.slideshare.net/emileifrem/neo4j-the-benefits-of-graph-databases-oscon-2009

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                                    9
A FEW OF THE CURRENT USES
●
    Social Networking and Recommendations
●
    Network and Cloud Management
●
    Master Data Management
●
    Geospatial
●
    Bioinformatics
●
    Content Management and Security and Access
    Control


                                                           Source: Mashable, http://mashable.com/2012/09/26/graph-databases/

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                    10
AND WHY ELSE?
●
    Because graphs are cool!




                               Leonard Euler
              Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   11
WHAT IS A GRAPH?


●
    G = (V, E)
    Where
    –   G is a graph
    –   V is a set of vertices
    –   E is a set of edges



                                                                 Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics)

                       Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                        12
WHAT IS A GRAPH?
●
    G = (V, E)
    –   Graph, aka network, diagram, etc.
    –   Vertex, aka point, dot, node, element, etc.
    –   Edge, aka relationship, arc, line, link, etc.


●
    Basically, “a graph states that something is related
    to something else”
                                                              – Svetlana Sicular,
                                                    Research Director at Gartner
                                                            Source: Gartner, http://blogs.gartner.com/svetlana-sicular/think-graph/

                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                           13
TYPES OF GRAPH




Undirected                                            Digraph



                                             Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics)

   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                        14
TYPES OF GRAPH




Multigraph                                      Hypergraph



                                             Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics)

   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                        15
SOME GRAPHS EVEN HAVE A NAME
●
    Complete graphs




          K3                                  K5                                             K8



                                                       Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs

               Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                         16
SOME GRAPHS EVEN HAVE A NAME
●
    Stars




            The star graphs S3, S4, S5 and S6



                                                     Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs

             Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                         17
SOME GRAPHS EVEN HAVE A NAME
●
    Snarks




    Blanuša (second)                  Szekeres                                 Double star



                                                      Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs

              Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                         18
THINGS CAN COMPLICATE...




       Local McLaughlin graph
                                          Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs

  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                         19
WAIT A SEC,




Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   20
DON'T WORRY
●
    Just one more type: the Property Graph



                                              1
                          2                                      1


            2                                 3                                    3


                                                                 4

                                              4




                Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012       21
THE PROPERTY GRAPH
●
    Directed, attributed and multi-relational
                                         Name: Javi

                                               1
                           2                                     1
                        Knows                                Knows
                      Since: 2009                          Since:1990
             2                                 3                                    3   Name: David
                                             Likes
         Name: John
                                                                  4
                                                                Likes
                                               4

                       Title: The Art of Computer Programming
                                       Price: $135


                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                22
THE PROPERTY GRAPH
●
    A set of nodes, and each node has:
    –   An unique identifier.
    –   A set of outgoing edges.
    –   A set of incoming edges.
    –   A collection of properties defined by a map from key to value.
●
    A set of relationships, and each relationship has:
    –   An unique identifier.
    –   An outgoing tail vertex.
    –   An incoming head vertex.
    –   And a collection of properties defined by a map from key to value.

                                                 Source: TinkerPop, https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                             23
IN SHORT
●
    A Property Graph is composed by:
    –   A set of nodes
    –   A set of relationships
    –   Properties and id's on both


●
    Sometimes, nodes and relationship can be typed
    –   In Blueprints and Neo4j, a label denotes the type of
        relationship between its two nodes.



                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   24
GRAPH DATABASES
●
    A graph database uses graph structures with nodes,
    edges, and properties to represent and store data
    –   ...but there is not an easy way to visualize this




                                                                Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       25
HOW IT LOOKS IN PYTHON?




  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   26
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")




              Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   27
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")




                                   Name: Silvester




              Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   28
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")
>>> arnold = g.nodes.create(name="Arnold")




                                   Name: Silvester




              Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   29
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")
>>> arnold = g.nodes.create(name="Arnold")




      Name: Silvester                                                      Name: Arnold


                Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012          30
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")
>>> arnold = g.nodes.create(name="Arnold")

>>> punch = arnold.punches(silvester)




      Name: Silvester                                                      Name: Arnold


                Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012          31
HOW IT LOOKS IN PYTHON?
# Let's create a graph
>>> silvester = g.nodes.create(name="Silvester")
>>> arnold = g.nodes.create(name="Arnold")

>>> punch = arnold.punches(silvester)




                                      punches




      Name: Silvester                                                      Name: Arnold


                Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012          32
HOW IT LOOKS IN PYTHON?


          punches

                           Name: Arnold




Name: Silvester

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   33
HOW IT LOOKS IN PYTHON?
  >>> chuck = g.nodes.create(name="Chuck")




          punches

                           Name: Arnold




Name: Silvester

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   34
HOW IT LOOKS IN PYTHON?
  >>> chuck = g.nodes.create(name="Chuck")




          punches

                           Name: Arnold




Name: Silvester                                                               Name: Chuck

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012        35
HOW IT LOOKS IN PYTHON?
  >>> chuck.dropkicks(silvester)
  >>> chuck.dropkicks(arnold)




          punches

                           Name: Arnold




Name: Silvester                                                               Name: Chuck

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012        36
HOW IT LOOKS IN PYTHON?
  >>> chuck.dropkicks(silvester)
  >>> chuck.dropkicks(arnold)




          punches                                   dropkicks

                           Name: Arnold



                               dropkicks



Name: Silvester                                                               Name: Chuck

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012        37
GRAPH DATABASES LANDSCAPE
  Database       Data Model           Query Method                 License                    Python Binding

                                     Cypher, Gremlin,                                            Native,
   Neo4j        Property Graph                                  GPL, AGPL
                                        Traversal                                            Blueprints, REST
                                          Gremlin,
  OrientDB      Property Graph                                    Apache 2                         Blueprints
                                          Traversal
                   Typed                 HGQuery,
HyperGraphDB                                                         LGPL                              Nope
                 Hypergraph              Traversal

    DEX         Property Graph            Traversal             Commercial                         Blueprints

   Titan        Property Graph             Gremlin                Apache 2                         Blueprints

                                                                  AGPL,
  InfoGrid      Property Graph            Traversal                                                    Nope
                                                                Commercial

InfiniteGraph   Property Graph             Gremlin              Commercial                             Nope


                                                               Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       40
GRAPH DATABASES LANDSCAPE
And more:
–   AffinityDB
–   YarcData uRiKA
–   Apache Giraph
–   Cassovary
–   StigDB
–   NuvolaBase
–   Pegasus
–   Microsoft Trinity
–   Sherlock
–   And so on

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   41
GRAPH DATABASES LANDSCAPE
  Database       Data Model           Query Method                 License                    Python Binding

                                     Cypher, Gremlin,                                            Native,
   Neo4j        Property Graph                                  GPL, AGPL
                                        Traversal                                            Blueprints, REST
                                          Gremlin,
  OrientDB      Property Graph                                    Apache 2                         Blueprints
                                          Traversal
                   Typed                 HGQuery,
HyperGraphDB                                                         LGPL                              Nope
                 Hypergraph              Traversal

    DEX         Property Graph            Traversal             Commercial                         Blueprints

   Titan        Property Graph             Gremlin                Apache 2                         Blueprints

                                                                  AGPL,
  InfoGrid      Property Graph            Traversal                                                    Nope
                                                                Commercial

InfiniteGraph   Property Graph             Gremlin              Commercial                             Nope


                                                               Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       42
GREMLIN, BLUEPRINTS, WAT?
Let me introduce you the TinkerPop Stack




                                                                 Source:TinkerPop, http://www.tinkerpop.com/

      Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                               43
BLUEPRINTS AND REXSTER
●
    Blueprints is a property graph model interface




●
    Rexster is a server that exposes any Blueprints
    graph through REST



                                                                          Source:TinkerPop, http://www.tinkerpop.com/

               Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                               44
AND WHAT ABOUT PYTHON?
●
    Options to connect to a Blueprints Graph Database


    OrientDB         Neo4j

                                                                                       bulbflow


        Blueprints API              Rexster                                     python-blueprints


                                                                                   pyblueprints
      DEX            Titan

                                                             REST




                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                45
BULBFLOW
●
    Create
    >>> alice = g.vertices.create(name="Alice")
    >>> bob = g.vertices.create(name="Bob")
    >>> g.edges.create(alice, "knows", bob)



●
    Get
    >>> alice = g.vertices.get(1)
    >>> bob = g.vertices.get(2)

●
    Update
    >>> alice.age = 21
    >>> alice.save()

●
    Delete
    >>> alice.delete()
                                                                             Source: Bulbflow, http://bulbflow.com/docs/

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                46
PYBLUEPRINTS
●
    Create
    >>>   alice = g.addVertex()
    >>>   alice.setProperty("name", "Alice")
    >>>   bob = g.addVertex()
    >>>   bob.setProperty("name", "Bob")
    >>>   g.addEdge(alice, bob, "knows")
●
    Get
    >>> alice = g.getVertex(1)
    >>> bob = g.getVertex(2)

●
    Update
    >>> alice.setProperty("age", 21)


●
    Delete
    >>> g.removeVertex(alice.getId())
                                                                  Source: PyBlueprints, https://github.com/escalant3/pyblueprints

                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       47
BUT NEO4J HAS ITS OWN CLIENTS!
●
    REST Clients for Neo4j
                                                                                neo4j-rest-client
    OrientDB         Neo4j
                                                                                       py2neo



        Blueprints API              Rexster                                            bulbflow


                                                                                python-blueprints
      DEX            Titan
                                                                                   pyblueprints


                                                             REST

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                48
HOW CAN I LOOKUP?
●
    An index is a data structure that supports the fast
    lookup of elements by some key/value pair




                                                   Source: TinkerPop, https://github.com/tinkerpop/blueprints/wiki/Graph-Indices

               Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                           49
INDICES
●
    In Python bindings, are similar to dict
    –   bulbflow
    # bulbflow creates auto indices to make easier basic lookups
    >>> nodes = g.vertices.index.lookup(name="Alice")
    >>> for node in nodes:
    ...:    print vertex



    –   PyBlueprints
    >>> index = g.getIndex("names", "vertex")
    >>> index.put("name", alice.getProperty("name"), alice)
    >>> nodes = index.get("name", "Alice")
    >>> for node in nodes:
    ...:    print node



                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   50
INDICES
●
    Some Graph Databases provide full-text queries
    –   bulbflow
    >>> nodes = g.vertices.index.query(name="ali*")
    >>> for node in nodes:
    ...:    print node




    –   PyBlueprints
    >>> index = g.getIndex("names", "vertex")
    >>> nodes = index.query("name", "ali*")
    >>> for node in nodes:
    ...:    print node




                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   51
...MORE COMPLEX SEARCHS?

“Without traversals [FlockDB] is only a persisted
graph. But not a graph database.”
                                                                   – Alex Popescu




                                                                     Source: myNoSQL, http://nosql.mypopescu.com/

           Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                               52
LET'S TRAVERSE THE GRAPH!
●
    “A graph traversal is the problem of visiting all the
    nodes in a graph in a particular manner”
    –   A* search
    –   Alpha-beta prunning
    –   Breadth-First Search (BFS)
    –   Depth-First Search (DFS)
    –   Dijkstra's algorithm
    –   Floyd-Warshall's algortimth
    –   Etc.
                                                                  Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_traversal

                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                        53
NEO4J TRAVERSAL API
●
    Python-embedded (native Neo4j Python binding)
    >>> traverser = gdb.traversal()
                    .relationships('knows').traverse(alice)

    # The graph is traversed as you loop through the result
    >>> for node in traverser.nodes:
    ...:    print node


●
    neo4j-rest-client
    >>> traverser = alice.traverse(types=[client.All.knows])

    # The graph is traversed as you loop through the result
    >>> for node in traverser:
    ...:    print node




                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   54
BLUEPRINTS GREMLIN

●
    Gremlin is a domain specific language for traversing
    property graphs
    –   Defines how to do a query based on the graph structure
    >>>   gremlin = g.extensions.GremlinPlugin.execute_script
    >>>   params = {'alice_id': alice.id}
    >>>   script = "g.V(alice_id).out('knows')"
    >>>   node = gremlin(script=script, params=params)
    >>>   node == bob


                                                                             Source: TinkerPop Gremlin, https://github.com/tinkerpop/gremlin/wiki
                       Source: Marko Rodríguez, The Graph Traversal Programmin Pattern, http://www.slideshare.net/slidarko/graph-windycitydb2010
                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                                      55
NEO4J CYPHER QUERY LANGUAGE
●
    Declarative graph query language
    –   Expressive and efficient querying
    –   Focused on expressing what to retrieve from a graph
    –   Inspired by SQL
    –   Pattern matching expressions from SPARQL




                                                               Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       56
NEO4J CYPHER QUERY LANGUAGE
●
    Declarative graph query language
    –   Expressive and efficient querying
    –   Focused on expressing what to retrieve from a graph
    –   Inspired by SQL
    –   Pattern matching expressions from SPARQL

                        1                                     2
                                         label


                    (1) -[:label]- (2)

                                                               Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       57
NEO4J CYPHER QUERY LANGUAGE
●
    Declarative graph query language
    –   Expressive and efficient querying
    –   Focused on expressing what to retrieve from a graph
    –   Inspired by SQL
    –   Pattern matching expressions from SPARQL

                        1                                     2
                                         label

               START n=(1), m=(2) MATCH
                    n-[r:label]-m
                       RETURN r
                                                               Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                       58
PY2NEO CYPHER HELPERS
●
    Get or create elements
    >>> g.get_or_create_relationships(
    ...:    (bob, "WORKS WITH", carol, {"since": 2004}),
    ...:    (alice, "DISLIKES!", carol, {"reason": "youth"}),
    ...:    (bob, "WORKS WITH", dave, {"since": 2009}), )

●
    Get counts
    >>> nodes_count = g.get_node_count()
    >>> rels_count = g.get_relationship_count()




●
    Delete
    >>> g.delete()


                                                                                        Source: py2neo, http://py2neo.org/

                     Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                              59
NEO4J-REST-CLIENT CYPHER HELPERS
●
    Query casting
    >>> q = """start n=node(*) match n-[r:punchs]-() """ 
            """return n, n.name, r, r.since"""
    >>> results = g.query(q, returns=(Node, unicode, Relationship, int))



●
    Complex filtering
    lookups = (
        Q("name", exact="Arnold") &
        (Q("surname", istartswith="swar") &
         ~Q("surname", iendswith="chenegger"))
    )
    arnolds = g.nodes.filter(lookups)




                                                            Source: neo4j-rest-client, https://github.com/versae/neo4j-rest-client

                  Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012                                            60
LET'S PLAY!
●
    Deploy Neo4j in Heroku or Amazon


●
    Use one of the available clients




               Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   61
NEO4J HEROKU ADD-ON
●
    Create a Heroku app and add the Neo4j add-on
    $   heroku apps:create pyconca
    $   heroku addons:add neo4j --app pyconca
    $   xdg-open `heroku config:get NEO4J_URL --app pyconca`
    $   export NEO4J_URL=`heroku config:get NEO4J_URL --app pyconca`




●
    Create a virtualenv with neo4j-rest-client
    $   mkvirtualenv --no-site-packages pyconca
    $   workon pyconca
    $   pip install ipython neo4jrestclient
    $   ipython




                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   62
NEO4J HEROKU ADD-ON
●
    Run IPython and that's it!
    >>>   import os
    >>>   NEO4J_URL = os.environ["NEO4J_URL"]
    >>>   from neo4jrestclient import client
    >>>   gdb = client.GraphDatabase(NEO4J_URL + "/db/data")
    >>>   gdb.url




                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   63
NEO4J HEROKU ADD-ON
●
    Run IPython and that's it!
    >>>   import os
    >>>   NEO4J_URL = os.environ["NEO4J_URL"]
    >>>   from neo4jrestclient import client
    >>>   gdb = client.GraphDatabase(NEO4J_URL + "/db/data")
    >>>   gdb.url




                   Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   64
THANKS!
     Questions?
    Javier de la Rosa
          @versae
     The CulturePlex Lab
Western University, London, ON

    PyCon Canada 2012
APPENDIX: DATA MODELS
●
    neo4django
    –   https://github.com/scholrly/neo4django


●
    neomodel
    –   https://github.com/robinedwards/neomodel


●
    bulbflow models
    –   http://bulbflow.com/quickstart/#models

                 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   66
APPENDIX: VISUALIZE YOUR GRAPH
●
    Export somehow to .gexf for Gephi
    –   http://gephi.org/
●
    Use D3.js
    –   http://d3js.org/
●
    Use sigma.js
    –   http://sigmajs.org/
●
    Take a look on Max De Marzi work
    –   http://maxdemarzi.com/category/visualization/
●
    Use Sylva (for newbies)
    –   http://www.sylvadb.com/
                    Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012   67

Más contenido relacionado

Was ist angesagt?

introduction to Neo4j (Tabriz Software Open Talks)
introduction to Neo4j (Tabriz Software Open Talks)introduction to Neo4j (Tabriz Software Open Talks)
introduction to Neo4j (Tabriz Software Open Talks)Farzin Bagheri
 
Presto as a Service - Tips for operation and monitoring
Presto as a Service - Tips for operation and monitoringPresto as a Service - Tips for operation and monitoring
Presto as a Service - Tips for operation and monitoringTaro L. Saito
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...Olaf Hartig
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...Olaf Hartig
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixStefan Krawczyk
 
H2O Deep Water - Making Deep Learning Accessible to Everyone
H2O Deep Water - Making Deep Learning Accessible to EveryoneH2O Deep Water - Making Deep Learning Accessible to Everyone
H2O Deep Water - Making Deep Learning Accessible to EveryoneSri Ambati
 
Neo, Titan & Cassandra
Neo, Titan & CassandraNeo, Titan & Cassandra
Neo, Titan & Cassandrajohnrjenson
 
LDQL: A Query Language for the Web of Linked Data
LDQL: A Query Language for the Web of Linked DataLDQL: A Query Language for the Web of Linked Data
LDQL: A Query Language for the Web of Linked DataOlaf Hartig
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...jaxLondonConference
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...jexp
 
H2O with Erin LeDell at Portland R User Group
H2O with Erin LeDell at Portland R User GroupH2O with Erin LeDell at Portland R User Group
H2O with Erin LeDell at Portland R User GroupSri Ambati
 
Sparkler - Spark Crawler
Sparkler - Spark Crawler Sparkler - Spark Crawler
Sparkler - Spark Crawler Thamme Gowda
 
Microservices, containers, and machine learning
Microservices, containers, and machine learningMicroservices, containers, and machine learning
Microservices, containers, and machine learningPaco Nathan
 
A super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMA super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMHolden Karau
 
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science Lab
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science LabScalable Ensemble Machine Learning @ Harvard Health Policy Data Science Lab
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science LabSri Ambati
 
A whirlwind tour of graph databases
A whirlwind tour of graph databasesA whirlwind tour of graph databases
A whirlwind tour of graph databasesjexp
 
Intro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariIntro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariKarissa Rae McKelvey
 

Was ist angesagt? (19)

introduction to Neo4j (Tabriz Software Open Talks)
introduction to Neo4j (Tabriz Software Open Talks)introduction to Neo4j (Tabriz Software Open Talks)
introduction to Neo4j (Tabriz Software Open Talks)
 
Presto as a Service - Tips for operation and monitoring
Presto as a Service - Tips for operation and monitoringPresto as a Service - Tips for operation and monitoring
Presto as a Service - Tips for operation and monitoring
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 1 (...
 
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
Tutorial "An Introduction to SPARQL and Queries over Linked Data" Chapter 3 (...
 
Data Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch FixData Day Texas 2017: Scaling Data Science at Stitch Fix
Data Day Texas 2017: Scaling Data Science at Stitch Fix
 
H2O Deep Water - Making Deep Learning Accessible to Everyone
H2O Deep Water - Making Deep Learning Accessible to EveryoneH2O Deep Water - Making Deep Learning Accessible to Everyone
H2O Deep Water - Making Deep Learning Accessible to Everyone
 
Neo, Titan & Cassandra
Neo, Titan & CassandraNeo, Titan & Cassandra
Neo, Titan & Cassandra
 
LDQL: A Query Language for the Web of Linked Data
LDQL: A Query Language for the Web of Linked DataLDQL: A Query Language for the Web of Linked Data
LDQL: A Query Language for the Web of Linked Data
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...
Designing and Building a Graph Database Application - Ian Robinson (Neo Techn...
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...
 
H2O with Erin LeDell at Portland R User Group
H2O with Erin LeDell at Portland R User GroupH2O with Erin LeDell at Portland R User Group
H2O with Erin LeDell at Portland R User Group
 
Sparkler - Spark Crawler
Sparkler - Spark Crawler Sparkler - Spark Crawler
Sparkler - Spark Crawler
 
Microservices, containers, and machine learning
Microservices, containers, and machine learningMicroservices, containers, and machine learning
Microservices, containers, and machine learning
 
A super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAMA super fast introduction to Spark and glance at BEAM
A super fast introduction to Spark and glance at BEAM
 
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science Lab
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science LabScalable Ensemble Machine Learning @ Harvard Health Policy Data Science Lab
Scalable Ensemble Machine Learning @ Harvard Health Policy Data Science Lab
 
A whirlwind tour of graph databases
A whirlwind tour of graph databasesA whirlwind tour of graph databases
A whirlwind tour of graph databases
 
Treasure Data Cloud Strategy
Treasure Data Cloud StrategyTreasure Data Cloud Strategy
Treasure Data Cloud Strategy
 
Intro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariIntro to Python Data Analysis in Wakari
Intro to Python Data Analysis in Wakari
 

Andere mochten auch

Persistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jPersistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jTobias Lindaaker
 
PyCon India 2012: Rapid development of website search in python
PyCon India 2012: Rapid development of website search in pythonPyCon India 2012: Rapid development of website search in python
PyCon India 2012: Rapid development of website search in pythonChetan Giridhar
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play NiceAlex Gaynor
 
Building Knowledge Graphs in DIG
Building Knowledge Graphs in DIGBuilding Knowledge Graphs in DIG
Building Knowledge Graphs in DIGPalak Modi
 
Bubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsBubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsStefan Urbanek
 
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...Trey Grainger
 
Blue Ocean Strategy 5 November 2010 Emergo Vfc1
Blue Ocean Strategy 5 November 2010 Emergo Vfc1Blue Ocean Strategy 5 November 2010 Emergo Vfc1
Blue Ocean Strategy 5 November 2010 Emergo Vfc1Nicoline Valk
 
Mobisfera - Agència de Mobile Marketing
Mobisfera - Agència de Mobile MarketingMobisfera - Agència de Mobile Marketing
Mobisfera - Agència de Mobile MarketingMobisfera
 
The Why and How of Java8 at LINE Fukuoka
The Why and How of Java8 at LINE FukuokaThe Why and How of Java8 at LINE Fukuoka
The Why and How of Java8 at LINE FukuokaYouhei Nitta
 
Fastrack Digital Marketing Campaign by Jubaer
Fastrack Digital Marketing Campaign by JubaerFastrack Digital Marketing Campaign by Jubaer
Fastrack Digital Marketing Campaign by JubaerSlide Gen
 
Designing The Digital Experience
Designing The Digital ExperienceDesigning The Digital Experience
Designing The Digital ExperienceDavid King
 
Presentación sobre autores por Mati y Vasile
Presentación sobre autores por Mati y VasilePresentación sobre autores por Mati y Vasile
Presentación sobre autores por Mati y VasilesextoBLucena
 
Multi-screen media report - May 2012 (Nielsen)
Multi-screen media report - May 2012 (Nielsen)Multi-screen media report - May 2012 (Nielsen)
Multi-screen media report - May 2012 (Nielsen)Maple Aikon
 

Andere mochten auch (19)

Persistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4jPersistent graphs in Python with Neo4j
Persistent graphs in Python with Neo4j
 
PyCon India 2012: Rapid development of website search in python
PyCon India 2012: Rapid development of website search in pythonPyCon India 2012: Rapid development of website search in python
PyCon India 2012: Rapid development of website search in python
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Building Knowledge Graphs in DIG
Building Knowledge Graphs in DIGBuilding Knowledge Graphs in DIG
Building Knowledge Graphs in DIG
 
Relational vs. Non-Relational
Relational vs. Non-RelationalRelational vs. Non-Relational
Relational vs. Non-Relational
 
Bubbles – Virtual Data Objects
Bubbles – Virtual Data ObjectsBubbles – Virtual Data Objects
Bubbles – Virtual Data Objects
 
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...
Searching on Intent: Knowledge Graphs, Personalization, and Contextual Disamb...
 
Espruinoの紹介
Espruinoの紹介Espruinoの紹介
Espruinoの紹介
 
Blue Ocean Strategy 5 November 2010 Emergo Vfc1
Blue Ocean Strategy 5 November 2010 Emergo Vfc1Blue Ocean Strategy 5 November 2010 Emergo Vfc1
Blue Ocean Strategy 5 November 2010 Emergo Vfc1
 
Divas (nx power lite)
Divas (nx power lite)Divas (nx power lite)
Divas (nx power lite)
 
Graphical Analysis
Graphical AnalysisGraphical Analysis
Graphical Analysis
 
Mobisfera - Agència de Mobile Marketing
Mobisfera - Agència de Mobile MarketingMobisfera - Agència de Mobile Marketing
Mobisfera - Agència de Mobile Marketing
 
The Why and How of Java8 at LINE Fukuoka
The Why and How of Java8 at LINE FukuokaThe Why and How of Java8 at LINE Fukuoka
The Why and How of Java8 at LINE Fukuoka
 
Dementias Platform UK
Dementias Platform UKDementias Platform UK
Dementias Platform UK
 
Fastrack Digital Marketing Campaign by Jubaer
Fastrack Digital Marketing Campaign by JubaerFastrack Digital Marketing Campaign by Jubaer
Fastrack Digital Marketing Campaign by Jubaer
 
Designing The Digital Experience
Designing The Digital ExperienceDesigning The Digital Experience
Designing The Digital Experience
 
Presentación sobre autores por Mati y Vasile
Presentación sobre autores por Mati y VasilePresentación sobre autores por Mati y Vasile
Presentación sobre autores por Mati y Vasile
 
Hidden markovmodel
Hidden markovmodelHidden markovmodel
Hidden markovmodel
 
Multi-screen media report - May 2012 (Nielsen)
Multi-screen media report - May 2012 (Nielsen)Multi-screen media report - May 2012 (Nielsen)
Multi-screen media report - May 2012 (Nielsen)
 

Ähnlich wie Graph Databases in Python (PyCon Canada 2012)

Getting started with R & Hadoop
Getting started with R & HadoopGetting started with R & Hadoop
Getting started with R & HadoopJeffrey Breen
 
The Semantic Web and Drupal 7 - Loja 2013
The Semantic Web and Drupal 7 - Loja 2013The Semantic Web and Drupal 7 - Loja 2013
The Semantic Web and Drupal 7 - Loja 2013scorlosquet
 
Apache Pig: Making data transformation easy
Apache Pig: Making data transformation easyApache Pig: Making data transformation easy
Apache Pig: Making data transformation easyVictor Sanchez Anguix
 
Scalable Hadoop with succinct Python: the best of both worlds
Scalable Hadoop with succinct Python: the best of both worldsScalable Hadoop with succinct Python: the best of both worlds
Scalable Hadoop with succinct Python: the best of both worldsDataWorks Summit
 
Graph Gurus Episode 1: Enterprise Graph
Graph Gurus Episode 1: Enterprise GraphGraph Gurus Episode 1: Enterprise Graph
Graph Gurus Episode 1: Enterprise GraphTigerGraph
 
Power of Python with Big Data
Power of Python with Big DataPower of Python with Big Data
Power of Python with Big DataEdureka!
 
Mapping the Web Ontology Language to OpenApi
Mapping the Web Ontology Language to OpenApiMapping the Web Ontology Language to OpenApi
Mapping the Web Ontology Language to OpenApiPaola Espinoza-Arias
 
DrupalCamp NJ 2014 Solr and Schema.org
DrupalCamp NJ 2014 Solr and Schema.orgDrupalCamp NJ 2014 Solr and Schema.org
DrupalCamp NJ 2014 Solr and Schema.orgscorlosquet
 
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future Wes McKinney
 
Bcn On Rails May2010 On Graph Databases
Bcn On Rails May2010 On Graph DatabasesBcn On Rails May2010 On Graph Databases
Bcn On Rails May2010 On Graph DatabasesPere Urbón-Bayes
 

Ähnlich wie Graph Databases in Python (PyCon Canada 2012) (20)

Running R on Hadoop - CHUG - 20120815
Running R on Hadoop - CHUG - 20120815Running R on Hadoop - CHUG - 20120815
Running R on Hadoop - CHUG - 20120815
 
Getting started with R & Hadoop
Getting started with R & HadoopGetting started with R & Hadoop
Getting started with R & Hadoop
 
Binary RDF for Scalable Publishing, Exchanging and Consumption in the Web of ...
Binary RDF for Scalable Publishing, Exchanging and Consumption in the Web of ...Binary RDF for Scalable Publishing, Exchanging and Consumption in the Web of ...
Binary RDF for Scalable Publishing, Exchanging and Consumption in the Web of ...
 
The Semantic Web and Drupal 7 - Loja 2013
The Semantic Web and Drupal 7 - Loja 2013The Semantic Web and Drupal 7 - Loja 2013
The Semantic Web and Drupal 7 - Loja 2013
 
Exploring Linked Data
Exploring Linked DataExploring Linked Data
Exploring Linked Data
 
Tese phd
Tese phdTese phd
Tese phd
 
Cloud-Based Spatial Data Analytics with R/Shiny
Cloud-Based Spatial Data Analytics with R/ShinyCloud-Based Spatial Data Analytics with R/Shiny
Cloud-Based Spatial Data Analytics with R/Shiny
 
Apache Pig: Making data transformation easy
Apache Pig: Making data transformation easyApache Pig: Making data transformation easy
Apache Pig: Making data transformation easy
 
Scalable Hadoop with succinct Python: the best of both worlds
Scalable Hadoop with succinct Python: the best of both worldsScalable Hadoop with succinct Python: the best of both worlds
Scalable Hadoop with succinct Python: the best of both worlds
 
Graph Gurus Episode 1: Enterprise Graph
Graph Gurus Episode 1: Enterprise GraphGraph Gurus Episode 1: Enterprise Graph
Graph Gurus Episode 1: Enterprise Graph
 
Power of Python with Big Data
Power of Python with Big DataPower of Python with Big Data
Power of Python with Big Data
 
Grails goes Graph
Grails goes GraphGrails goes Graph
Grails goes Graph
 
Mapping the Web Ontology Language to OpenApi
Mapping the Web Ontology Language to OpenApiMapping the Web Ontology Language to OpenApi
Mapping the Web Ontology Language to OpenApi
 
DrupalCamp NJ 2014 Solr and Schema.org
DrupalCamp NJ 2014 Solr and Schema.orgDrupalCamp NJ 2014 Solr and Schema.org
DrupalCamp NJ 2014 Solr and Schema.org
 
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future
PyCon Colombia 2020 Python for Data Analysis: Past, Present, and Future
 
Bcn On Rails May2010 On Graph Databases
Bcn On Rails May2010 On Graph DatabasesBcn On Rails May2010 On Graph Databases
Bcn On Rails May2010 On Graph Databases
 
Spark 2013-04-17
Spark 2013-04-17Spark 2013-04-17
Spark 2013-04-17
 
17CS008.pdf
17CS008.pdf17CS008.pdf
17CS008.pdf
 
Big Data & Hadoop. Simone Leo (CRS4)
Big Data & Hadoop. Simone Leo (CRS4)Big Data & Hadoop. Simone Leo (CRS4)
Big Data & Hadoop. Simone Leo (CRS4)
 
Seminario Cristian Lai, 06-09-2012
Seminario Cristian Lai, 06-09-2012Seminario Cristian Lai, 06-09-2012
Seminario Cristian Lai, 06-09-2012
 

Mehr von Javier de la Rosa

Neutralización de /l/ por /r/
Neutralización de /l/ por /r/Neutralización de /l/ por /r/
Neutralización de /l/ por /r/Javier de la Rosa
 
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...Javier de la Rosa
 
Databases evolution in CulturePlex Lab
Databases evolution in CulturePlex LabDatabases evolution in CulturePlex Lab
Databases evolution in CulturePlex LabJavier de la Rosa
 
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"Javier de la Rosa
 
Mejora de un problema combinatorio sobre vectores ordenados
Mejora de un problema combinatorio sobre vectores ordenadosMejora de un problema combinatorio sobre vectores ordenados
Mejora de un problema combinatorio sobre vectores ordenadosJavier de la Rosa
 

Mehr von Javier de la Rosa (6)

Dr. Glearning for FirefoxOS
Dr. Glearning for FirefoxOSDr. Glearning for FirefoxOS
Dr. Glearning for FirefoxOS
 
Neutralización de /l/ por /r/
Neutralización de /l/ por /r/Neutralización de /l/ por /r/
Neutralización de /l/ por /r/
 
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...
BaroqueArt at Arts, Humanities, and Complex Networks — 2nd Leonardo satellite...
 
Databases evolution in CulturePlex Lab
Databases evolution in CulturePlex LabDatabases evolution in CulturePlex Lab
Databases evolution in CulturePlex Lab
 
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"
Presentation of "Hybrid Page Layout Analysis via Tab-Stop Detection"
 
Mejora de un problema combinatorio sobre vectores ordenados
Mejora de un problema combinatorio sobre vectores ordenadosMejora de un problema combinatorio sobre vectores ordenados
Mejora de un problema combinatorio sobre vectores ordenados
 

Último

CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024Brian Pichman
 
IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingMAGNIntelligence
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTxtailishbaloch
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosErol GIRAUDY
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxNeo4j
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingFrancesco Corti
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfInfopole1
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsDianaGray10
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdfThe Good Food Institute
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxNeo4j
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIVijayananda Mohire
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Libraryshyamraj55
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarThousandEyes
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applicationsnooralam814309
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3DianaGray10
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveIES VE
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch TuesdayIvanti
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.IPLOOK Networks
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FESTBillieHyde
 

Último (20)

CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024CyberSecurity - Computers In Libraries 2024
CyberSecurity - Computers In Libraries 2024
 
IT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced ComputingIT Service Management (ITSM) Best Practices for Advanced Computing
IT Service Management (ITSM) Best Practices for Advanced Computing
 
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENTSIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
SIM INFORMATION SYSTEM: REVOLUTIONIZING DATA MANAGEMENT
 
Scenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenariosScenario Library et REX Discover industry- and role- based scenarios
Scenario Library et REX Discover industry- and role- based scenarios
 
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptxGraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
GraphSummit Copenhagen 2024 - Neo4j Vision and Roadmap.pptx
 
Where developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is goingWhere developers are challenged, what developers want and where DevEx is going
Where developers are challenged, what developers want and where DevEx is going
 
Extra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdfExtra-120324-Visite-Entreprise-icare.pdf
Extra-120324-Visite-Entreprise-icare.pdf
 
Automation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projectsAutomation Ops Series: Session 2 - Governance for UiPath projects
Automation Ops Series: Session 2 - Governance for UiPath projects
 
2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf2024.03.12 Cost drivers of cultivated meat production.pdf
2024.03.12 Cost drivers of cultivated meat production.pdf
 
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptxEmil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
Emil Eifrem at GraphSummit Copenhagen 2024 - The Art of the Possible.pptx
 
My key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAIMy key hands-on projects in Quantum, and QAI
My key hands-on projects in Quantum, and QAI
 
How to release an Open Source Dataweave Library
How to release an Open Source Dataweave LibraryHow to release an Open Source Dataweave Library
How to release an Open Source Dataweave Library
 
EMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? WebinarEMEA What is ThousandEyes? Webinar
EMEA What is ThousandEyes? Webinar
 
Graphene Quantum Dots-Based Composites for Biomedical Applications
Graphene Quantum Dots-Based Composites for  Biomedical ApplicationsGraphene Quantum Dots-Based Composites for  Biomedical Applications
Graphene Quantum Dots-Based Composites for Biomedical Applications
 
UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3UiPath Studio Web workshop Series - Day 3
UiPath Studio Web workshop Series - Day 3
 
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES LiveKeep Your Finger on the Pulse of Your Building's Performance with IES Live
Keep Your Finger on the Pulse of Your Building's Performance with IES Live
 
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie WorldTrustArc Webinar - How to Live in a Post Third-Party Cookie World
TrustArc Webinar - How to Live in a Post Third-Party Cookie World
 
March Patch Tuesday
March Patch TuesdayMarch Patch Tuesday
March Patch Tuesday
 
Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.Introduction - IPLOOK NETWORKS CO., LTD.
Introduction - IPLOOK NETWORKS CO., LTD.
 
Technical SEO for Improved Accessibility WTS FEST
Technical SEO for Improved Accessibility  WTS FESTTechnical SEO for Improved Accessibility  WTS FEST
Technical SEO for Improved Accessibility WTS FEST
 

Graph Databases in Python (PyCon Canada 2012)

  • 1. GRAPH DATABASES IN PYTHON Javier de la Rosa @versae The CulturePlex Lab Western University, London, ON PyCon Canada 2012
  • 2. WHO I AM ● Javier de la Rosa ● versae ● versae ● Computer Scientist and Humanist ● CulturePlex Lab ● CulturePlex Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 2
  • 3. FIRST OF ALL “You do not really understand something unless you can explain it to your grandmother” – (Frequently attributed to) Richard Feynman Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 3
  • 4. DATABASES (in the last 30 years) ● Data in tables, rows and columns ● Pretty basic mechanism to make connections: – Primary keys, Foreign keys, and... that's all ● Relational, ahem, really? Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 4
  • 5. DATABASES (in the last 30 years) ● Rigid data schemas – Have you ever tried to make a schema migration? ● Relational Algebra and SQL – Terrible for highly interconnected data – JOIN's can take a life to end (a bit overdramatized) Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 5
  • 6. NoSQL, Not Only SQL ● Document ● Anaylitc – MongoDB, CouchDB, etc. – Hadoop ● Key-value stores ● Graph – Redis, Riak, Voldemort, – Neo4j, OrientDB, Dynamo, etc. HyperGraphDB, Titan, etc. ● Big Tables ● Other – Cassandra, Hbase, etc – Objectivity/DB, ZODB, etc. Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 6
  • 7. DATABASES LANDSCAPE Source: 451Research, https://451research.com/report-long?icid=2289 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 7
  • 8. WHO IS USING GRAPHS? ● Mozilla with Pancake and Pacer – https://wiki.mozilla.org/Pancake & http://pangloss.github.com/pacer/ ● Twitter with FlockDB – https://github.com/twitter/flockdb ● Facebook with Open Graph – https://developers.facebook.com/docs/opengraph/ ● Google with Knowledge Graph – http://www.google.ca/insidesearch/.../knowledge.html Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 8
  • 9. WHY GRAPHS? ● Data is getting more and more connected – From text documents, to wikis, to ontologies, to folksonomies, etc ● And more semi-structured – Think about the decentralization of content generation ● And more complex – Social networks, semantic trending, etc Source: Neo Technology, http://www.slideshare.net/emileifrem/neo4j-the-benefits-of-graph-databases-oscon-2009 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 9
  • 10. A FEW OF THE CURRENT USES ● Social Networking and Recommendations ● Network and Cloud Management ● Master Data Management ● Geospatial ● Bioinformatics ● Content Management and Security and Access Control Source: Mashable, http://mashable.com/2012/09/26/graph-databases/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 10
  • 11. AND WHY ELSE? ● Because graphs are cool! Leonard Euler Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 11
  • 12. WHAT IS A GRAPH? ● G = (V, E) Where – G is a graph – V is a set of vertices – E is a set of edges Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics) Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 12
  • 13. WHAT IS A GRAPH? ● G = (V, E) – Graph, aka network, diagram, etc. – Vertex, aka point, dot, node, element, etc. – Edge, aka relationship, arc, line, link, etc. ● Basically, “a graph states that something is related to something else” – Svetlana Sicular, Research Director at Gartner Source: Gartner, http://blogs.gartner.com/svetlana-sicular/think-graph/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 13
  • 14. TYPES OF GRAPH Undirected Digraph Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics) Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 14
  • 15. TYPES OF GRAPH Multigraph Hypergraph Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_(mathematics) Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 15
  • 16. SOME GRAPHS EVEN HAVE A NAME ● Complete graphs K3 K5 K8 Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 16
  • 17. SOME GRAPHS EVEN HAVE A NAME ● Stars The star graphs S3, S4, S5 and S6 Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 17
  • 18. SOME GRAPHS EVEN HAVE A NAME ● Snarks Blanuša (second) Szekeres Double star Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 18
  • 19. THINGS CAN COMPLICATE... Local McLaughlin graph Source: Wikipedia, http://en.wikipedia.org/wiki/Gallery_of_named_graphs Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 19
  • 20. WAIT A SEC, Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 20
  • 21. DON'T WORRY ● Just one more type: the Property Graph 1 2 1 2 3 3 4 4 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 21
  • 22. THE PROPERTY GRAPH ● Directed, attributed and multi-relational Name: Javi 1 2 1 Knows Knows Since: 2009 Since:1990 2 3 3 Name: David Likes Name: John 4 Likes 4 Title: The Art of Computer Programming Price: $135 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 22
  • 23. THE PROPERTY GRAPH ● A set of nodes, and each node has: – An unique identifier. – A set of outgoing edges. – A set of incoming edges. – A collection of properties defined by a map from key to value. ● A set of relationships, and each relationship has: – An unique identifier. – An outgoing tail vertex. – An incoming head vertex. – And a collection of properties defined by a map from key to value. Source: TinkerPop, https://github.com/tinkerpop/gremlin/wiki/Defining-a-Property-Graph Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 23
  • 24. IN SHORT ● A Property Graph is composed by: – A set of nodes – A set of relationships – Properties and id's on both ● Sometimes, nodes and relationship can be typed – In Blueprints and Neo4j, a label denotes the type of relationship between its two nodes. Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 24
  • 25. GRAPH DATABASES ● A graph database uses graph structures with nodes, edges, and properties to represent and store data – ...but there is not an easy way to visualize this Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 25
  • 26. HOW IT LOOKS IN PYTHON? Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 26
  • 27. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 27
  • 28. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") Name: Silvester Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 28
  • 29. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") >>> arnold = g.nodes.create(name="Arnold") Name: Silvester Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 29
  • 30. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") >>> arnold = g.nodes.create(name="Arnold") Name: Silvester Name: Arnold Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 30
  • 31. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") >>> arnold = g.nodes.create(name="Arnold") >>> punch = arnold.punches(silvester) Name: Silvester Name: Arnold Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 31
  • 32. HOW IT LOOKS IN PYTHON? # Let's create a graph >>> silvester = g.nodes.create(name="Silvester") >>> arnold = g.nodes.create(name="Arnold") >>> punch = arnold.punches(silvester) punches Name: Silvester Name: Arnold Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 32
  • 33. HOW IT LOOKS IN PYTHON? punches Name: Arnold Name: Silvester Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 33
  • 34. HOW IT LOOKS IN PYTHON? >>> chuck = g.nodes.create(name="Chuck") punches Name: Arnold Name: Silvester Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 34
  • 35. HOW IT LOOKS IN PYTHON? >>> chuck = g.nodes.create(name="Chuck") punches Name: Arnold Name: Silvester Name: Chuck Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 35
  • 36. HOW IT LOOKS IN PYTHON? >>> chuck.dropkicks(silvester) >>> chuck.dropkicks(arnold) punches Name: Arnold Name: Silvester Name: Chuck Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 36
  • 37. HOW IT LOOKS IN PYTHON? >>> chuck.dropkicks(silvester) >>> chuck.dropkicks(arnold) punches dropkicks Name: Arnold dropkicks Name: Silvester Name: Chuck Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 37
  • 38. GRAPH DATABASES LANDSCAPE Database Data Model Query Method License Python Binding Cypher, Gremlin, Native, Neo4j Property Graph GPL, AGPL Traversal Blueprints, REST Gremlin, OrientDB Property Graph Apache 2 Blueprints Traversal Typed HGQuery, HyperGraphDB LGPL Nope Hypergraph Traversal DEX Property Graph Traversal Commercial Blueprints Titan Property Graph Gremlin Apache 2 Blueprints AGPL, InfoGrid Property Graph Traversal Nope Commercial InfiniteGraph Property Graph Gremlin Commercial Nope Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 40
  • 39. GRAPH DATABASES LANDSCAPE And more: – AffinityDB – YarcData uRiKA – Apache Giraph – Cassovary – StigDB – NuvolaBase – Pegasus – Microsoft Trinity – Sherlock – And so on Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 41
  • 40. GRAPH DATABASES LANDSCAPE Database Data Model Query Method License Python Binding Cypher, Gremlin, Native, Neo4j Property Graph GPL, AGPL Traversal Blueprints, REST Gremlin, OrientDB Property Graph Apache 2 Blueprints Traversal Typed HGQuery, HyperGraphDB LGPL Nope Hypergraph Traversal DEX Property Graph Traversal Commercial Blueprints Titan Property Graph Gremlin Apache 2 Blueprints AGPL, InfoGrid Property Graph Traversal Nope Commercial InfiniteGraph Property Graph Gremlin Commercial Nope Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 42
  • 41. GREMLIN, BLUEPRINTS, WAT? Let me introduce you the TinkerPop Stack Source:TinkerPop, http://www.tinkerpop.com/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 43
  • 42. BLUEPRINTS AND REXSTER ● Blueprints is a property graph model interface ● Rexster is a server that exposes any Blueprints graph through REST Source:TinkerPop, http://www.tinkerpop.com/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 44
  • 43. AND WHAT ABOUT PYTHON? ● Options to connect to a Blueprints Graph Database OrientDB Neo4j bulbflow Blueprints API Rexster python-blueprints pyblueprints DEX Titan REST Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 45
  • 44. BULBFLOW ● Create >>> alice = g.vertices.create(name="Alice") >>> bob = g.vertices.create(name="Bob") >>> g.edges.create(alice, "knows", bob) ● Get >>> alice = g.vertices.get(1) >>> bob = g.vertices.get(2) ● Update >>> alice.age = 21 >>> alice.save() ● Delete >>> alice.delete() Source: Bulbflow, http://bulbflow.com/docs/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 46
  • 45. PYBLUEPRINTS ● Create >>> alice = g.addVertex() >>> alice.setProperty("name", "Alice") >>> bob = g.addVertex() >>> bob.setProperty("name", "Bob") >>> g.addEdge(alice, bob, "knows") ● Get >>> alice = g.getVertex(1) >>> bob = g.getVertex(2) ● Update >>> alice.setProperty("age", 21) ● Delete >>> g.removeVertex(alice.getId()) Source: PyBlueprints, https://github.com/escalant3/pyblueprints Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 47
  • 46. BUT NEO4J HAS ITS OWN CLIENTS! ● REST Clients for Neo4j neo4j-rest-client OrientDB Neo4j py2neo Blueprints API Rexster bulbflow python-blueprints DEX Titan pyblueprints REST Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 48
  • 47. HOW CAN I LOOKUP? ● An index is a data structure that supports the fast lookup of elements by some key/value pair Source: TinkerPop, https://github.com/tinkerpop/blueprints/wiki/Graph-Indices Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 49
  • 48. INDICES ● In Python bindings, are similar to dict – bulbflow # bulbflow creates auto indices to make easier basic lookups >>> nodes = g.vertices.index.lookup(name="Alice") >>> for node in nodes: ...: print vertex – PyBlueprints >>> index = g.getIndex("names", "vertex") >>> index.put("name", alice.getProperty("name"), alice) >>> nodes = index.get("name", "Alice") >>> for node in nodes: ...: print node Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 50
  • 49. INDICES ● Some Graph Databases provide full-text queries – bulbflow >>> nodes = g.vertices.index.query(name="ali*") >>> for node in nodes: ...: print node – PyBlueprints >>> index = g.getIndex("names", "vertex") >>> nodes = index.query("name", "ali*") >>> for node in nodes: ...: print node Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 51
  • 50. ...MORE COMPLEX SEARCHS? “Without traversals [FlockDB] is only a persisted graph. But not a graph database.” – Alex Popescu Source: myNoSQL, http://nosql.mypopescu.com/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 52
  • 51. LET'S TRAVERSE THE GRAPH! ● “A graph traversal is the problem of visiting all the nodes in a graph in a particular manner” – A* search – Alpha-beta prunning – Breadth-First Search (BFS) – Depth-First Search (DFS) – Dijkstra's algorithm – Floyd-Warshall's algortimth – Etc. Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_traversal Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 53
  • 52. NEO4J TRAVERSAL API ● Python-embedded (native Neo4j Python binding) >>> traverser = gdb.traversal() .relationships('knows').traverse(alice) # The graph is traversed as you loop through the result >>> for node in traverser.nodes: ...: print node ● neo4j-rest-client >>> traverser = alice.traverse(types=[client.All.knows]) # The graph is traversed as you loop through the result >>> for node in traverser: ...: print node Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 54
  • 53. BLUEPRINTS GREMLIN ● Gremlin is a domain specific language for traversing property graphs – Defines how to do a query based on the graph structure >>> gremlin = g.extensions.GremlinPlugin.execute_script >>> params = {'alice_id': alice.id} >>> script = "g.V(alice_id).out('knows')" >>> node = gremlin(script=script, params=params) >>> node == bob Source: TinkerPop Gremlin, https://github.com/tinkerpop/gremlin/wiki Source: Marko Rodríguez, The Graph Traversal Programmin Pattern, http://www.slideshare.net/slidarko/graph-windycitydb2010 Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 55
  • 54. NEO4J CYPHER QUERY LANGUAGE ● Declarative graph query language – Expressive and efficient querying – Focused on expressing what to retrieve from a graph – Inspired by SQL – Pattern matching expressions from SPARQL Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 56
  • 55. NEO4J CYPHER QUERY LANGUAGE ● Declarative graph query language – Expressive and efficient querying – Focused on expressing what to retrieve from a graph – Inspired by SQL – Pattern matching expressions from SPARQL 1 2 label (1) -[:label]- (2) Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 57
  • 56. NEO4J CYPHER QUERY LANGUAGE ● Declarative graph query language – Expressive and efficient querying – Focused on expressing what to retrieve from a graph – Inspired by SQL – Pattern matching expressions from SPARQL 1 2 label START n=(1), m=(2) MATCH n-[r:label]-m RETURN r Source: Wikipedia, https://en.wikipedia.org/wiki/Graph_database Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 58
  • 57. PY2NEO CYPHER HELPERS ● Get or create elements >>> g.get_or_create_relationships( ...: (bob, "WORKS WITH", carol, {"since": 2004}), ...: (alice, "DISLIKES!", carol, {"reason": "youth"}), ...: (bob, "WORKS WITH", dave, {"since": 2009}), ) ● Get counts >>> nodes_count = g.get_node_count() >>> rels_count = g.get_relationship_count() ● Delete >>> g.delete() Source: py2neo, http://py2neo.org/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 59
  • 58. NEO4J-REST-CLIENT CYPHER HELPERS ● Query casting >>> q = """start n=node(*) match n-[r:punchs]-() """ """return n, n.name, r, r.since""" >>> results = g.query(q, returns=(Node, unicode, Relationship, int)) ● Complex filtering lookups = ( Q("name", exact="Arnold") & (Q("surname", istartswith="swar") & ~Q("surname", iendswith="chenegger")) ) arnolds = g.nodes.filter(lookups) Source: neo4j-rest-client, https://github.com/versae/neo4j-rest-client Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 60
  • 59. LET'S PLAY! ● Deploy Neo4j in Heroku or Amazon ● Use one of the available clients Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 61
  • 60. NEO4J HEROKU ADD-ON ● Create a Heroku app and add the Neo4j add-on $ heroku apps:create pyconca $ heroku addons:add neo4j --app pyconca $ xdg-open `heroku config:get NEO4J_URL --app pyconca` $ export NEO4J_URL=`heroku config:get NEO4J_URL --app pyconca` ● Create a virtualenv with neo4j-rest-client $ mkvirtualenv --no-site-packages pyconca $ workon pyconca $ pip install ipython neo4jrestclient $ ipython Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 62
  • 61. NEO4J HEROKU ADD-ON ● Run IPython and that's it! >>> import os >>> NEO4J_URL = os.environ["NEO4J_URL"] >>> from neo4jrestclient import client >>> gdb = client.GraphDatabase(NEO4J_URL + "/db/data") >>> gdb.url Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 63
  • 62. NEO4J HEROKU ADD-ON ● Run IPython and that's it! >>> import os >>> NEO4J_URL = os.environ["NEO4J_URL"] >>> from neo4jrestclient import client >>> gdb = client.GraphDatabase(NEO4J_URL + "/db/data") >>> gdb.url Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 64
  • 63. THANKS! Questions? Javier de la Rosa @versae The CulturePlex Lab Western University, London, ON PyCon Canada 2012
  • 64. APPENDIX: DATA MODELS ● neo4django – https://github.com/scholrly/neo4django ● neomodel – https://github.com/robinedwards/neomodel ● bulbflow models – http://bulbflow.com/quickstart/#models Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 66
  • 65. APPENDIX: VISUALIZE YOUR GRAPH ● Export somehow to .gexf for Gephi – http://gephi.org/ ● Use D3.js – http://d3js.org/ ● Use sigma.js – http://sigmajs.org/ ● Take a look on Max De Marzi work – http://maxdemarzi.com/category/visualization/ ● Use Sylva (for newbies) – http://www.sylvadb.com/ Graph Databases in Python, Javier de la Rosa, PyCon Canada, 2012 67