SlideShare a Scribd company logo
1 of 1
Download to read offline
The Floyd-Warshall all-pairs shortest path algorithm computes, for each v,wV, the shortest path
from v to w. However, if the graph has negative cycles, the algorithm fails. Describe a modified
version of the algorithm (with the same asymptotic time complexity) that correctly returns
shortestpath distances, even if the graph contains negative cycles. That is, if there is a path from v
to some negative cycle, and a path from that cycle to w, the algorithm should output dist(v,w)=.
For any other pair v,w, the algorithm should output the length of the shortest directed path from v
to w.

More Related Content

More from adihost

The following table lists federal expenditures revenues an.pdf
The following table lists federal expenditures revenues an.pdfThe following table lists federal expenditures revenues an.pdf
The following table lists federal expenditures revenues an.pdfadihost
 
The following spreadsheet contains monthly returns for Cola .pdf
The following spreadsheet contains monthly returns for Cola .pdfThe following spreadsheet contains monthly returns for Cola .pdf
The following spreadsheet contains monthly returns for Cola .pdfadihost
 
The following relate to MPF aka maturation promoting factor.pdf
The following relate to MPF aka maturation promoting factor.pdfThe following relate to MPF aka maturation promoting factor.pdf
The following relate to MPF aka maturation promoting factor.pdfadihost
 
The following processes arrived in the order P1P2P3P4P5.pdf
The following processes arrived in the order P1P2P3P4P5.pdfThe following processes arrived in the order P1P2P3P4P5.pdf
The following processes arrived in the order P1P2P3P4P5.pdfadihost
 
The following is Ubuntu statement of financial position for .pdf
The following is Ubuntu statement of financial position for .pdfThe following is Ubuntu statement of financial position for .pdf
The following is Ubuntu statement of financial position for .pdfadihost
 
The following figure is a probability density curve that rep.pdf
The following figure is a probability density curve that rep.pdfThe following figure is a probability density curve that rep.pdf
The following figure is a probability density curve that rep.pdfadihost
 
The following information pertains to Ivanhoe Company 1 Ca.pdf
The following information pertains to Ivanhoe Company 1 Ca.pdfThe following information pertains to Ivanhoe Company 1 Ca.pdf
The following information pertains to Ivanhoe Company 1 Ca.pdfadihost
 
The following graph represents the demand and supply for bli.pdf
The following graph represents the demand and supply for bli.pdfThe following graph represents the demand and supply for bli.pdf
The following graph represents the demand and supply for bli.pdfadihost
 
The following are modified from Activity 84 5 You find an.pdf
The following are modified from Activity 84 5 You find an.pdfThe following are modified from Activity 84 5 You find an.pdf
The following are modified from Activity 84 5 You find an.pdfadihost
 
the following applies todescribes the glycocalyxcapsulesl.pdf
the following applies todescribes the glycocalyxcapsulesl.pdfthe following applies todescribes the glycocalyxcapsulesl.pdf
the following applies todescribes the glycocalyxcapsulesl.pdfadihost
 
The following data relates to company Y EBIT 2 million D.pdf
The following data relates to company Y EBIT  2 million D.pdfThe following data relates to company Y EBIT  2 million D.pdf
The following data relates to company Y EBIT 2 million D.pdfadihost
 
The following are the steps in periodontal disease Place th.pdf
The following are the steps in periodontal disease Place th.pdfThe following are the steps in periodontal disease Place th.pdf
The following are the steps in periodontal disease Place th.pdfadihost
 
The flypaper theory of tax incidence a assumes that most ta.pdf
The flypaper theory of tax incidence a assumes that most ta.pdfThe flypaper theory of tax incidence a assumes that most ta.pdf
The flypaper theory of tax incidence a assumes that most ta.pdfadihost
 
The following grammar is ambiguous Show the two derivation .pdf
The following grammar is ambiguous Show the two derivation .pdfThe following grammar is ambiguous Show the two derivation .pdf
The following grammar is ambiguous Show the two derivation .pdfadihost
 
The following figure depicts the aggregate demand AD the .pdf
The following figure depicts the aggregate demand AD the .pdfThe following figure depicts the aggregate demand AD the .pdf
The following figure depicts the aggregate demand AD the .pdfadihost
 
The following diagram represents the money market in the Uni.pdf
The following diagram represents the money market in the Uni.pdfThe following diagram represents the money market in the Uni.pdf
The following diagram represents the money market in the Uni.pdfadihost
 
The following are the transactions of Spotlighter Inc for.pdf
The following are the transactions of Spotlighter Inc for.pdfThe following are the transactions of Spotlighter Inc for.pdf
The following are the transactions of Spotlighter Inc for.pdfadihost
 
The flow rate of fluorine from a 65m stack is 12kgs The.pdf
The flow rate of fluorine from a 65m stack is 12kgs The.pdfThe flow rate of fluorine from a 65m stack is 12kgs The.pdf
The flow rate of fluorine from a 65m stack is 12kgs The.pdfadihost
 
The following data were taken from the records of Marin Comp.pdf
The following data were taken from the records of Marin Comp.pdfThe following data were taken from the records of Marin Comp.pdf
The following data were taken from the records of Marin Comp.pdfadihost
 
The FischerTropsch FT process was developed in Germany i.pdf
The FischerTropsch FT process was developed in Germany i.pdfThe FischerTropsch FT process was developed in Germany i.pdf
The FischerTropsch FT process was developed in Germany i.pdfadihost
 

