diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 2569b3d..c828f39 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1121,35 +1121,38 @@ namespace { [[maybe_unused]] void debugPrintDot(FILE *file, Node *node) { + constexpr int kSeparation = 2; + struct DebugDotPrinter { explicit DebugDotPrinter(FILE *file) : file(file) {} - void print(Node *n) { + void print(Node *n, int y = 0) { assert(n != nullptr); - auto partialKey = printable(Key{n->partialKey, n->partialKeyLen}); if (n->entryPresent) { fprintf(file, " k_%p [label=\"m=%" PRId64 " p=%" PRId64 " r=%" PRId64 - " %s\"];\n", + "\n%s\", pos=\"%d,%d!\"];\n", (void *)n, n->maxVersion, n->entry.pointVersion, - n->entry.rangeVersion, partialKey.c_str()); + n->entry.rangeVersion, getSearchPath(n).c_str(), x, y); } else { - fprintf(file, " k_%p [label=\"m=%" PRId64 " %s\"];\n", (void *)n, - n->maxVersion, partialKey.c_str()); + fprintf(file, " k_%p [label=\"m=%" PRId64 "\n%s\", pos=\"%d,%d!\"];\n", + (void *)n, n->maxVersion, getSearchPath(n).c_str(), x, y); } + x += kSeparation; for (int child = getChildGeq(n, 0); child >= 0; child = getChildGeq(n, child + 1)) { auto *c = getChildExists(n, child); - fprintf(file, " k_%p -> k_%p [label=\"x%02x\"];\n", (void *)n, - (void *)c, child); - print(c); + fprintf(file, " k_%p -> k_%p;\n", (void *)n, (void *)c); + print(c, y - kSeparation); } } + int x = 0; FILE *file; }; fprintf(file, "digraph ConflictSet {\n"); + fprintf(file, " node [shape = box];\n"); assert(node != nullptr); DebugDotPrinter printer{file}; printer.print(node);