Skip to content

Commit e86369b

Browse files
committed
Fix indexing error.
1 parent dfc75e8 commit e86369b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

polygon_coverage_solvers/include/polygon_coverage_solvers/impl/graph_base_impl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ Solution GraphBase<NodeProperty, EdgeProperty>::reconstructSolution(
324324
template <class NodeProperty, class EdgeProperty>
325325
std::vector<std::vector<int>>
326326
GraphBase<NodeProperty, EdgeProperty>::getAdjacencyMatrix() const {
327+
ROS_DEBUG("Create adjacency matrix.");
327328
// First scale the matrix such that when converting the cost to integers two
328329
// costs can always be differentiated (except for if they are the same). Find
329330
// the minimum absolute difference between any two values to normalize the
@@ -341,10 +342,10 @@ GraphBase<NodeProperty, EdgeProperty>::getAdjacencyMatrix() const {
341342
}
342343
}
343344
sort(sorted_cost.begin(), sorted_cost.end());
344-
auto min_diff = std::numeric_limits<double>::max();
345-
for (size_t i = 0; i < sorted_cost.size() - 2; i++) {
345+
const double equality = 0.000001; // Min. considered cost difference.
346+
auto min_diff = sorted_cost.back();
347+
for (size_t i = 0; i < sorted_cost.size() - 1; i++) {
346348
auto diff = std::fabs(sorted_cost[i + 1] - sorted_cost[i]);
347-
const double equality = 0.000001; // Min. considered cost difference.
348349
if (diff > equality && diff < min_diff)
349350
min_diff = diff;
350351
}

0 commit comments

Comments
 (0)