More from adihost (20)

The following table lists federal expenditures revenues an.pdf
The following table lists federal expenditures revenues an.pdfThe following table lists federal expenditures revenues an.pdf
The following table lists federal expenditures revenues an.pdf
 
The following spreadsheet contains monthly returns for Cola .pdf
The following spreadsheet contains monthly returns for Cola .pdfThe following spreadsheet contains monthly returns for Cola .pdf
The following spreadsheet contains monthly returns for Cola .pdf
 
The following relate to MPF aka maturation promoting factor.pdf
The following relate to MPF aka maturation promoting factor.pdfThe following relate to MPF aka maturation promoting factor.pdf
The following relate to MPF aka maturation promoting factor.pdf
 
The following processes arrived in the order P1P2P3P4P5.pdf
The following processes arrived in the order P1P2P3P4P5.pdfThe following processes arrived in the order P1P2P3P4P5.pdf
The following processes arrived in the order P1P2P3P4P5.pdf
 
The following is Ubuntu statement of financial position for .pdf
The following is Ubuntu statement of financial position for .pdfThe following is Ubuntu statement of financial position for .pdf
The following is Ubuntu statement of financial position for .pdf
 
The following figure is a probability density curve that rep.pdf
The following figure is a probability density curve that rep.pdfThe following figure is a probability density curve that rep.pdf
The following figure is a probability density curve that rep.pdf
 
The following information pertains to Ivanhoe Company 1 Ca.pdf
The following information pertains to Ivanhoe Company 1 Ca.pdfThe following information pertains to Ivanhoe Company 1 Ca.pdf
The following information pertains to Ivanhoe Company 1 Ca.pdf
 
The following graph represents the demand and supply for bli.pdf
The following graph represents the demand and supply for bli.pdfThe following graph represents the demand and supply for bli.pdf
The following graph represents the demand and supply for bli.pdf
 
The following are modified from Activity 84 5 You find an.pdf
The following are modified from Activity 84 5 You find an.pdfThe following are modified from Activity 84 5 You find an.pdf
The following are modified from Activity 84 5 You find an.pdf
 
the following applies todescribes the glycocalyxcapsulesl.pdf
the following applies todescribes the glycocalyxcapsulesl.pdfthe following applies todescribes the glycocalyxcapsulesl.pdf
the following applies todescribes the glycocalyxcapsulesl.pdf
 
The following data relates to company Y EBIT 2 million D.pdf
The following data relates to company Y EBIT  2 million D.pdfThe following data relates to company Y EBIT  2 million D.pdf
The following data relates to company Y EBIT 2 million D.pdf
 
The following are the steps in periodontal disease Place th.pdf
The following are the steps in periodontal disease Place th.pdfThe following are the steps in periodontal disease Place th.pdf
The following are the steps in periodontal disease Place th.pdf
 
The flypaper theory of tax incidence a assumes that most ta.pdf
The flypaper theory of tax incidence a assumes that most ta.pdfThe flypaper theory of tax incidence a assumes that most ta.pdf
The flypaper theory of tax incidence a assumes that most ta.pdf
 
The following grammar is ambiguous Show the two derivation .pdf
The following grammar is ambiguous Show the two derivation .pdfThe following grammar is ambiguous Show the two derivation .pdf
The following grammar is ambiguous Show the two derivation .pdf
 
The following figure depicts the aggregate demand AD the .pdf
The following figure depicts the aggregate demand AD the .pdfThe following figure depicts the aggregate demand AD the .pdf
The following figure depicts the aggregate demand AD the .pdf
 
The following diagram represents the money market in the Uni.pdf
The following diagram represents the money market in the Uni.pdfThe following diagram represents the money market in the Uni.pdf
The following diagram represents the money market in the Uni.pdf
 
The following are the transactions of Spotlighter Inc for.pdf
The following are the transactions of Spotlighter Inc for.pdfThe following are the transactions of Spotlighter Inc for.pdf
The following are the transactions of Spotlighter Inc for.pdf
 
The flow rate of fluorine from a 65m stack is 12kgs The.pdf
The flow rate of fluorine from a 65m stack is 12kgs The.pdfThe flow rate of fluorine from a 65m stack is 12kgs The.pdf
The flow rate of fluorine from a 65m stack is 12kgs The.pdf
 
The following data were taken from the records of Marin Comp.pdf
The following data were taken from the records of Marin Comp.pdfThe following data were taken from the records of Marin Comp.pdf
The following data were taken from the records of Marin Comp.pdf
 
The FischerTropsch FT process was developed in Germany i.pdf
The FischerTropsch FT process was developed in Germany i.pdfThe FischerTropsch FT process was developed in Germany i.pdf
The FischerTropsch FT process was developed in Germany i.pdf
 

Recently uploaded

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Recently uploaded (20)

General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

The FloydWarshall allpairs shortest path algorithm compute.pdf

  • 1. The Floyd-Warshall all-pairs shortest path algorithm computes, for each v,wV, the shortest path from v to w. However, if the graph has negative cycles, the algorithm fails. Describe a modified version of the algorithm (with the same asymptotic time complexity) that correctly returns shortestpath distances, even if the graph contains negative cycles. That is, if there is a path from v to some negative cycle, and a path from that cycle to w, the algorithm should output dist(v,w)=. For any other pair v,w, the algorithm should output the length of the shortest directed path from v to w.