際際滷

際際滷Share a Scribd company logo
Distributed Computing Seminar Lecture 5: Graph Algorithms & PageRank Christophe Bisciglia, Aaron Kimball, & Sierra Michels-Slettvet Summer 2007 Except as otherwise noted, the content of this presentation is 息 2007 Google Inc. and licensed under the Creative Commons Attribution 2.5 License.
Outline Motivation Graph Representations Breadth-First Search & Shortest-Path Finding PageRank
Motivating Concepts Performing computation on a graph data structure requires processing at each node Each node contains node-specific data as well as links (edges) to other nodes Computation must traverse the graph and perform the computation step How do we traverse a graph in MapReduce? How do we represent the graph for this?
Breadth-First Search Breadth-First Search is an  iterated  algorithm over graphs Frontier advances from origin by one level with each pass
Breadth-First Search & MapReduce Problem: This doesn't fit into MapReduce Solution: Iterated passes through MapReduce  map some nodes, result includes additional nodes which are fed into successive MapReduce passes
Breadth-First Search & MapReduce  Problem: Sending the entire graph to a map task (or hundreds/thousands of map tasks) involves an enormous amount of memory Solution: Carefully consider how we represent graphs
Graph Representations The most straightforward representation of graphs uses references from each node to its neighbors
Direct References Structure is inherent to object Iteration requires linked list threaded through graph Requires common view of shared memory (synchronization!) Not easily serializable class GraphNode { Object data; Vector<GraphNode> out_edges; GraphNode  iter_next; }
Adjacency Matrices Another classic graph representation. M[i][j]= '1' implies a link from node  i to j. Naturally encapsulates iteration over nodes 0 1 0 1 4 0 0 1 0 3 1 1 0 1 2 1 0 1 0 1 4 3 2 1
Adjacency Matrices: Sparse Representation Adjacency matrix for most large graphs (e.g., the web) will be overwhelmingly full of zeros.  Each row of the graph is absurdly long Sparse matrices only include non-zero elements
Sparse Matrix Representation 1: (3, 1), (18, 1), (200, 1) 2: (6, 1), (12, 1), (80, 1), (400, 1) 3: (1, 1), (14, 1)
Sparse Matrix Representation 1: 3, 18, 200 2: 6, 12, 80, 400 3: 1, 14
Finding the Shortest Path A common graph search application is finding the shortest path from a start node to one or more target nodes Commonly done on a single machine with  Dijkstra's Algorithm Can we use BFS to find the shortest path via MapReduce? This is called the single-source shortest path problem. (a.k.a. SSSP)
Finding the Shortest Path: Intuition We can define the solution to this problem inductively:  DistanceTo(startNode) = 0 For all nodes  n  directly reachable from startNode, DistanceTo(n) = 1 For all nodes  n  reachable from some other set of nodes  S ,  DistanceTo(n) = 1 + min(DistanceTo(m), m    S)
From Intuition to Algorithm A map task receives a node  n as  a key, and  (D, points-to)  as its value D  is the distance to the node from the start points-to  is a list of nodes reachable from  n  p    points-to, emit (p, D+1) Reduce task gathers possible distances to a given  p  and selects the minimum one
What This Gives Us This MapReduce task can advance the known frontier by one hop To perform the whole BFS, a non-MapReduce component then feeds the output of this step back into the MapReduce task for another iteration Problem: Where'd the points-to list go? Solution: Mapper emits (n, points-to) as well
Blow-up and Termination This algorithm starts from one node Subsequent iterations include many more nodes of the graph as frontier advances Does this ever terminate? Yes! Eventually, routes between nodes will stop being discovered and no better distances will be found. When distance is the same, we stop Mapper should emit  (n, D)  to ensure that current distance is carried into the reducer
Adding weights Weighted-edge shortest path is more useful than cost==1 approach Simple change: points-to list in map task includes a weight 'w' for each pointed-to node emit (p, D+w p ) instead of (p, D+1) for each node p Works for positive-weighted graph
Comparison to Dijkstra Dijkstra's algorithm is more efficient because at any step it only pursues edges from the minimum-cost path inside the frontier MapReduce version explores all paths in parallel; not as efficient overall, but the architecture is more scalable Equivalent to Dijkstra for weight=1 case
PageRank: Random Walks Over The Web If a user starts at a random web page and surfs by clicking links and randomly entering new URLs, what is the probability that s/he will arrive at a given page? The  PageRank  of a page captures this notion More popular or worthwhile pages get a higher rank
PageRank: Visually
PageRank: Formula Given page A, and pages T 1  through T n  linking to A, PageRank is defined as: PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n )) C(P) is the cardinality (out-degree) of page P d is the damping (random URL) factor
PageRank: Intuition Calculation is iterative: PR i+1  is based on PR i Each page distributes its PR i  to all pages it links to. Linkees add up their awarded rank fragments to find their PR i+1 d  is a tunable parameter (usually = 0.85) encapsulating the random jump factor PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
PageRank: Issues Is PageRank guaranteed to converge? How quickly? What is the correct value of油 d , and how sensitive is the algorithm to it? What is an efficient algorithm to solve this?
PageRank: First Implementation Create two tables 'current' and 'next' holding the PageRank for each page. Seed 'current' with initial PR values Iterate over all pages in the graph, distributing PR from 'current' into 'next' of linkees current := next; next := fresh_table(); Go back to iteration step or end if converged
Distribution of the Algorithm Key insights allowing parallelization: The 'next' table depends on 'current', but not on any other rows of 'next' Individual rows of the adjacency matrix can be processed in parallel Sparse matrix rows are relatively small
Distribution of the Algorithm Consequences of insights: We can  map  each row of 'current' to a list of PageRank fragments to assign to linkees These fragments can be  reduced  into a single PageRank value for a page by summing Graph representation can be even more compact; since each element is simply 0 or 1, only transmit column numbers where it's 1
油
Phase 1: Parse HTML Map task takes (URL, page content) pairs and maps them to (URL, (PR init , list-of-urls)) PR init  is the seed PageRank for URL list-of-urls contains all pages pointed to by URL Reduce task is just the identity function
Phase 2: PageRank Distribution Map task takes (URL, (cur_rank, url_list)) For each  u  in url_list, emit  ( u , cur_rank/|url_list|) Emit (URL, url_list) to carry the points-to list along through iterations PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
Phase 2: PageRank Distribution Reduce task gets (URL, url_list) and many (URL,  val ) values Sum  val s and fix up with  d Emit (URL, (new_rank, url_list)) PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
Finishing up... A non-parallelizable component determines whether convergence has been achieved (Fixed number of iterations? Comparison of key values?) If so, write out the PageRank lists - done! Otherwise, feed output of Phase 2 into another Phase 2 iteration
Conclusions MapReduce isn't the greatest at iterated computation, but still helps run the heavy lifting Key element in parallelization is independent PageRank computations in a given step Parallelization requires thinking about minimum data partitions to transmit (e.g., compact representations of graph rows) Even the implementation shown today doesn't actually scale to the whole Internet; but it works for intermediate-sized graphs

