pykonal.heapq.Heap

class pykonal.heapq.Heap

Binary Min-Heap structure for storing indices sorted by auxiliary values.

pop(self)

Pop the index of the item with the smallest sort value from the heap, maintaining the heap invariant.

Returns

Index of node on the heap with smallest sort value.

Return type

tuple(int, int, int)

push(self, i1, i2, i3)

Push index onto the heap, maintaining the heap invariant.

Parameters
  • i1 (int) – First component of index.

  • i2 (int) – Second component of index.

  • i3 (int) – Third component of index.

Returns

True upon successful completion.

Return type

bool

Todo

Check that index is in range.

sift_down(self, j_start, j)

Sift the heap element at j down the heap (towards the root), without going past j_start, until finding a place that it fits.

Parameters
  • j_start (int) – Heap index creating a barrier beyond which heap element j cannot be sifted.

  • j (int) – Heap index of element to sift towards root.

Returns

Returns True upon successful execution.

Return type

bool

sift_up(self, j_start)

Sift the heap element at j_start up the heap (away from the root), until finding a place that it fits.

Parameters

j_start (int) – Heap index of element to sift away from root.

Returns

Returns True upon successful execution.

Return type

bool

heap_index

[Read only, numpy.ndarray(shape=(N0,N1,N2), dtype=numpy.int)] Array of indices indicating the heap position of each node. Index -1 indicates that a node is not on the heap.

keys

[Read only, list] Sorted list of node indices currently on the heap.

size

[Read only, int] Number of node indices on the heap.

values

[Read/Write, numpy.ndarray(shape=(N0,N1,N2), dtype=numpy.float)] Auxiliary values to sort by.