A network has n computers and there are connecting links between them. Each link can be used for sending a certain number of bits per second from one computer to another.
Your task is to find out what is the maximum number of bits per second that can be send from a given computer to another.
You may assume that the number of computers is at most 50 and that the methods of the class are called at most 100 times. The bit rate of each link is an integer in the range 1 \dots 1000.
In a file download.py
, implement a class Download
with the following methods:
- constructor with the number of computers as a parameter
add_link
adds a connecting link from a computer a to a computer b with the capacity of x bits per secondcalculate
returns the maximum bit rate from a computer a to a computer b
class Download: def __init__(self,n): # TODO def add_link(self,a,b,x): # TODO def calculate(self,a,b): # TODO if __name__ == "__main__": d = Download(4) print(d.calculate(1,4)) # 0 d.add_link(1,2,5) d.add_link(2,4,6) d.add_link(1,4,2) print(d.calculate(1,4)) # 7 d.add_link(1,3,4) d.add_link(3,2,2) print(d.calculate(1,4)) # 8