Skip to content

Commit

Permalink
count dupes in cycle finder
Browse files Browse the repository at this point in the history
  • Loading branch information
tromp committed Feb 16, 2020
1 parent 1529cc1 commit 1607877
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cuckaroom/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class graph {
}
}

void add_edge(word_t from, word_t to) {
bool add_edge(word_t from, word_t to) {
assert(from < MAXNODES);
assert(to < MAXNODES);
if (from == to || adjlist[to] != NIL) { // possibly part of a cycle
Expand All @@ -119,11 +119,16 @@ class graph {
word_t link = nlinks++;
assert(link != NIL); // avoid confusing links with NIL; guaranteed if bits in word_t > EDGEBITS + 1
assert(link < MAXEDGES);
#ifndef ALLOWDUPES
for (word_t au = adjlist[from]; au != NIL; au = links[au].next)
if (links[au].to == to) return false; // drop duplicate edge
#endif
links[link].next = adjlist[from];
links[adjlist[from] = link].to = to;
return true;
}

void add_compress_edge(word_t from, word_t to) {
add_edge(compress->compress(from), compress->compress(to));
bool add_compress_edge(word_t from, word_t to) {
return add_edge(compress->compress(from), compress->compress(to));
}
};

0 comments on commit 1607877

Please sign in to comment.