Skip to content

Commit 4577f96

Browse files
committed
Fix duplicate vertex-vertex constraints
1 parent 4fe8a38 commit 4577f96

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/ipc/candidates/vertex_vertex.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ MatrixMax12d VertexVertexCandidate::compute_distance_hessian(
3838

3939
bool VertexVertexCandidate::operator==(const VertexVertexCandidate& other) const
4040
{
41-
return vertex0_id == other.vertex0_id && vertex1_id == other.vertex1_id;
41+
// (i, j) == (i, j) || (i, j) == (j, i)
42+
return (this->vertex0_id == other.vertex0_id
43+
&& this->vertex1_id == other.vertex1_id)
44+
|| (this->vertex0_id == other.vertex1_id
45+
&& this->vertex1_id == other.vertex0_id);
4246
}
4347

4448
bool VertexVertexCandidate::operator!=(const VertexVertexCandidate& other) const
@@ -48,10 +52,13 @@ bool VertexVertexCandidate::operator!=(const VertexVertexCandidate& other) const
4852

4953
bool VertexVertexCandidate::operator<(const VertexVertexCandidate& other) const
5054
{
51-
if (vertex0_id == other.vertex0_id) {
52-
return vertex1_id < other.vertex1_id;
55+
long this_min = std::min(this->vertex0_id, this->vertex1_id);
56+
long other_min = std::min(other.vertex0_id, other.vertex1_id);
57+
if (this_min == other_min) {
58+
return std::max(this->vertex0_id, this->vertex1_id)
59+
< std::max(other.vertex0_id, other.vertex1_id);
5360
}
54-
return vertex0_id < other.vertex0_id;
61+
return this_min < other_min;
5562
}
5663

5764
} // namespace ipc

0 commit comments

Comments
 (0)