broken sorting in nearest_neighbor_graph_ann.cpp
The two functions sortPtsX
and sortPtsY
in nearest_neighbor_graph_ann.cpp contain nested loops whose inner loop is useless. The loop counter is never used, so the body of the loop is a no-op after the first iteration.
It's not obvious to me what this code is attempting to accomplish. It uses the global dim
that is not declared const
but whose value is always 4
. However, the functions are called from nearest_neighbor_graph_ann
that takes a custom dim
value from its caller. It looks to me as if the bodies of the nested loops were coded to assume dim
is always 4
but also ignore their containing loop.
What is the right fix here? It looks like the functions to reach this are not in any shipped header and Graphviz itself only calls into this code with dim == 4
. So maybe we should just remove dim
as a parameter and remove the inner loops?