I'm tryng to figure out how I can use heapify function in a list of tuples. i want it for djikstra algorithm so my list will look like this.
[(node,distance)(node2,distance2)....(node-n,distance-n]
I just wanna know how heapify can order my list just checking the distance and not the node in the tuple.
As I know, if i have a list'l' like:
[8,4,7,2]
and I use
heapify(l)
It will return:
[2,4,7,8]
So how I can use this function only ordering by distance?
Heapify will work with lists of tuples such that the first element of each tuple is the value, so use (distance, node) instead
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With