oct_4 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Everything is a graph. Except for graphs. Those are charts.
  2. We're going to talk about sparse graphs. This means there aren't too many edges compared to the possible amt of edges.
  3. CS people are masochists. (Because we love graphs, which are hard). Why:
  4. they can have weird structures (can be fun to make data structs for it)
  5. weird data access patters (Can be fun to make infrastructure to adjust for that)
  6. you can optimize things with graph things
  7. What do graphs have to do with MR/Spark?
  8. lots of graph algos do:
  9. compute stuff at each node, and continue traversing (propogate results) (often these computations have to do with parents/children)
  10. How to represent a graph in MR and Spark?
  11. Adjacency matrices (n * n matrix, each row/column represents a vertex, each cell is 1 or 0 if there is an edge from row to column)
  12. while easy to understand, it uses lots of space and is hard to actually code/compute on them
  13. Adjacency Lists: basically the above but just have a list of n lists, each list is a list of outgoing edges (this is like a postings list for text processing/search)
  14. compressible just like those postings lists, easy to compute things as your traverse from start -> end (compute over outgoing links). But rather hard to do the opposite without flipping the entire data strcuture beforehand
  15. Edge Lists: Just a fucking list of edges. Why? Cause it's fucking easy. Also you can always append shit, so good for processing a stream of input. But it uses lots of space, and computing on them efficiently is hard cause it's not in traversal order or anything.
  16. How to process them:
  17. split by edges or vertices??
  18. How to deal with undirected graphs?
  19. 1) you could store the edge both ways, and ensure your algo handles the dupes
  20. 2) store one edge using a static rule (eg start is always the lower ID)
  21. Things we can do with MR/Spark:
  22. Invert the graph: flatMap: emit each edge with the pair reversed, regroup as needed depending on which representation you used
  23. Going from types of representations to each other is pretty self-explanatory
  24. Make those cool graphical representations of data and relations!:
  25. treat all vertices like "like charges" (they repel each other)
  26. treat edges like spring connecting them (so they pull vertices together)
  27. this aint scalable though. 10,000+ nodes makes this useless and a giant mess to see
  28. How to do that with say, the interwebs?
  29. painfully
  30. SSSP:
  31. read the slides