Hi All,
Can anybody help me to make j2ME implementation of Dijkstra algorithm faster ? I have two loops, one inside another. Like this
while(for each item in Q)
{
//...do something.
//the following loop is to find the minimum
for(all un-visited nodes in Q)
{
//.. do something to get min.
}
}
I have almost 23000 nodes and 50000 edges connecting them...The inner loop executes an average of 169330131 times after all improvements mentioned below. This takes 5 minutes to complete on my w910i mobile and more than minutes on my emulator. This looks too much for me. Any suggestions for improvement? I have the following improvements already implemented.
- Using array instead of vector.
- Make sure that the inner loop does not consider the visited nodes. All my visited nodes are at the end of the array and I node know the count. So, I can easily skip them altogether.
Thanks in advance
D M