All problems
Butterfly Network Capacity
Problem
Return the multicast capacity of the symmetric butterfly network when each link has capacity link_capacity. Each receiver has two edge-disjoint paths, so network coding achieves 2 * link_capacity while plain routing only achieves link_capacity.
Hint
The middle link is coded so both receivers benefit from a single transmission.
Test cases
case 1
in: [1]
expected: 2
case 2
in: [0]
expected: 0
case 3
in: [0.5]
expected: 1
case 4
in: [10]
expected: 20
Starter codePython
def butterfly_capacity(link_capacity):
# Your code here
pass4 test cases · run your code against them in the editor