More Related Content

What's hot (20)

Shortest Path Problem
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
Guillaume Gu辿rard
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
Big Data Analysis with Signal Processing on Graphs
Big Data Analysis with Signal Processing on GraphsBig Data Analysis with Signal Processing on Graphs
Big Data Analysis with Signal Processing on Graphs
Mohamed Seif
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Ramoni Adeogun, PhD
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkX
Benjamin Bengfort
Djikstra's Algorithm
Djikstra's Algorithm Djikstra's Algorithm
Djikstra's Algorithm
Samar Kenkre
A star algorithms
A star algorithmsA star algorithms
A star algorithms
sandeep54552
Networkx tutorial
Networkx tutorialNetworkx tutorial
Networkx tutorial
Deepakshankar S
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRouting
antonpa
Application of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planningApplication of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planning
Darling Jemima
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search TraversalGraph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
1 chayes
1 chayes1 chayes
1 chayes
Yandex
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
Akshay soni
Scalar lenses-workshop
Scalar lenses-workshopScalar lenses-workshop
Scalar lenses-workshop
Marcin Matuszak
(Icca 2014) shortest path analysis in social graphs
(Icca 2014) shortest path analysis in social graphs(Icca 2014) shortest path analysis in social graphs
(Icca 2014) shortest path analysis in social graphs
Waqas Nawaz
cis98010
cis98010cis98010
cis98010
perfj
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
Linawati Adiman
From Data to Knowledge thru Grailog Visualization
From Data to Knowledge thru Grailog VisualizationFrom Data to Knowledge thru Grailog Visualization
From Data to Knowledge thru Grailog Visualization
giurca
Combinatorial Optimization
Combinatorial OptimizationCombinatorial Optimization
Combinatorial Optimization
Institute of Technology, Nirma University
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
Big Data Analysis with Signal Processing on Graphs
Big Data Analysis with Signal Processing on GraphsBig Data Analysis with Signal Processing on Graphs
Big Data Analysis with Signal Processing on Graphs
Mohamed Seif
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
Srikrishnan Suresh
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Ramoni Adeogun, PhD
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkX
Benjamin Bengfort
Djikstra's Algorithm
Djikstra's Algorithm Djikstra's Algorithm
Djikstra's Algorithm
Samar Kenkre
A star algorithms
A star algorithmsA star algorithms
A star algorithms
sandeep54552
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRouting
antonpa
Application of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planningApplication of Dijkstra Algorithm in Robot path planning
Application of Dijkstra Algorithm in Robot path planning
Darling Jemima
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search TraversalGraph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
1 chayes
1 chayes1 chayes
1 chayes
Yandex
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
Akshay soni
Scalar lenses-workshop
Scalar lenses-workshopScalar lenses-workshop
Scalar lenses-workshop
Marcin Matuszak
(Icca 2014) shortest path analysis in social graphs
(Icca 2014) shortest path analysis in social graphs(Icca 2014) shortest path analysis in social graphs
(Icca 2014) shortest path analysis in social graphs
Waqas Nawaz
cis98010
cis98010cis98010
cis98010
perfj
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
Linawati Adiman
From Data to Knowledge thru Grailog Visualization
From Data to Knowledge thru Grailog VisualizationFrom Data to Knowledge thru Grailog Visualization
From Data to Knowledge thru Grailog Visualization
giurca

