(Difficulty Level 5) There are N different cities each connect to another through a pipeline. The maximum flow capacity for a pipeline connecting two cities is given by an NxN matrix. For instance the following matrix represent the pipeline flow capacities among 5 different cities:   capacities = [[100, 19, 4, 14, 9], [1, 100, 23, 4, 15], [7, 30, 100, 1, 13], [2, 13, 2, 100, 25], [5, 21, 8, 12, 100]]You can notice that the diagonal is 100 because there is flow limitation for the same city (or we can assume that highest flow capacity is 100). The cities are numerated from 1 to N, so you can refer to a pipeline route as a list with the corresponding city numbers, for example:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

(Difficulty Level 5)
There are N different cities each connect to another through a pipeline. The maximum flow capacity for a pipeline connecting two cities is given by an NxN matrix. For instance the following matrix represent the pipeline flow capacities among 5 different cities:

 

capacities = [[100, 19, 4, 14, 9],
[1, 100, 23, 4, 15],
[7, 30, 100, 1, 13],
[2, 13, 2, 100, 25],
[5, 21, 8, 12, 100]]You can notice that the diagonal is 100 because there is flow limitation for the same city (or we can assume that highest flow capacity is 100). The cities are numerated from 1 to N, so you can refer to a pipeline route as a list with the corresponding city numbers, for example:

route = [3, 1, 5, 4]Refers to a pipeline connection where you start in the third city then move to the first one, then you go the to fifth and your final destination is the fourth one. The maximum flow capacity in this route will be given by the minimum of the individual capacities connecting each city. For example the capacity from 3 to 1, is 7; the capacity from 1 to 5, is 9; and the capacity from 5 to 4, is 12. Thus the maximum flow capacity of this pipeline route will be 7.

You must write a function max_flow(route, flows)that will receive the list containing the route and the matrix (a list of lists) containing the flows capacities. This function must return the maximum flow capacity for the route.



solve in python language 

For example:

Test Result
flows = [[100, 19, 4, 14, 9], [1, 100, 23, 4, 15], [7, 30, 100, 1, 13], [2, 13, 2, 100, 25], [5, 21, 8, 12, 100]] print(max_flow([1,2,3],flows)) 19
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education