Manuscript Offprint
arXiv:2611.00146FastHeapDict: Permanent Slot Indexing for Efficient Decrease-Key Operations in Indexed Priority Queues
Hojjat T. Goudarzi
Oregon State University
Corvallis, Oregon, USA
Arash Torabi Goodarzi
University of Würzburg
Würzburg, Germany
arash.goodarzi@uni-wuerzburg.de
Mohammad Amir Eshraghi
Purdue University
West Lafayette, Indiana, USA
Abstract—Efficient decrease-key support remains an important practical concern in priority queues used by shortest-path and graph-processing algorithms. Although duplicate-entry heaps avoid explicit decrease-key operations and are simple to implement, they may accumulate many stale entries when tentative priorities are repeatedly improved. This paper presents FastHeapDict, an indexed binary min-heap based on permanent slot indexing. Instead of repeatedly locating keys through hash-table lookups during heap repair, FastHeapDict assigns each key a stable integer slot and stores that slot directly in heap entries. As a result, position updates during sift-up and sift-down operations are performed through integer indexing while preserving the usual indexed-heap interface.
We evaluate FastHeapDict in both Python and C++20 using Dijkstra's algorithm as the primary experimental workload. The benchmarks include constructed dense stress graphs, randomized dense graph variants, and comparisons against duplicate-entry heaps and existing priority-queue alternatives. Across the tested Python workloads, FastHeapDict consistently outperforms the duplicate-entry heapq baseline and the tested heapdict and pqdict implementations. In the C++20 implementation, FastHeapDict also achieves strong constant-factor improvements over std::priority_queue duplicates, std::set-based decrease-key, and std::multiset duplicates. These results indicate that permanent slot indexing can provide a compact and effective implementation strategy for indexed priority queues in workloads where priority updates are frequent.
I. INTRODUCTION
Priority queues are fundamental components of many graph algorithms and optimization problems. Among their most important operations is decrease-key, which allows the priority associated with an existing element to be updated efficiently without inserting duplicate entries. Algorithms such as Dijkstra's single-source shortest-path algorithm rely heavily on this operation when tentative distances are repeatedly improved during execution [1].
Despite the theoretical importance of decrease-key, many practical implementations of Dijkstra's algorithm avoid supporting it explicitly. Instead, they rely on a duplicate-entry strategy in which every distance improvement inserts a new heap entry while obsolete entries are discarded only when they are eventually removed from the priority queue. This approach is simple, robust, and readily supported by widely used libraries such as Python's heapq [2] and C++'s std::priority_queue [3]. However, when many priority updates occur before vertices are finalized, duplicate entries accumulate, increasing the number of heap operations, memory usage, and unnecessary processing of stale elements.
Indexed priority queues address this limitation [4] by maintaining exactly one live entry for each key and updating its priority in place. Traditional indexed heaps, however, typically maintain a mapping from keys to heap positions, requiring repeated hash-table or dictionary lookups whenever heap elements move during sift-up or sift-down operations. Although these lookups have expected constant-time complexity, they contribute additional constant-factor overhead in implementations where decrease-key operations occur frequently.
This paper introduces FastHeapDict, an indexed binary min-heap based on the idea of permanent slot indexing.
Unlike conventional indexed heaps that repeatedly recover heap positions through key-based hash-table accesses, FastHeapDict performs all subsequent heap maintenance through direct integer indexing once a permanent slot has been assigned. Each key is assigned a stable integer slot when it first appears, and heap entries store this slot together with the key and its priority. A separate position array maps slots to current heap locations, allowing heap repair operations to update positions through integer indexing rather than repeated key-based hash lookups. The resulting implementation preserves the simplicity and asymptotic complexity of a conventional indexed binary heap while reducing practical overhead during decrease-key operations.
The contribution of this work is implementation-oriented rather than asymptotic. FastHeapDict does not change the theoretical complexity of indexed binary heaps; instead, it proposes a compact implementation strategy that reduces repeated hash-table access during heap maintenance. To evaluate its practical effectiveness, we implement FastHeapDict independently in both Python and C++20 and use Dijkstra's algorithm as the primary evaluation workload. The proposed design is compared against duplicate-entry heaps as well as existing indexed and tree-based priority-queue implementations across several controlled benchmark families.
The remainder of this paper is organized as follows. Section II reviews existing priority-queue designs and practical implementations of Dijkstra's algorithm. Section III presents the design of FastHeapDict. Section IV describes the C++20 implementation. Section V outlines the experimental methodology. Sections VI and VII present the Python and C++20 experimental results, respectively. Sections VIII and IX discuss the findings and limitations of the study, and Section X concludes the paper.
Considerable research has explored priority-queue structures with improved theoretical performance. Fibonacci heaps achieve constant amortized time for decrease-key and lead to stronger asymptotic bounds for several graph algorithms [6]. Pairing heaps were later proposed as a simpler self-adjusting alternative that often performs well in practice while retaining many of the advantages of more sophisticated heap structures [7]. Despite these theoretical developments, binary heaps continue to dominate many production implementations because their lower constant factors and implementation simplicity frequently outweigh asymptotic improvements for practical workloads.
Many widely used software libraries expose priority queues without providing explicit decrease-key support. Python's heapq module implements an efficient binary heap but leaves indexed priority updates to the application [2]. Consequently, Dijkstra's algorithm is often implemented using duplicate entries together with lazy deletion of stale elements. Third-party libraries such as pqdict [8] and heapdict [9] provide indexed priority queues with direct priority updates. Similarly, the C++ Standard Library offers std::priority_queue [3], which follows the duplicate-entry approach in practical shortest-path implementations, while ordered containers such as std::set [10] and std::multiset [11] can be adapted to support priority updates through erase-and-reinsert operations.
FastHeapDict belongs to the family of indexed binary heaps, but differs in how the mapping between keys and heap positions is maintained. Conventional indexed implementations typically update a key-to-position map whenever heap elements move during sift-up or sift-down operations. FastHeapDict instead assigns each key a permanent integer slot and records heap positions using slot indices rather than repeatedly accessing the original keys. The motivation is not to change the asymptotic complexity of indexed heaps, but to reduce practical constant-factor overhead associated with repeated key hashing during heap maintenance. The following sections describe this design in detail and evaluate its effectiveness using Dijkstra's algorithm as the primary benchmark workload.
III. FASTHEAPDICT DESIGN
A. Design Motivation
The goal of FastHeapDict is not to change the theoretical complexity of indexed binary heaps, but to reduce the implementation overhead incurred during practical decrease-key workloads.
Indexed binary heaps support efficient decrease-key operations [4] by maintaining a mapping from each key to its current position in the heap. A conventional implementation stores this mapping directly as a key-to-index dictionary. Whenever two heap entries are exchanged during BUBBLEUP or BUBBLEDOWN, the corresponding dictionary entries must also be updated. Although each lookup or update has expected constant-time complexity, repeated key hashing becomes part of every heap repair operation. In workloads that perform frequent priority updates, this overhead contributes to the overall constant factors of the implementation.
FastHeapDict addresses this issue by separating key identification from heap maintenance. Rather than storing heap positions directly in the hash table, each key is assigned a permanent integer slot when it first appears. Heap entries carry this slot together with the key and its priority, while a separate position array maps slots to the current heap indices. Once the slot has been obtained, all subsequent heap maintenance is performed through integer indexing without further key-based hash lookups. The resulting design preserves the behavior and asymptotic complexity of a conventional indexed binary heap while reducing the amount of hash-table activity during heap movement.
a) Definition (Permanent Slot Indexing).: Permanent slot indexing is a position-management strategy in which each key is assigned a unique integer slot exactly once during its lifetime. Heap entries retain this slot permanently, while a separate position array maps slots to current heap locations. Consequently, heap maintenance relies on direct integer indexing instead of repeated key-based hash lookups.
B. Data Structures
FastHeapDict is organized around three complementary data structures:
-
slot: a hash table mapping each key to its permanent slot;
-
pos: an integer array mapping each slot to the current heap position, or -1 if the key is not currently present in the heap;
Algorithm 1 FastHeapDict insert-or-update
Require: key k, priority p 1: s ← slot assigned to k, creating one if needed 2: if s is new or pos[s] < 0 then 3: append (p, k, s) to heap 4: pos[s] ← index of new entry 5: BUBBLEUP from pos[s] 6: else 7: i ← pos[s] 8: old ← heap[i].priority 9: heap[i].priority ← p 10: if p < old then 11: BUBBLEUP from i 12: else if p > old then 13: BUBBLEDOWN from i 14: end if 15: end if
- heap: a binary min-heap, following the array-based heap representation introduced for heapsort [5], whose entries store the triple (priority, key, slot).
Each key receives its slot only once. The slot remains permanently associated with that key, even after the corresponding heap entry has been removed. If the key is inserted again later, the existing slot is reused. During Dijkstra's algorithm each vertex normally has at most one live heap entry, but permanent slot indexing also provides a consistent representation for more general insertion and reinsertion scenarios.
C. Priority Updates
Insertion and priority updates begin with a single lookup in the slot table. If the key has not appeared previously, a new slot is allocated, appended to the position array, and stored together with the newly created heap entry before restoring the heap property using BUBBLEUP. If the key already has a live heap entry, its priority is modified in place and the heap is repaired by invoking either BUBBLEUP or BUBBLEDOWN, depending on whether the priority decreases or increases.
Heap repair is implemented using the hole method. Rather than repeatedly swapping adjacent heap entries, the updated element is temporarily removed while parent or child entries are shifted into the vacant position. Since every heap entry carries its permanent slot identifier, the corresponding position array can be updated immediately through integer indexing without consulting the key-to-slot hash table. This organization reduces repeated hashing while preserving the standard behavior of binary heap operations.
Algorithm 1 summarizes the insert-or-update procedure.
D. Complexity Analysis
Let V denote the number of vertices and E the number of edges. In the indexed implementation of Dijkstra's algorithm, FastHeapDict maintains at most one live heap entry for each vertex. Insertions, priority updates, and minimum removals therefore require heap operations together with an expected key-to-slot lookup at the beginning of each insertion or update. Consequently, Dijkstra's algorithm retains its standard running time of while requiring auxiliary space for the priority queue. Including the graph representation, the overall space complexity remains .
The duplicate-entry strategy exhibits a different practical behavior. Every successful edge relaxation may insert an additional heap entry, allowing obsolete entries to accumulate until they are eventually removed. In the worst case, this results in up to heap entries and corresponding stale removals, increasing both memory consumption and the amount of heap maintenance performed during execution. The experimental evaluation presented later is designed to highlight these practical differences while recognizing that both approaches retain the same asymptotic running time.
IV. C++20 IMPLEMENTATION
The C++20 implementation follows the same algorithmic design as the Python version while leveraging static typing and standard-library containers [12], [13]. The permanent slot indexing strategy is preserved without modification, allowing the experimental comparison to focus on implementation language and runtime characteristics rather than differences in data structures or algorithms.
The key-to-slot mapping is implemented using std::unordered_map<Key, std::size_t> [12]. Heap positions are stored in a std::vector<int> [13], where a value of -1 indicates that the corresponding key is not currently present in the heap. The binary heap itself is maintained as a std::vector<Node>, with each node storing a priority, a key, and its permanent slot identifier.
Insertion and update operations use try_emplace [12] to combine slot lookup and allocation into a single operation. When a key is inserted for the first time, a new heap node is appended and restored to the correct position using BUBBLEUP. If the key already has a live heap entry, its priority is updated in place, after which either BUBBLEUP or BUBBLEDOWN is performed depending on whether the priority decreases or increases.
As in the Python implementation, heap repair uses the hole method rather than repeated adjacent swaps. During heap movement, the position array is updated directly through the permanent slot stored in each node. Consequently, heap maintenance never performs additional lookups in the key-to-slot hash table after the initial slot has been obtained.
To evaluate the practical behavior of the proposed design, the C++ benchmark compares four implementations: FastHeapDict, std::priority_queue using duplicate entries, std::set using erase-and-reinsert updates as a tree-based decrease-key implementation [10], and std::multiset using duplicate entries [11]. These baselines distinguish two independent design choices: maintaining a single live entry versus allowing duplicate entries, and using a binary heap versus an ordered tree as the underlying priority-queue structure.
V. EXPERIMENTAL METHODOLOGY
A. System Configuration
All experiments were performed on the same hardware and software platform to ensure a consistent evaluation environment. The benchmark system ran Fedora 44 [14] on a 12th Generation Intel Core i7-12800H processor with 64 GB of RAM. The C++ implementation was compiled using GCC 16.1.1 with CMake 4.3.0 and the C++20 language standard [15]–[17]. The Python implementation was executed using Python 3.12 within a dedicated Conda environment [18], [19].
B. Timing Methodology
Both the Python and C++20 implementations follow the same timing methodology. The input edge list is converted into an adjacency-list representation before timing begins. The measured interval therefore includes only priority-queue initialization and execution of Dijkstra's algorithm, excluding graph construction and preprocessing overhead.
For the Python implementation, cyclic garbage collection is temporarily disabled [20] only during each timed execution and restored immediately afterward to reduce measurement variability. The execution order of competing methods is rotated across trials to minimize ordering effects, and all reported running times correspond to the median over repeated executions.
The C++ benchmark records both a CSV file containing per-trial timing measurements and a terminal-style log summarizing the execution of every benchmark.
C. Correctness Verification
All benchmark results were obtained only after passing a comprehensive collection of correctness tests.
The Python implementation first performs a direct hashing validation, followed by 100 randomized priority-queue operation sequences and 500 randomized positive-weight Dijkstra comparisons between the indexed and duplicate-entry implementations.
The C++20 implementation performs analogous correctness checks for FastHeapDict together with randomized graph validation. Every benchmark reported in this paper passed all self-tests before any performance measurements were collected.
D. Graph Families
The evaluation uses undirected graphs with positive edge weights generated deterministically after fixing the random seed.
Experiments 1–3 employ a controlled dense stress-graph construction designed to emphasize workloads with frequent priority updates. Vertex 0 serves as the source. A set of intermediate improver vertices repeatedly decreases the tentative distances of a collection of active sink vertices. The final target vertex is assigned a larger shortest-path distance than the remaining sinks, forcing duplicate-entry implementations to process many obsolete heap entries before termination. Additional high-weight filler edges are inserted until the desired
TABLE I PYTHON MEDIAN RUNNING TIME AS THE GRAPH SIZE INCREASES AT DENSITY RATIO 0.25.
| V | E | Density | FastHeapDict (s) | heapq dup. (s) | Speedup |
|---|---|---|---|---|---|
| 500 | 31,188 | 0.250 | 0.0110 | 0.0172 | 1.56x |
| 1,000 | 124,875 | 0.250 | 0.0508 | 0.0876 | 1.72x |
| 1,500 | 281,062 | 0.250 | 0.1231 | 0.2257 | 1.83x |
| 2,000 | 499,750 | 0.250 | 0.2195 | 0.4396 | 2.00x |
| 2,500 | 780,938 | 0.250 | 0.3538 | 0.7548 | 2.13x |
| 3,000 | 1,124,625 | 0.250 | 0.5146 | 1.1625 | 2.26x |
graph density is reached; these edges increase density without affecting the intended shortest-path structure.
Graph density is measured relative to the complete undirected graph,
where and denote the numbers of edges and vertices, respectively. For completeness, the experiments also report
allowing dense graphs to be described using the relation .
Experiment 1 varies the number of vertices while fixing the density ratio at . Experiment 2 fixes and varies graph density. Experiment 3 compares every runnable priority-queue implementation using and . Experiment 4 evaluates randomized dense stress graphs with and over multiple random seeds. In this randomized benchmark, the active sink set, the number of active sinks, sink ordering, base distances, and filler edges all vary between trials while preserving the decrease-key-intensive characteristics of the workload.
VI. PYTHON RESULTS
A. Scaling with the Number of Vertices
Table I summarizes the median running times obtained in Experiment 1, and Fig. 1 visualizes the corresponding runtime trend. The graph density ratio is fixed at , while the number of vertices increases from 500 to 3000. Across the entire range, FastHeapDict consistently outperforms the duplicate-entry heapq implementation. The observed speedup increases from for the smallest graph to for the largest, indicating that the performance advantage becomes more pronounced as the workload grows.
B. Changing Graph Density
Experiment 2 isolates the effect of graph density by fixing the number of vertices at and varying the density ratio from 0.03 to 1.0. Table II reports the corresponding median running times, and Fig. 2 shows the resulting speedup trend over the density sweep. FastHeapDict remains consistently faster than the duplicate-entry baseline across all tested densities. Measured speedups range from to ,

