diff --git a/include/aidge/graph/Matching.hpp b/include/aidge/graph/Matching.hpp index 37bd4cf1b4f8ec20bdb6d42395b49fd69689f698..4d1a920f0fff542f88459bd0fa8db9415a73af32 100644 --- a/include/aidge/graph/Matching.hpp +++ b/include/aidge/graph/Matching.hpp @@ -197,12 +197,19 @@ private: struct CompareMatchingResultSize { bool operator()(const MatchingResult& lhs, const MatchingResult& rhs) const { + // Some matches size could be the same + if (lhs.graph->getNodes().size() == rhs.graph->getNodes().size()) { + // In this case, use rootNode which is garanteed to be different! + return lhs.graph->rootNode() < rhs.graph->rootNode(); + } + return lhs.graph->getNodes().size() > rhs.graph->getNodes().size(); } }; }; inline bool operator<(const Aidge::SinglePassGraphMatching::MatchingResult& lhs, const Aidge::SinglePassGraphMatching::MatchingResult& rhs) { + // Matches rootNode are garanteed to be different! return lhs.graph->rootNode() < rhs.graph->rootNode(); } } // namespace Aidge