Make tree visualization more compact

This commit is contained in:
2024-01-19 17:31:15 -08:00
parent f76191cfca
commit 9774a8af2b

View File

@@ -676,6 +676,9 @@ void lastLeqMulti(Arena &arena, Node *root, std::span<Key> keys,
explicit DebugDotPrinter(FILE *file) : file(file) {} explicit DebugDotPrinter(FILE *file) : file(file) {}
void print(Node *node) { void print(Node *node) {
if (node->child[0] == nullptr && node->child[1] == nullptr) {
return;
}
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
if (node->child[i] != nullptr) { if (node->child[i] != nullptr) {
fprintf(file, " k_%.*s -> k_%.*s;\n", node->len, fprintf(file, " k_%.*s -> k_%.*s;\n", node->len,
@@ -702,11 +705,11 @@ void lastLeqMulti(Arena &arena, Node *root, std::span<Key> keys,
for (auto iter = extrema(node, false); iter != nullptr; for (auto iter = extrema(node, false); iter != nullptr;
iter = next(iter, true)) { iter = next(iter, true)) {
fprintf(file, fprintf(file,
" k_%.*s [label=\"k=\\\"%.*s\\\" " " k_%.*s [label=\"k=\\\"%.*s\\\"\\n"
#if SHOW_PRIORITY #if SHOW_PRIORITY
"p=%u " "p=%u\\n"
#endif #endif
"m=%d v=%d r=%d\"];\n", "m=%d\\nv=%d r=%d\"];\n",
iter->len, (const char *)(iter + 1), iter->len, iter->len, (const char *)(iter + 1), iter->len,
(const char *)(iter + 1), (const char *)(iter + 1),
#if SHOW_PRIORITY #if SHOW_PRIORITY