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 full-size 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 full-size 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 full-size slide

  4. Why graphs?
    In a Ruby Conference!

    View full-size slide

  5. Example
    How does Codeminer build dev teams?

    View full-size slide

  6. Example
    How does Codeminer build dev teams?
    MATCH

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  9. Persistence
    One of the first CS subjects is…

    View full-size slide

  10. Do you remember?
    Queue
    Stack
    Hash
    Tree
    Graphs

    View full-size slide

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

    View full-size slide

  12. Have you ever thought about it?

    View full-size slide

  13. When did I notice that?

    View full-size slide

  14. Hydropower modelling

    View full-size slide

  15. Hydropower in Brazil

    View full-size slide

  16. 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 full-size slide

  17. FUUUUUUU….

    View full-size slide

  18. 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 full-size slide

  19. Double Fail….

    View full-size slide

  20. ‘Unleraned?'

    View full-size slide

  21. Look at this

    View full-size slide

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

    View full-size slide

  23. 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 full-size slide

  24. 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 full-size slide

  25. Visual representation
    Itaipu!
    Itá

    View full-size slide

  26. 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 full-size slide

  27. How many people does Itaipu feed?

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  30. Neo4j with Ruby <3
    REST API Wrapper
    Neography

    View full-size slide

  31. Neo4j - When should I not use?

    View full-size slide

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

    View full-size slide

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

    View full-size slide