mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-15 11:25:53 +08:00
Use sets instead of dictionaries in merge_nodes
This commit is contained in:
+2
-11
@@ -63,17 +63,8 @@ class RAG(nx.Graph):
|
||||
The dict of keyword arguments passed to the `weight_func`.
|
||||
|
||||
"""
|
||||
neighbors = self.adj[src].copy()
|
||||
neighbors.update(self.adj[dst])
|
||||
|
||||
try:
|
||||
del neighbors[src]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
del neighbors[dst]
|
||||
except KeyError:
|
||||
pass
|
||||
neighbors = (set(self.neighbors(src)) & set(
|
||||
self.neighbors(dst))) - set([src, dst])
|
||||
|
||||
for neighbor in neighbors:
|
||||
w = weight_func(self, src, dst, neighbor, *extra_arguments,
|
||||
|
||||
Reference in New Issue
Block a user