SlideShare a Scribd company logo
1 of 18
Single-Source
Shortest Path on
MapReduce
Shenglei Zhao
Social Media Recommendation
Motivation
 Determine the appropriate person to recommend in
Social Media (Mainly Undirected here)
 Help calculate the Betweeness Centrality of A Person
in a Social Network
 (Weighted Graph) Best Route on Google Map
3
Algorithms – Breath-first Search
• Determine Root Node (starting Node)
• Initial Settings for all Nodes:
EdgeList, Distance From Root(initially all
Infinite), Status(not visited, being visited,
already visited), Parent Node
• Iteration of looking for neighbors and change
settings of nodes
4
Iteration
• Traverse all records (node ID and node setting),
find “BEINGVISITED” nodes (for example: A)
• Find their neighbors (B, C …..), apply new settings:
for B, C, …
Parent: null  A
Status: TOBEVISITED  BEINGVISITED
Distance: null  A’s distance + 1
for A:
Status: BEINGVISITED  VISITED
• Next Traversal would apply on these neighbors
(BEINGVISITED)
5
6
Map Reduce Structure
7
Preprocessing
Map & Reduce:
put data into
format
<nodeId,
nodeInformation>
Reduce:
Delete
old rows
of
neighbors
Map:
Create
new rows
for
neighbors
Postprocessing
Map & Reduce:
Collect all the
distances and get
the average
8
Design - <k, v> evolution
1
• Preprocessing Map & Reduce:
• List<n1, n2>  <n1, [n2,n3,n4…]> <n1 ID, neighbors IDs +
Distance + Status + Parent Node ID>
2
• Recurring Working Map & Reduce (shown in next
slide)
3
• Postprocessing Map & Reduce
• <ID2, nodeInformation>  <Status, distance>  <Status,
averageDistance>
Working Map & Reduce Sample
9
1 2,3|0|BEINGVISITED|source
2 1,3,4,5|Inf|TOBEVISITED|null
3 1,4,2|Inf|TOBEVISITED|null
4 2,3|Inf|TOBEVISITED|null
5 2|Inf|TOBEVISITED|null
Map
1 2,3|0|BEINGVISITED|source
2 1,3,4,5|Inf|TOBEVISITED|null
3 1,4,2|Inf|TOBEVISITED|null
4 2,3|Inf|TOBEVISITED|null
5 2|Inf|TOBEVISITED|null
1 |0|BEINGVISITED|source
2 |1|BEINGVISITED|1
3 |1|BEINGVISITED|1
1 2,3|0|VISITED|source
2 1,3,4,5|1|BEINGVISITED|1
3 1,4,2|1|BEINGVISITED|1
4 2,3|Inf|TOBEVISITED|null
5 2|Inf|TOBEVISITED|null
Parent Node this turn
New record
created
without
edge list
Merged records
Will be picked as parent Node
next turn
Code Snippet
10
11
Mapper for Core part of Algorithm
12
Reducer for Core part of Algorithm
13
Create an enum variable to represent counter
The counter increments by 1 when a node turns “BEINGVISITED”
Show the counter value on screen to show # of changes
14
Iteration for Job
Result
• A list of rows containing complete information
15
Result – distance-only
16
Result – average distance
17
• The average distance from all nodes to source
node (0) is about 2.829
• For random person, Person 0 has to go across
about 2.8 immediate persons to find him.
Future Work
• Calculate all the average distance to each nodes
• Determine betweeness centrality based on
results of all nodes
• Visualization of Network (lower average distance
nodes have bigger radius)
18

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Hadoop_FinalProject_ShengleiZhao

  • 3. Motivation  Determine the appropriate person to recommend in Social Media (Mainly Undirected here)  Help calculate the Betweeness Centrality of A Person in a Social Network  (Weighted Graph) Best Route on Google Map 3
  • 4. Algorithms – Breath-first Search • Determine Root Node (starting Node) • Initial Settings for all Nodes: EdgeList, Distance From Root(initially all Infinite), Status(not visited, being visited, already visited), Parent Node • Iteration of looking for neighbors and change settings of nodes 4
  • 5. Iteration • Traverse all records (node ID and node setting), find “BEINGVISITED” nodes (for example: A) • Find their neighbors (B, C …..), apply new settings: for B, C, … Parent: null  A Status: TOBEVISITED  BEINGVISITED Distance: null  A’s distance + 1 for A: Status: BEINGVISITED  VISITED • Next Traversal would apply on these neighbors (BEINGVISITED) 5
  • 6. 6
  • 7. Map Reduce Structure 7 Preprocessing Map & Reduce: put data into format <nodeId, nodeInformation> Reduce: Delete old rows of neighbors Map: Create new rows for neighbors Postprocessing Map & Reduce: Collect all the distances and get the average
  • 8. 8 Design - <k, v> evolution 1 • Preprocessing Map & Reduce: • List<n1, n2>  <n1, [n2,n3,n4…]> <n1 ID, neighbors IDs + Distance + Status + Parent Node ID> 2 • Recurring Working Map & Reduce (shown in next slide) 3 • Postprocessing Map & Reduce • <ID2, nodeInformation>  <Status, distance>  <Status, averageDistance>
  • 9. Working Map & Reduce Sample 9 1 2,3|0|BEINGVISITED|source 2 1,3,4,5|Inf|TOBEVISITED|null 3 1,4,2|Inf|TOBEVISITED|null 4 2,3|Inf|TOBEVISITED|null 5 2|Inf|TOBEVISITED|null Map 1 2,3|0|BEINGVISITED|source 2 1,3,4,5|Inf|TOBEVISITED|null 3 1,4,2|Inf|TOBEVISITED|null 4 2,3|Inf|TOBEVISITED|null 5 2|Inf|TOBEVISITED|null 1 |0|BEINGVISITED|source 2 |1|BEINGVISITED|1 3 |1|BEINGVISITED|1 1 2,3|0|VISITED|source 2 1,3,4,5|1|BEINGVISITED|1 3 1,4,2|1|BEINGVISITED|1 4 2,3|Inf|TOBEVISITED|null 5 2|Inf|TOBEVISITED|null Parent Node this turn New record created without edge list Merged records Will be picked as parent Node next turn
  • 11. 11 Mapper for Core part of Algorithm
  • 12. 12 Reducer for Core part of Algorithm
  • 13. 13 Create an enum variable to represent counter The counter increments by 1 when a node turns “BEINGVISITED” Show the counter value on screen to show # of changes
  • 15. Result • A list of rows containing complete information 15
  • 17. Result – average distance 17 • The average distance from all nodes to source node (0) is about 2.829 • For random person, Person 0 has to go across about 2.8 immediate persons to find him.
  • 18. Future Work • Calculate all the average distance to each nodes • Determine betweeness centrality based on results of all nodes • Visualization of Network (lower average distance nodes have bigger radius) 18