Fig. 1. Python Experiment 1: running time as the number of vertices increases while the density ratio is fixed at 0.25.
TABLE II
PYTHON MEDIAN RUNNING TIME AS GRAPH DENSITY VARIES AT V = 1500.
| Density | E | α | FastHeapDict (s) | heapq dup. (s) | Speedup |
|---|---|---|---|---|---|
| 1.000 | 1,124,250 | 0.4997 | 0.5250 | 0.8287 | 1.58x |
| 0.750 | 843,188 | 0.3748 | 0.3783 | 0.6880 | 1.82x |
| 0.500 | 562,125 | 0.2498 | 0.2544 | 0.5309 | 2.09x |
| 0.350 | 393,488 | 0.1749 | 0.1795 | 0.3509 | 1.96x |
| 0.250 | 281,062 | 0.1249 | 0.1283 | 0.2306 | 1.80x |
| 0.150 | 168,638 | 0.0750 | 0.0755 | 0.1272 | 1.69x |
| 0.100 | 112,425 | 0.0500 | 0.0491 | 0.0775 | 1.58x |
| 0.075 | 84,319 | 0.0375 | 0.0355 | 0.0544 | 1.53x |
| 0.050 | 56,212 | 0.0250 | 0.0232 | 0.0329 | 1.42x |
| 0.030 | 33,728 | 0.0150 | 0.0144 | 0.0178 | 1.23x |
with the largest speedup occurring at density ratio 0.50. As expected, the performance gap narrows for the sparsest graphs, where fewer repeated priority updates occur and duplicate entries accumulate less frequently.
C. Priority-Queue Comparison
Table III compares FastHeapDict with three widely used Python priority-queue implementations: duplicate-entry heapq, pqdict, and heapdict, while Fig. 3 visualizes the corresponding runtime comparison. FastHeapDict achieves the lowest running time among all evaluated methods. Although both pqdict and heapdict support indexed priority updates, their practical overhead differs substantially. On this workload, pqdict performs comparably to duplicate-entry heapq, whereas heapdict is noticeably slower.
D. Randomized Dense Stress Graphs
Experiment 4 evaluates five independently generated randomized dense stress graphs in order to verify that the observed behavior is not specific to a single deterministic construction. Table IV shows that FastHeapDict consistently outperforms duplicate-entry heapq for every random seed, and Fig. 4 visualizes the running times across the randomized graph instances. The measured speedups range from 1.80× to 2.29×. Throughout these experiments, FastHeapDict maintains exactly one live heap entry per vertex, whereas the