Similar to Lec5 Pagerank (20)

MapReduceAlgorithms.ppt
MapReduceAlgorithms.pptMapReduceAlgorithms.ppt
MapReduceAlgorithms.ppt
CheeWeiTan10
Machine Learning and GraphX
Machine Learning and GraphXMachine Learning and GraphX
Machine Learning and GraphX
Andy Petrella
Behm Shah Pagerank
Behm Shah PagerankBehm Shah Pagerank
Behm Shah Pagerank
gothicane
PowerLyra@EuroSys2015
PowerLyra@EuroSys2015PowerLyra@EuroSys2015
PowerLyra@EuroSys2015
realstolz
Dstar Lite
Dstar LiteDstar Lite
Dstar Lite
Adrian Sotelo
Dijkstra
DijkstraDijkstra
Dijkstra
jagdeeparora86
d
dd
d
jagdeeparora86
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Subhajit Sahu
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam LermaGraph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
PyData
Alpine Spark Implementation - Technical
Alpine Spark Implementation - TechnicalAlpine Spark Implementation - Technical
Alpine Spark Implementation - Technical
alpinedatalabs
Multinomial Logistic Regression with Apache Spark
Multinomial Logistic Regression with Apache SparkMultinomial Logistic Regression with Apache Spark
Multinomial Logistic Regression with Apache Spark
DB Tsai
Streaming Python on Hadoop
Streaming Python on HadoopStreaming Python on Hadoop
Streaming Python on Hadoop
Vivian S. Zhang
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithms
guest084d20
Graph convolutional networks in apache spark
Graph convolutional networks in apache sparkGraph convolutional networks in apache spark
Graph convolutional networks in apache spark
Emiliano Martinez Sanchez
Lecture13
Lecture13Lecture13
Lecture13
vaishali_singh
Hadoop classes in mumbai
Hadoop classes in mumbaiHadoop classes in mumbai
Hadoop classes in mumbai
Vibrant Technologies & Computers
Chapter8-Link_Analysis.pptx
Chapter8-Link_Analysis.pptxChapter8-Link_Analysis.pptx
Chapter8-Link_Analysis.pptx
AmenahAbbood
Chapter8-Link_Analysis (1).pptx
Chapter8-Link_Analysis (1).pptxChapter8-Link_Analysis (1).pptx
Chapter8-Link_Analysis (1).pptx
AmenahAbbood
Data Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptxData Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
Social network-analysis-in-python
Social network-analysis-in-pythonSocial network-analysis-in-python
Social network-analysis-in-python
Joe OntheRocks
MapReduceAlgorithms.ppt
MapReduceAlgorithms.pptMapReduceAlgorithms.ppt
MapReduceAlgorithms.ppt
CheeWeiTan10
Machine Learning and GraphX
Machine Learning and GraphXMachine Learning and GraphX
Machine Learning and GraphX
Andy Petrella
Behm Shah Pagerank
Behm Shah PagerankBehm Shah Pagerank
Behm Shah Pagerank
gothicane
PowerLyra@EuroSys2015
PowerLyra@EuroSys2015PowerLyra@EuroSys2015
PowerLyra@EuroSys2015
realstolz
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Algorithmic optimizations for Dynamic Monolithic PageRank (from STICD) : SHOR...
Subhajit Sahu
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam LermaGraph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
PyData
Alpine Spark Implementation - Technical
Alpine Spark Implementation - TechnicalAlpine Spark Implementation - Technical
Alpine Spark Implementation - Technical
alpinedatalabs
Multinomial Logistic Regression with Apache Spark
Multinomial Logistic Regression with Apache SparkMultinomial Logistic Regression with Apache Spark
Multinomial Logistic Regression with Apache Spark
DB Tsai
Streaming Python on Hadoop
Streaming Python on HadoopStreaming Python on Hadoop
Streaming Python on Hadoop
Vivian S. Zhang
Parallel algorithms
Parallel algorithmsParallel algorithms
Parallel algorithms
guest084d20
Graph convolutional networks in apache spark
Graph convolutional networks in apache sparkGraph convolutional networks in apache spark
Graph convolutional networks in apache spark
Emiliano Martinez Sanchez
Chapter8-Link_Analysis.pptx
Chapter8-Link_Analysis.pptxChapter8-Link_Analysis.pptx
Chapter8-Link_Analysis.pptx
AmenahAbbood
Chapter8-Link_Analysis (1).pptx
Chapter8-Link_Analysis (1).pptxChapter8-Link_Analysis (1).pptx
Chapter8-Link_Analysis (1).pptx
AmenahAbbood
Data Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptxData Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
Social network-analysis-in-python
Social network-analysis-in-pythonSocial network-analysis-in-python
Social network-analysis-in-python
Joe OntheRocks

