def compute_edges(): """ actions performed by the environment Alzeihmer desease: select randomly a certain percentage of edges. The weights of the edges will be reduced of a certain percentage """ num_edges_selected = int(math.ceil(gi.num_edges() * config.frac_edges )) selected=gi.random_edges(num_edges_selected) damaged = set() thisdamage=[] for e in selected: # each of these edges will be assigned a damage prev_weight = gi.get_weight(e) gi.mult_weight(e, config.frac_damage) diff = prev_weight - e.weight e.damage = diff # if the edge is too light, destroy it thisdamage.append((e.source, e.target, e.damage)) if gi.get_weight(e) < 1.0: #del e # FIXME!! careful!!! pass damaged.add(e) return damaged
def termination_condition3(): if gi.num_edges() <= 0: return True return False