Fig. 2. Python Experiment 2: speedup of FastHeapDict relative to duplicate-entry heapq as graph density varies.
TABLE III
PYTHON PRIORITY-QUEUE COMPARISON FOR V = 1500 AND DENSITY RATIO 0.10.
| Method | Median (s) | Updates | Pops | Stale | Max |
|---|---|---|---|---|---|
| FastHeapDict | 0.0493 | 112,049 | 899 | 0 | 898 |
| pqdict | 0.0758 | 112,049 | 899 | 0 | 898 |
| heapq dup. | 0.0772 | 112,048 | 111,001 | 110,103 | 111,270 |
| heapdict | 0.3109 | 112,049 | 899 | 0 | 897 |

Fig. 3. Python Experiment 3: comparison of Python priority-queue implementations at V = 1500 and density ratio 0.10.
duplicate-entry implementation processes hundreds of thousands of stale removals before termination.
TABLE IV
PYTHON RANDOMIZED DENSE STRESS GRAPHS AT V = 1500 AND DENSITY RATIO 0.25.
| Seed | Active sinks | FastHeapDict (s) | heapq dup. (s) | Speedup |
|---|---|---|---|---|
| 11 | 310 | 0.1156 | 0.2302 | 1.99x |
| 22 | 271 | 0.1048 | 0.2022 | 1.93x |
| 33 | 251 | 0.1032 | 0.1862 | 1.80x |
| 44 | 372 | 0.1275 | 0.2915 | 2.29x |
| 55 | 293 | 0.1128 | 0.2177 | 1.93x |