More from mobius.cn (7)

Lec4 Clustering
Lec4 ClusteringLec4 Clustering
Lec4 Clustering
mobius.cn
Lec3 Dfs
Lec3 DfsLec3 Dfs
Lec3 Dfs
mobius.cn
Lec2 Mapred
Lec2 MapredLec2 Mapred
Lec2 Mapred
mobius.cn
Parallel Programming Primer 1
Parallel Programming Primer 1Parallel Programming Primer 1
Parallel Programming Primer 1
mobius.cn
Lec1 Intro
Lec1 IntroLec1 Intro
Lec1 Intro
mobius.cn
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
Advanced Lighting Techniques   Dan Baker (Meltdown 2005)Advanced Lighting Techniques   Dan Baker (Meltdown 2005)
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
mobius.cn
Influence map
Influence mapInfluence map
Influence map
mobius.cn
Lec4 Clustering
Lec4 ClusteringLec4 Clustering
Lec4 Clustering
mobius.cn
Lec2 Mapred
Lec2 MapredLec2 Mapred
Lec2 Mapred
mobius.cn
Parallel Programming Primer 1
Parallel Programming Primer 1Parallel Programming Primer 1
Parallel Programming Primer 1
mobius.cn
Lec1 Intro
Lec1 IntroLec1 Intro
Lec1 Intro
mobius.cn
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
Advanced Lighting Techniques   Dan Baker (Meltdown 2005)Advanced Lighting Techniques   Dan Baker (Meltdown 2005)
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
mobius.cn
Influence map
Influence mapInfluence map
Influence map
mobius.cn

Lec5 Pagerank

  • 1. Distributed Computing Seminar Lecture 5: Graph Algorithms & PageRank Christophe Bisciglia, Aaron Kimball, & Sierra Michels-Slettvet Summer 2007 Except as otherwise noted, the content of this presentation is 息 2007 Google Inc. and licensed under the Creative Commons Attribution 2.5 License.
  • 2. Outline Motivation Graph Representations Breadth-First Search & Shortest-Path Finding PageRank
  • 3. Motivating Concepts Performing computation on a graph data structure requires processing at each node Each node contains node-specific data as well as links (edges) to other nodes Computation must traverse the graph and perform the computation step How do we traverse a graph in MapReduce? How do we represent the graph for this?
  • 4. Breadth-First Search Breadth-First Search is an iterated algorithm over graphs Frontier advances from origin by one level with each pass
  • 5. Breadth-First Search & MapReduce Problem: This doesn't fit into MapReduce Solution: Iterated passes through MapReduce map some nodes, result includes additional nodes which are fed into successive MapReduce passes
  • 6. Breadth-First Search & MapReduce Problem: Sending the entire graph to a map task (or hundreds/thousands of map tasks) involves an enormous amount of memory Solution: Carefully consider how we represent graphs
  • 7. Graph Representations The most straightforward representation of graphs uses references from each node to its neighbors
  • 8. Direct References Structure is inherent to object Iteration requires linked list threaded through graph Requires common view of shared memory (synchronization!) Not easily serializable class GraphNode { Object data; Vector<GraphNode> out_edges; GraphNode iter_next; }
  • 9. Adjacency Matrices Another classic graph representation. M[i][j]= '1' implies a link from node i to j. Naturally encapsulates iteration over nodes 0 1 0 1 4 0 0 1 0 3 1 1 0 1 2 1 0 1 0 1 4 3 2 1
  • 10. Adjacency Matrices: Sparse Representation Adjacency matrix for most large graphs (e.g., the web) will be overwhelmingly full of zeros. Each row of the graph is absurdly long Sparse matrices only include non-zero elements
  • 11. Sparse Matrix Representation 1: (3, 1), (18, 1), (200, 1) 2: (6, 1), (12, 1), (80, 1), (400, 1) 3: (1, 1), (14, 1)
  • 12. Sparse Matrix Representation 1: 3, 18, 200 2: 6, 12, 80, 400 3: 1, 14
  • 13. Finding the Shortest Path A common graph search application is finding the shortest path from a start node to one or more target nodes Commonly done on a single machine with Dijkstra's Algorithm Can we use BFS to find the shortest path via MapReduce? This is called the single-source shortest path problem. (a.k.a. SSSP)
  • 14. Finding the Shortest Path: Intuition We can define the solution to this problem inductively: DistanceTo(startNode) = 0 For all nodes n directly reachable from startNode, DistanceTo(n) = 1 For all nodes n reachable from some other set of nodes S , DistanceTo(n) = 1 + min(DistanceTo(m), m S)
  • 15. From Intuition to Algorithm A map task receives a node n as a key, and (D, points-to) as its value D is the distance to the node from the start points-to is a list of nodes reachable from n p points-to, emit (p, D+1) Reduce task gathers possible distances to a given p and selects the minimum one
  • 16. What This Gives Us This MapReduce task can advance the known frontier by one hop To perform the whole BFS, a non-MapReduce component then feeds the output of this step back into the MapReduce task for another iteration Problem: Where'd the points-to list go? Solution: Mapper emits (n, points-to) as well
  • 17. Blow-up and Termination This algorithm starts from one node Subsequent iterations include many more nodes of the graph as frontier advances Does this ever terminate? Yes! Eventually, routes between nodes will stop being discovered and no better distances will be found. When distance is the same, we stop Mapper should emit (n, D) to ensure that current distance is carried into the reducer
  • 18. Adding weights Weighted-edge shortest path is more useful than cost==1 approach Simple change: points-to list in map task includes a weight 'w' for each pointed-to node emit (p, D+w p ) instead of (p, D+1) for each node p Works for positive-weighted graph
  • 19. Comparison to Dijkstra Dijkstra's algorithm is more efficient because at any step it only pursues edges from the minimum-cost path inside the frontier MapReduce version explores all paths in parallel; not as efficient overall, but the architecture is more scalable Equivalent to Dijkstra for weight=1 case
  • 20. PageRank: Random Walks Over The Web If a user starts at a random web page and surfs by clicking links and randomly entering new URLs, what is the probability that s/he will arrive at a given page? The PageRank of a page captures this notion More popular or worthwhile pages get a higher rank
  • 22. PageRank: Formula Given page A, and pages T 1 through T n linking to A, PageRank is defined as: PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n )) C(P) is the cardinality (out-degree) of page P d is the damping (random URL) factor
  • 23. PageRank: Intuition Calculation is iterative: PR i+1 is based on PR i Each page distributes its PR i to all pages it links to. Linkees add up their awarded rank fragments to find their PR i+1 d is a tunable parameter (usually = 0.85) encapsulating the random jump factor PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
  • 24. PageRank: Issues Is PageRank guaranteed to converge? How quickly? What is the correct value of油 d , and how sensitive is the algorithm to it? What is an efficient algorithm to solve this?
  • 25. PageRank: First Implementation Create two tables 'current' and 'next' holding the PageRank for each page. Seed 'current' with initial PR values Iterate over all pages in the graph, distributing PR from 'current' into 'next' of linkees current := next; next := fresh_table(); Go back to iteration step or end if converged
  • 26. Distribution of the Algorithm Key insights allowing parallelization: The 'next' table depends on 'current', but not on any other rows of 'next' Individual rows of the adjacency matrix can be processed in parallel Sparse matrix rows are relatively small
  • 27. Distribution of the Algorithm Consequences of insights: We can map each row of 'current' to a list of PageRank fragments to assign to linkees These fragments can be reduced into a single PageRank value for a page by summing Graph representation can be even more compact; since each element is simply 0 or 1, only transmit column numbers where it's 1
  • 28.
  • 29. Phase 1: Parse HTML Map task takes (URL, page content) pairs and maps them to (URL, (PR init , list-of-urls)) PR init is the seed PageRank for URL list-of-urls contains all pages pointed to by URL Reduce task is just the identity function
  • 30. Phase 2: PageRank Distribution Map task takes (URL, (cur_rank, url_list)) For each u in url_list, emit ( u , cur_rank/|url_list|) Emit (URL, url_list) to carry the points-to list along through iterations PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
  • 31. Phase 2: PageRank Distribution Reduce task gets (URL, url_list) and many (URL, val ) values Sum val s and fix up with d Emit (URL, (new_rank, url_list)) PR(A) = (1-d) + d (PR(T 1 )/C(T 1 ) + ... + PR(T n )/C(T n ))
  • 32. Finishing up... A non-parallelizable component determines whether convergence has been achieved (Fixed number of iterations? Comparison of key values?) If so, write out the PageRank lists - done! Otherwise, feed output of Phase 2 into another Phase 2 iteration
  • 33. Conclusions MapReduce isn't the greatest at iterated computation, but still helps run the heavy lifting Key element in parallelization is independent PageRank computations in a given step Parallelization requires thinking about minimum data partitions to transmit (e.g., compact representations of graph rows) Even the implementation shown today doesn't actually scale to the whole Internet; but it works for intermediate-sized graphs