我正在开展一个处理图像分割的课程项目。鉴于图像的初始过度分割,我们计划通过凝聚聚类将对合并在一起。
我们将首先遍历群集并推送成对距离和这些群集的ID(用于在更新距离时由于合并操作而引用)到数据结构中。
< / LI>在每次迭代时,将合并具有最小距离的一对簇,并且将删除存储该距离的节点。
最初连接到所述对的所有其他节点将重新计算它们的距离并更新信息(即它现在连接到群集a-b而不是群集a)。
我们建议使用Fibonacci堆,因为它可以找到O(1)中的最小键。然而,因为仍然存在搜索邻居和更新距离的问题,我想知道如果我为每个节点都有标签,Boost的Fibonacci堆的实现是否允许我在O(1)中找到某个节点?
TLDR:我想知道是否有可以有效定位节点并删除min的数据结构。
答案 0 :(得分:0)
根据a summary made by John Ahlgren关于std容器性能的SO q&a:
+------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | Container | Insertion | Access | Erase | Find | Persistent Iterators | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | vector / string | Back: O(1) or O(n) | O(1) | Back: O(1) | Sorted: O(log n) | No | | | Other: O(n) | | Other: O(n) | Other: O(n) | | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | deque | Back/Front: O(1) | O(1) | Back/Front: O(1) | Sorted: O(log n) | Pointers only | | | Other: O(n) | | Other: O(n) | Other: O(n) | | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | list | Back/Front: O(1) | Back/Front: O(1) | Back/Front: O(1) | O(n) | Yes | | forward_list | With iterator: O(1) | With iterator: O(1) | With iterator: O(1) | | | | | Index: O(n) | Index: O(n) | Index: O(n) | | | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | set / map | O(log n) | N/A | O(log n) | O(log n) | Yes | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | unordered_set | O(1) or O(n) | O(1) or O(n) | O(1) or O(n) | O(1) or O(n) | Pointers only | | unordered_map | | | | | | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+ | priority_queue | O(log n) | O(1) | O(log n) | N/A | N/A | +------------------+---------------------+---------------------+---------------------+------------------+----------------------+