Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Graphs + Hamsters

Lucas Dohmen
November 09, 2013

Graphs + Hamsters

My talk about Graphs, Hamsters & ArangoDB from yesterday.

Lucas Dohmen

November 09, 2013
Tweet

More Decks by Lucas Dohmen

Other Decks in Programming

Transcript

  1. RWTH Aachen, Computer Science Student triAGENS GmbH, Developer moonglum moonbeamlabs

    by Lucas Dohmen Graphs and Hamsters Modelling things differently
  2. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  3. Task • The hamster wants to know how much grain

    and how much nuts it has • It can’t remember the way back if it travels through more than two caves • It remembers which caves it already has visited
  4. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 0 Nuts: 0
  5. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 2 Nuts: 3
  6. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9 Grain: 4 Nuts: 3
  7. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  8. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  9. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  10. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  11. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  12. Grain: 0 Nuts: 0 Grain: 2 Nuts: 3 Grain: 2

    Nuts: 0 Grain: 5 Nuts: 5 Grain: 1 Nuts: 1 Grain: 0 Nuts: 2 Grain: 1 Nuts: 1 Grain: 2 Nuts: 1 Grain: 8 Nuts: 9
  13. The hamster is a visitor • There’s a natural way

    to implement it called traversals • There are a lot of things that you can implement very comfortably with traversals
  14. ArangoDB • Free & Open Source • Documents & Graphs

    • ArangoDB Query Language, but also simple queries • Real transactions • Master/Slave Replication • Extensible API • Embedded V8 • Extremely space efficient • High performance
  15. Post Request to /_api/traversal { "startVertex": "caves/Start", "edgeCollection": "tunnel", "direction":

    "any", "minDepth": 1, "maxDepth": 2, "uniqueness": { "vertices":"global", "edges":"global" }, "init": "result.grain = 0;result.nuts = 0;", "visitor": "result.grain += vertex.grain;result.nuts += vertex.nuts" }
  16. ArangoDB + Graphs • Graphical Graph Explorer is part of

    the admin interface • AQL has support for graphs • Iterators as shown before • Built in algorithms like shortest path etc.
  17. ArangoDB + Ruby • Ashikawa Core (https://github.com/triagens/ ashikawa-core): Low Level

    Driver • Guacamole (https://github.com/triagens/ guacamole): ODM with Rails Support