Skip to content

Commit 9e29216

Browse files
author
Ben Vandervalk
committed
ExtendPath.h: add documentation to tricky trueBranch method
1 parent 20d9f3d commit 9e29216

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

Graph/ExtendPath.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,14 @@ static inline bool lookAhead(
160160
}
161161

162162
/**
163-
* Return true if the given edge represents the start of a "true branch".
164-
* Roughly speaking, a path is a true branch if it has length >= trim
165-
* or terminates in a branching node, where a branching node is (recursively)
166-
* defined to be a node with either >= 2 incoming true branches or >= outgoing
167-
* true branches.
163+
* Return true if the given edge represents the beginning of a "true branch".
164+
*
165+
* A path is a true branch if it has length >= `trim` or terminates in a
166+
* branching node, where a branching node is (recursively) defined to be
167+
* a node with either >= 2 incoming true branches or >= 2 outgoing true branches.
168+
*
169+
* This method is similar to `lookAhead`, but it additionally changes traversal
170+
* direction when a dead-end is encountered.
168171
*/
169172
template <class Graph>
170173
static inline bool trueBranch(
@@ -195,6 +198,12 @@ static inline bool trueBranch(
195198
if (trueBranch(*oei, depth+1, FORWARD, g, trim, fpTrim, visited))
196199
return true;
197200
}
201+
/*
202+
* Note: The test for depth/lookAhead >= fpTrim before changing
203+
* traversal direction is needed to deal with an X-shaped
204+
* graph pattern that is frequently created by Bloom false positives.
205+
* See the test for `trueBranch` in `ExtendPathTest.h` for an example.
206+
*/
198207
if (depth >= fpTrim || lookAhead(v, FORWARD, fpTrim, g)) {
199208
for (boost::tie(iei, iei_end) = in_edges(v, g);
200209
iei != iei_end; ++iei) {
@@ -211,6 +220,12 @@ static inline bool trueBranch(
211220
if (trueBranch(*iei, depth+1, REVERSE, g, trim, fpTrim, visited))
212221
return true;
213222
}
223+
/*
224+
* Note: The test for depth/lookAhead >= fpTrim before changing
225+
* traversal direction is needed to deal with an X-shaped
226+
* graph pattern that is frequently created by Bloom false positives.
227+
* See the test for `trueBranch` in `ExtendPathTest.h` for an example.
228+
*/
214229
if (depth >= fpTrim || lookAhead(v, REVERSE, fpTrim, g)) {
215230
for (boost::tie(oei, oei_end) = out_edges(v, g);
216231
oei != oei_end; ++oei) {

0 commit comments

Comments
 (0)