Fig. 4. Python Experiment 4: running times on randomized dense stress graphs.
VII. C++20 RESULTS
A. Scaling with the Number of Vertices
Table V summarizes the median running times obtained in Experiment 1 for the C++20 implementation, and Fig. 5 visualizes the corresponding runtime trend. The graph density ratio is fixed at , while the number of vertices increases from 500 to 3000. FastHeapDict consistently outperforms the duplicate-entry std::priority_queue implementation across the entire range of graph sizes. The measured speedup is at least across all tested graph sizes and reaches for the largest graph, demonstrating that the practical advantage of the proposed design remains substantial as the workload increases.
TABLE V
C++20 MEDIAN RUNNING TIME AS THE GRAPH SIZE INCREASES AT DENSITY RATIO 0.25.
| V | E | Density | FastHeapDict (s) | std::pq dup. (s) | Speedup |
|---|---|---|---|---|---|
| 500 | 31,188 | 0.250 | 0.000778 | 0.008943 | 11.50x |
| 1,000 | 124,875 | 0.250 | 0.003122 | 0.041968 | 13.44x |
| 1,500 | 281,062 | 0.250 | 0.008582 | 0.103429 | 12.05x |
| 2,000 | 499,750 | 0.250 | 0.010428 | 0.106022 | 10.17x |
| 2,500 | 780,938 | 0.250 | 0.015138 | 0.176501 | 11.66x |
| 3,000 | 1,124,625 | 0.250 | 0.015592 | 0.270049 | 17.32x |
B. Changing Graph Density
Experiment 2 fixes the graph size at while varying the density ratio from 0.03 to 1.0. Table VI reports the corresponding median running times, and Fig. 6 shows

