Formatting fixed based on Keir's comments and extended the tests
diff --git a/internal/ceres/graph_algorithms.h b/internal/ceres/graph_algorithms.h index e83531d..3b42d93 100644 --- a/internal/ceres/graph_algorithms.h +++ b/internal/ceres/graph_algorithms.h
@@ -50,9 +50,9 @@ bool operator()(const Vertex& lhs, const Vertex& rhs) const { if (graph_.Neighbors(lhs).size() == graph_.Neighbors(rhs).size()) { - return (lhs < rhs); + return lhs < rhs; } - return (graph_.Neighbors(lhs).size() < graph_.Neighbors(rhs).size()); + return graph_.Neighbors(lhs).size() < graph_.Neighbors(rhs).size(); } private:
diff --git a/internal/ceres/graph_algorithms_test.cc b/internal/ceres/graph_algorithms_test.cc index a67d7b7..d5d4843 100644 --- a/internal/ceres/graph_algorithms_test.cc +++ b/internal/ceres/graph_algorithms_test.cc
@@ -172,22 +172,29 @@ graph.AddVertex(2); graph.AddVertex(3); - // 0-1 2-3 - // All vertices have degree 1. + // 0-1 + // | + // 2-3 + // 0,1 and 2 have degree 1 and 3 has degree 2. graph.AddEdge(0, 1, 1.0); graph.AddEdge(2, 3, 1.0); VertexDegreeLessThan<int> less_than(graph); for (int i = 0; i < 4; ++i) { - EXPECT_FALSE(less_than(i,i)) - << "Failing vertex: " << i; + EXPECT_FALSE(less_than(i,i)) << "Failing vertex: " << i; for (int j = 0; j < 4; ++j) { if (i != j) { - EXPECT_TRUE(less_than(i,j) ^ less_than(j,i)) + EXPECT_TRUE(less_than(i, j) ^ less_than(j, i)) << "Failing vertex pair: " << i << " " << j; } } } + + for (int i = 0; i < 3; ++i) { + EXPECT_TRUE(less_than(i, 3)); + EXPECT_FALSE(less_than(3, i)); + } } + } // namespace internal } // namespace ceres