I want to accelerate my algorithm using long long
instead of double
data type. My algorithm is to find the shortest path in a directed acyclic graph (DAG)
. Simply, it adds the weight of an edge "E: a->b" to b
, and if the new weight of b
is lower than the previous one, it is updated along with its parent which is set to a.
I mean, my algorithm is simply some addition and comparison operations. The weight of edges are originally of "double"
, is it possible for me to multiply them to a large number and cast them to "long long"
. If this tweak makes my program faster and worth considering. How can I handle instability problems due to rounding big double
to long long
.
Thanks