Hi all.
I'm writing an application that uses Dijkstra algorithm to find minimal paths in the graph. The weights of the nodes and edges in the graph are float
numbers, so the algorithm doing many arithmetics on float numbers. Could I gain a running time improve if I convert all weight to int
s? Is int arithmetic operations are faster in Java then float ones?
I tried to write a simple benchmark to check that out, but I'm not satisfied with the results I got. Possibly the compiler has optimized some parts of the program so the results doesn't looks good for me.
EDIT:
The problem I'm trying to solve is in the Information Retrieval field. The application should show answers to a query posed as a set of keywords.
My data structure is a weighted directed graph. Given a set of leaf nodes I have to find a smallest tree that connects these nodes and show the answer to the user. The weights are assigned by a weighting function based partially on the tf/idf technique. The user don't know what weights I assign to the nodes and edges he just wants to see answers relevant to the query he posed. So exact results are not required, just a possibility to enumerate answers according to theirs weights. Just the native use of weighting function (as I mentioned it is based on tf/idf) gives float weights so I used floats so far.
I hope this adds some background to the question.