bugfix - dict item removed during iteration

Change-Id: I283f6ca968a6289db6d218d37fb6e5b197130d46
This commit is contained in:
Idan Hefetz 2018-01-17 10:42:26 +00:00
parent 6fb1e323e1
commit 648a894b51

View File

@ -230,6 +230,8 @@ class NXAlgorithm(GraphAlgorithm):
@staticmethod @staticmethod
def _apply_edge_attr_filter(graph, edge_attr_filter): def _apply_edge_attr_filter(graph, edge_attr_filter):
for source, target, edge_data in graph._g.edges_iter(data=True): edges_iter = graph._g.edges_iter(data=True, keys=True)
if not check_filter(edge_data, edge_attr_filter): edges_to_remove = [(u, v, k) for (u, v, k, d) in edges_iter
graph._g.remove_edge(u=source, v=target) if not check_filter(d, edge_attr_filter)]
for source, target, key in edges_to_remove:
graph._g.remove_edge(u=source, v=target, key=key)