Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Monotone priority queue useful for shortest paths and more; wraps Rust's radix-heap crate
This module provides a Python implementation of Radix Heap-like data structures, designed to function as monotone priority queues. The heavy-lifting for the heap operations is powered by the radix-heap
Rust crate from mpdn -- they did 99% of the hard work by implementing the data structure.
Monotone priority queues are useful for pathfinding in general (e.g., A*, Dijkstra's algorithm). A monotone priority queue must maintain the invariant where the extracted elements form a monotone sequence (e.g., for a max-heap, the extracted elements are in non-increasing order).
A Radix Heap is a type of priority queue where the extracted elements form a monotone sequence. This module includes implementations for both maximum and minimum heaps for integer and float keys.
RadixHeapLike[K, V]
: A generic base class for Radix Heap-like structures.RadixMaxHeapInt[V]
: A radix max heap for integers.RadixMinHeapInt[V]
: A radix min heap for integers.RadixMaxHeap[V]
: A radix max heap for floats (or integers).RadixMinHeap[V]
: A radix min heap for floats (or integers).push(key: K, value: V) -> None
: Adds a key-value pair to the heap.pop() -> V
: Removes and returns the minimum value from the heap.pop_with_key() -> tuple[K, V]
: Removes and returns the minimum key-value pair from the heap.top() -> V | None
: Returns the minimum value from the heap without removing it.clear() -> None
: Removes all elements from the heap.__len__() -> int
: Returns the number of elements in the heap.from radix_heap import RadixMaxHeapInt
heap = RadixMaxHeapInt()
heap.push(10, "A")
heap.push(5, "B")
heap.push(8, "C")
while heap:
print(heap.pop())
# Output: "A", "C", "B"
To install the module, you can use pip:
pip install radix-heap
Contributions are welcome! Please check the repository and feel free to open issues or submit pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.
FAQs
Monotone priority queue useful for shortest paths and more; wraps Rust's radix-heap crate
We found that radix-heap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.