Use foreach_out_edge_safe() instead of reimplementing it.