From eab4f1cbfb7f17975a6a7c82156737a44ec9e4d3 Mon Sep 17 00:00:00 2001 From: Aneesh Durg Date: Mon, 9 Sep 2024 09:46:48 -0500 Subject: [PATCH] Use std::lower_bound to search for edge --- .../analytics/distributed/triangle-counting/tc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lonestar/analytics/distributed/triangle-counting/tc.cpp b/lonestar/analytics/distributed/triangle-counting/tc.cpp index 3ed08c52b4..debbd2ddcb 100644 --- a/lonestar/analytics/distributed/triangle-counting/tc.cpp +++ b/lonestar/analytics/distributed/triangle-counting/tc.cpp @@ -107,11 +107,11 @@ struct TC { Graph::edge_iterator vIterEnd = graph->edge_end(v); for (auto wIter : graph->edges(w)) { - auto x = graph->getEdgeDst(wIter); - Graph::edge_iterator vvIter = vIterBeg; - while (graph->getEdgeDst(vvIter) < x && vvIter < vIterEnd) { - vvIter++; - } + auto x = graph->getEdgeDst(wIter); + auto vvIter = std::lower_bound(vIterBeg, vIterEnd, x, + [&](Graph::edge_iterator it, GNode x) { + return graph->getEdgeDst(it) < x; + }); if (vvIter < vIterEnd && x == graph->getEdgeDst(vvIter)) { ++numTriangles_local; }