Fig. 5. C++20 Experiment 1: running time as the number of vertices increases while the density ratio is fixed at 0.25.
TABLE VI
C++20 MEDIAN RUNNING TIME AS GRAPH DENSITY VARIES AT .
| Density | E | FastHeapDict (s) | std::pq dup. (s) | Speedup | |
|---|---|---|---|---|---|
| 1.000 | 1,124,250 | 0.4997 | 0.008486 | 0.121276 | 14.29x |
| 0.750 | 843,188 | 0.3748 | 0.008039 | 0.125288 | 15.59x |
| 0.500 | 562,125 | 0.2498 | 0.006937 | 0.121001 | 17.44x |
| 0.350 | 393,488 | 0.1749 | 0.005080 | 0.079402 | 15.63x |
| 0.250 | 281,062 | 0.1249 | 0.004099 | 0.054588 | 13.32x |
| 0.150 | 168,638 | 0.0750 | 0.002380 | 0.031310 | 13.16x |
| 0.100 | 112,425 | 0.0500 | 0.001884 | 0.022632 | 12.01x |
| 0.075 | 84,319 | 0.0375 | 0.001447 | 0.015353 | 10.61x |
| 0.050 | 56,212 | 0.0250 | 0.000920 | 0.009725 | 10.57x |
| 0.030 | 33,728 | 0.0150 | 0.000585 | 0.005647 | 9.65x |
the resulting speedup trend over the density sweep. This density sweep follows the two-method design used in the corresponding Python experiment and compares FastHeapDict against the duplicate-entry std::priority_queue baseline. FastHeapDict remains consistently faster throughout the entire range of tested densities. Measured speedups vary from to , with the largest speedup occurring at density ratio 0.50. Unlike the Python implementation, where the performance gap narrows noticeably for sparse graphs, the C++ implementation maintains a substantial advantage even at the lowest tested density.
C. Priority-Queue Comparison
Table VII compares FastHeapDict with three commonly used C++ priority-queue implementations: duplicate-entry std::priority_queue, tree-based std::set with erase-and-reinsert updates, and duplicate-entry std::multiset; Fig. 7 visualizes the corresponding runtime comparison. FastHeapDict achieves the lowest running time among all evaluated methods. Although the std::set implementation maintains a single live entry for each vertex, its balanced-tree operations incur substantially larger constant factors than the binary-heap-based design. Both duplicate-entry baselines also perform a large number of stale removals, resulting in considerably larger queue sizes during execution.
TABLE VII C++20 PRIORITY-QUEUE COMPARISON FOR AND DENSITY RATIO 0.10.
| Method | Median (s) | Updates | Pops | Stale pops | Max heap |
|---|---|---|---|---|---|
| FastHeapDict | 0.001842 | 112,033 | 899 | 0 | 897 |
| std_set_decrease_key | 0.010513 | 112,033 | 899 | 0 | 897 |
| std_priority_queue_duplicates | 0.019360 | 112,032 | 111,001 | 110,103 | 111,243 |
| std_multiset_duplicates | 0.021280 | 112,032 | 111,001 | 110,103 | 111,243 |
TABLE VIII C++20 RANDOMIZED DENSE STRESS GRAPHS AT AND DENSITY RATIO 0.25.
| Seed | Active sinks | E | α | FastHeapDict (s) | std::pq dup. (s) | std::set (s) | std::multiset dup. (s) |
|---|---|---|---|---|---|---|---|
| 11 | 308 | 281,062 | 0.1249 | 0.003304 | 0.055201 | 0.057951 | 0.113341 |
| 22 | 270 | 281,062 | 0.1249 | 0.002832 | 0.049830 | 0.045843 | 0.095882 |
| 33 | 303 | 281,062 | 0.1249 | 0.003855 | 0.050241 | 0.051738 | 0.117295 |
| 44 | 265 | 281,062 | 0.1249 | 0.003021 | 0.042370 | 0.043169 | 0.097723 |
| 55 | 311 | 281,062 | 0.1249 | 0.003348 | 0.056428 | 0.058424 | 0.110485 |

