Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Disconnection makes me set. solution in Clear category for Node Disconnected Users by smilicic
def disconnected_users(net, users, source, crushes):
if source in crushes:
return sum(users.values())
net = {frozenset(link) for link in net}
crushes = set(crushes)
disconnects = set(link for link in net if link & crushes)
net -= disconnects
new_reachable = {source}
reachable = set()
while new_reachable:
reachable |= new_reachable
new_reachable = set()
for link in net.copy():
if link & reachable:
new_reachable |= link
net.remove(link)
return sum(user_count for node, user_count in users.items()
if node not in reachable)
Dec. 2, 2020
Comments: