diff --git a/skimage/graph/graph_cut.py b/skimage/graph/graph_cut.py index 9c133bd3..bc694409 100644 --- a/skimage/graph/graph_cut.py +++ b/skimage/graph/graph_cut.py @@ -47,6 +47,7 @@ def cut_threshold(labels, rag, thresh): """ # Because deleting edges while iterating through them produces an error. + rag = rag.copy() to_remove = [(x, y) for x, y, d in rag.edges_iter(data=True) if d['weight'] >= thresh] rag.remove_edges_from(to_remove)