Fig. 6. C++20 Experiment 2: speedup of FastHeapDict relative to duplicate-entry std::priority_queue as graph density varies.
D. Randomized Dense Stress Graphs
Experiment 4 evaluates five independently generated randomized dense stress graphs using the C++20 implementation. Table VIII reports all four C++ priority-queue methods for each seed, and Fig. 8 visualizes the running times across the randomized graph instances. FastHeapDict is the fastest method on every randomized graph. Relative to duplicate-entry std::priority_queue, the observed FastHeapDict speedups range from to . The std::set decrease-key implementation is close to the duplicate-entry heap baseline on these randomized graphs, while std::multiset is consistently slower. This comparison shows that the advantage is not only due to avoiding stale duplicate entries, but also to the lower constant-factor overhead of the vector-backed permanent-slot heap.

Fig. 7. C++20 Experiment 3: priority-queue comparison at and density ratio 0.10.

Fig. 8. C++20 Experiment 4: randomized dense stress-graph running times by method.
VIII. DISCUSSION
The experimental results consistently support the central design hypothesis underlying FastHeapDict. By maintaining exactly one live heap entry for each key and replacing repeated key-based position updates with permanent slot indexing, the proposed implementation reduces the practical overhead associated with decrease-key operations while preserving the asymptotic complexity of a conventional indexed binary heap.
The observed speedups therefore arise from reducing implementation overhead rather than from introducing a new heap algorithm or improving asymptotic complexity.
One observation common to both implementations is that the benefit of FastHeapDict increases as duplicate-entry overhead becomes more significant. In the constructed dense stress graphs, repeated edge relaxations generate large numbers of obsolete heap entries in duplicate-entry implementations. Every stale entry eventually requires an additional heap removal, increasing both the total number of heap operations and the effective queue size during execution. Because FastHeapDict updates priorities in place, this overhead is avoided entirely.
The magnitude of the improvement differs between Python and C++20. In Python, FastHeapDict consistently outperforms duplicate-entry heapq by approximately a factor of two on the evaluated workloads. This result is noteworthy because heapq is a mature and highly optimized standard-library implementation, while FastHeapDict is implemented entirely in pure Python. The C++20 implementation exhibits substantially larger speedups. In addition to outperforming duplicate-entry std::priority_queue, FastHeapDict also consistently exceeds the performance of the tree-based std::set implementation, indicating that an indexed binary heap with efficient position maintenance can provide lower practical overhead than balanced-tree alternatives for decrease-key-intensive workloads.
The randomized dense stress graphs strengthen this conclusion by demonstrating that the observed behavior is not tied to a single handcrafted graph instance. Although individual graph structures vary across random seeds, FastHeapDict consistently maintains its performance advantage. This suggests that the improvement arises from the underlying implementation strategy rather than from properties of one particular benchmark graph.
At the same time, the present results should be interpreted within the scope of the evaluated workloads. The benchmark families were intentionally designed to emphasize repeated priority updates in order to isolate the practical cost of duplicate-entry processing. Consequently, the reported speedups should not be interpreted as universal improvements for every graph or every application. Instead, they demonstrate that permanent slot indexing provides a practical implementation strategy for indexed priority queues whose benefits become increasingly apparent as decrease-key operations become more frequent.
IX. LIMITATIONS
The present study has several limitations that should be considered when interpreting the reported results.
First, the benchmark graphs are synthetic and were intentionally designed to emphasize workloads with frequent decrease-key operations. Although this construction provides a controlled setting for evaluating the proposed implementation, it does not capture the full diversity of real-world graph families such as road networks, social networks, communication graphs, or finite-element meshes.
Second, the experimental evaluation focuses on positive-weight single-source shortest-path computations using Dijkstra's algorithm. Other application domains, including multi-source shortest paths, all-pairs shortest paths, dynamic graphs, or algorithms such as Prim's minimum spanning tree algorithm and A* search, may exhibit different performance characteristics and warrant separate investigation.
Third, all experiments were performed on a single hardware and software platform. Although both the Python and C++20 implementations consistently demonstrate the same qualitative behavior, absolute running times and constant factors may vary across processors, compilers, optimization settings, memory allocators, and operating systems.
Finally, FastHeapDict does not alter the asymptotic complexity of indexed binary heaps. Its contribution is implementation-oriented rather than theoretical: by introducing permanent slot indexing, it reduces repeated key-based hash-table accesses during heap maintenance while preserving the standard time complexity of indexed binary heaps. Broader evaluation across additional graph families, algorithms, and computing environments will help further characterize the practical applicability of the proposed design.
X. CONCLUSION
This paper introduced FastHeapDict, an indexed binary heap based on the principle of permanent slot indexing. Rather than repeatedly updating heap positions through key-based hash-table operations during heap maintenance, FastHeapDict assigns each key a stable integer slot that is reused throughout its lifetime. This design preserves the standard asymptotic complexity of indexed binary heaps while reducing the practical overhead associated with frequent decrease-key operations.
The proposed design was evaluated through independent Python and C++20 implementations using Dijkstra's algorithm as the primary experimental workload. Across all evaluated benchmark families, including deterministic and randomized dense stress graphs, FastHeapDict consistently outperformed duplicate-entry priority queues. The Python implementation also exceeded the performance of existing indexed priority-queue libraries, while the C++20 implementation demonstrated substantial constant-factor improvements over both duplicate-entry and tree-based standard-library implementations.
The contribution of this work is implementation-oriented rather than theoretical. FastHeapDict does not introduce a new priority-queue complexity bound; instead, it demonstrates that careful engineering of indexed priority queues can produce substantial practical improvements while preserving the simplicity and theoretical guarantees of binary heaps. We hope that the proposed design will serve as a useful reference for future implementations of decrease-key-intensive graph algorithms and motivate further investigation of practical priority-queue engineering across a broader range of algorithms, workloads, and computing environments.
REPRODUCIBILITY NOTES
All benchmark artifacts required to reproduce the reported results are publicly available in the project's GitHub repository. These include the Python and C++20 implementations, benchmark scripts, CSV benchmark outputs, plotting scripts, and the generated figures used throughout the evaluation. The experimental hardware and software environment is described in Section V-A.
CODE AND REPRODUCIBILITY
The complete source code, benchmark scripts, raw experimental data, plotting utilities, generated figures, and detailed reproduction notes are publicly available in the project repository: https://github.com/hojjatgoudarzi/FastHeapDict. For convenient reuse, the Python implementation is additionally distributed through the Python Package Index and can be installed with pip install fastheapdict.
REFERENCES
[1] E. W. Dijkstra, "A note on two problems in connexion with graphs," Numerische Mathematik, vol. 1, pp. 269–271, 1959.
[2] Python Software Foundation, "heapq — heap queue algorithm," Python Standard Library Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://docs.python.org/3/library/heapq.html.
[3] cppreference.com, "std::priority_queue," C++ Reference Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://en.cppreference.com/w/cpp/container/priority_queue.
[4] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms, 3rd ed. MIT Press, 2009.
[5] J. W. J. Williams, "Algorithm 232: Heapsort," Communications of the ACM, vol. 7, no. 6, pp. 347–348, 1964.
[6] M. L. Fredman and R. E. Tarjan, "Fibonacci heaps and their uses in improved network optimization algorithms," Journal of the ACM, vol. 34, no. 3, pp. 596–615, 1987.
[7] M. L. Fredman, R. Sedgewick, D. D. Sleator, and R. E. Tarjan, "The pairing heap: A new form of self-adjusting heap," Algorithmica, vol. 1, pp. 111–129, 1986.
[8] N. Abdennur, "Priority queue dictionary," pqdict Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://pqdict.readthedocs.io/.
[9] D. Stutzbach, "heapdict: A heap with decrease-key and increase-key operations," GitHub Repository, 2026, accessed: 2026-06-30. [Online]. Available: https://github.com/DanielStutzbach/heapdict.
[10] cppreference.com, "std::set," C++ Reference Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://en.cppreference.com/w/cpp/container/set.
[11] —, "std::multiset," C++ Reference Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://en.cppreference.com/w/cpp/container/multiset.
[12] —, "std::unordered_map," C++ Reference Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://en.cppreference.com/w/cpp/container/unordered_map.
[13] —, "std::vector," C++ Reference Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://en.cppreference.com/w/cpp/container/vector.
[14] Fedora Project, "Fedora documentation," Fedora Docs, 2026, accessed: 2026-06-30. [Online]. Available: https://docs.fedoraproject.org/.
[15] Free Software Foundation, "GCC online documentation," GNU Compiler Collection Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://gcc.gnu.org/onlinedocs/.
[16] Kitware, Inc., "Cmake documentation," CMake Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://cmake.org/documentation/.
[17] International Organization for Standardization, "ISO/IEC 14882:2020: Programming languages — c++," International Standard, 2020.
[18] Python Software Foundation, "Python 3.12 documentation," Python Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://docs.python.org/3.12/.
[19] Anaconda, Inc., "Conda user guide," Conda Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://docs.conda.io/.
[20] Python Software Foundation, "gc — garbage collector interface," Python Standard Library Documentation, 2026, accessed: 2026-06-30. [Online]. Available: https://docs.python.org/3/library/gc.html.