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

Our Daily Graphs written in Ruby and Neo4j

hannelita
October 24, 2014

Our Daily Graphs written in Ruby and Neo4j

Talk given at RubyConf AR 2014 - Buenos AIres

hannelita

October 24, 2014
Tweet

More Decks by hannelita

Other Decks in Technology

Transcript

  1. Our Daily Graphs
    Written in Ruby and Neo4j

    View Slide

  2. Hola! / Oi! / Hi!
    • Hanneli - from Brazil
    • CodeMiner 42
    • Coffee (coffee, coffee, coffee, coffee, coffee,
    coffee), Pokémon, Lego and animals <3
    HIRING

    View Slide

  3. We *WON’T* see here
    • Advanced graph theory
    • Neo4j complete guide
    • Java stuff (Neo4j is written in Java)
    • Social Networks classics example (eeeww)

    View Slide

  4. Why graphs?
    In a Ruby Conference!

    View Slide

  5. Example
    How does Codeminer build dev teams?

    View Slide

  6. Example
    How does Codeminer build dev teams?
    MATCH

    View Slide

  7. How many times
    have you made
    drawings like these?

    View Slide

  8. Some history
    • Euler
    • Statistics
    • Patterns/relationship
    • Dependencies
    • Routes

    View Slide

  9. Persistence

    View Slide

  10. Persistence

    View Slide

  11. Persistence
    One of the first CS subjects is…

    View Slide

  12. Do you remember?
    Queue
    Stack
    Hash
    Tree
    Graphs

    View Slide

  13. Persistence
    What’s the first storing system we study!
    into databases class?
    a. Queue
    b. Stack
    c. Hash
    d. Tree
    e. None

    View Slide

  14. Persistence

    View Slide

  15. Have you ever thought about it?

    View Slide

  16. When did I notice that?

    View Slide

  17. Hydropower modelling

    View Slide

  18. Hydropower in Brazil

    View Slide

  19. Wanna represent hydropower map
    into relational model
    HYDROPOWER_PLANT
    locale:float
    capacity:float
    name:float
    providing_city_id:CITY
    neighbor_id:HYDROPOWER_PLANT
    population:int

    View Slide

  20. FUUUUUUU….

    View Slide

  21. FUUUUUUU….
    • According to population, how should I create
    hydropower plants neighbors?
    • If one plant shuts off, which one should replace it
    without causing damage to the entire system?
    • How should I avoid underuse?
    • Monitoring?

    View Slide

  22. Double Fail….

    View Slide

  23. ‘Unleraned?'

    View Slide

  24. Look at this

    View Slide

  25. Similar?

    View Slide

  26. Similar?

    View Slide

  27. Graphs oriented
    databases
    Because not all data need to live in tables

    View Slide

  28. Neo4j

    View Slide

  29. Our plants into graphs
    Itaipu!
    is_neighbor
    Itá
    latitude:33.43
    longitude:32:33
    capacity:1400
    latitude:43.43
    longitude:56:33
    capacity:700
    line_voltage:230

    View Slide

  30. Our plants into graphs
    Itaipu!
    is_neighbor
    Itá
    latitude:33.43
    longitude:32:33
    capacity:1400
    latitude:43.43
    longitude:56:33
    capacity:700
    line_voltage:230
    Node
    Relationship
    Attributes
    index

    View Slide

  31. Visual representation
    Itaipu!
    Itá

    View Slide

  32. Our plants into graphs
    Itaipu!
    feeds
    Foz do
    iguaçu
    latitude:33.43
    longitude:32:33
    capacity:1400
    population:265000
    feeds
    Curitiba
    population:1700000

    View Slide

  33. How many people does Itaipu feed?

    View Slide

  34. Traversal - Search
    Itaipu!
    feeds
    Foz do
    iguaçu
    latitude:33.43
    longitude:32:33
    capacity:1400
    population:265000
    feeds
    Curitiba
    population:1700000

    View Slide

  35. Cypher

    View Slide

  36. Neo4j with Ruby <3
    neo4j.rb
    Active Record

    View Slide

  37. Neo4j with Ruby <3
    REST API Wrapper
    Neography

    View Slide

  38. Neo4j - When should I not use?

    View Slide

  39. Neo4j - When should I not use?
    • NoSQL Hater?
    • Searches - BE CAREFUL (depth x width)
    • Cloud
    • Node Monitor
    • Infra (backup)
    • Limted RAM

    View Slide

  40. Obrigada!
    @hannelita
    [email protected]
    Questions?

    View Slide