[Olsr-dev] Improving SPF with binary heaps
Sun Jul 12 03:48:56 CEST 2015
On 11 July 2015 at 03:34, Henning Rogge <(spam-protected)> wrote:
> On Sat, Jul 11, 2015 at 12:43 AM, Saulo Queiroz <(spam-protected)>
> > Hi Henning,
> > I've supervised the work of Diogo.
> > Regarding you first question, response is no. Not all procedures are
> > Diogo just listed in .h all classical procedures of a binary heap but
> > the ones required by Dijkstra are implemented. The other are there just
> > as a reminder, but he can clean .h, No problem.
> I would suggest moving everything that is "internal" to a static
> function... this makes it easier for new users of the API to
> understand what they need because they only have to look at the header
> > Regarding the second question: heap_extract_min is the procedure you
> > about.
> > Note however that the idea is to replace AVL only for Dijkstra and
> > AVL there for other stuff. ok?
> I would like to have this as a generic API, so I am looking which
> basic functions we have, we still need or we cannot get.
> Basics for both lists and AVL trees in OONF (which is the base of OLSRv2)
> - init
> - insert
> - remove
> - get(key)
> - get_first
> - get_last
> and a good way to iterate over the elements of the tree/list (which
> would enable me to write iterator macros like the ones in
> Can we have the same functions for a binary heap?
It is possible but i think few procedures don't sound reasonable because
are Priority Queues (PQs) by nature being different from the typical data
In general, one employs priority queues when all items are expected to
leave the structure until the end of the execution of a procedure (what is
very usual in the so-called "greedy algorithms" like Dijkstra). In "normal"
data structures, there is no problem if an item stay in the structure
"forever". In PQs the earlier an item leaves the structure, the better (to
it) because this means it will be served first (in case of Dijkstra this
means the shortest path computation ends for the extracted item).
In this context, functions like get(key) doesn't sound important because
focus goes to the priority assigned to the items not to the key values.
Perhaps we should start discussing an API for PQs since other can be
implemented like Fibonacci, Binomial, etc.
If yes, it makes sense to disallow AVL trees with overlapping keys
> (which is a parameter in avl_init at the moment) and tell the
> developers "use a binary heap instead for this case".
Wherever AVL has been used as a priority queue (as I just explained) it can
be replaced by binary heaps. Other scenarios need to be analyzed.
> The heap (because its different than AVL) might of course have a few
> more functions, like the "modify key later" functions you have. Its
> just about the same "basic set".
Saulo Jorge bq
"In theory, there is no difference between practice and theory, in practice
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Olsr-dev