/*----------------------------------------------------------------------------*/ void _printTree(struct AVLNode *cur, printer printVal) { if (cur == 0) return; printf("("); _printTree(cur->left, printVal); /* Note that you must change this to work for your particular 'data' pointer */ (*printVal)(cur->val);printf("[%d]",cur->hght); _printTree(cur->rght, printVal); printf(")"); }
static void _printTree(tnode *tree, unsigned int layer) { if (NULL == tree) return; _printBranch(layer); printf("%-4d\n", tree->value); _printTree(tree->pstLeft, layer+1); if (NULL == tree->pstLeft && NULL != tree->pstRight) { _printBranch(layer+1); printf("\n"); } _printTree(tree->pstRight, layer+1); }
void _printTree(searchNode* node, int depth, int maxDepth) { if (depth <= maxDepth) { std::ostringstream output; output << std::left; output << std::setw(6) << node->getNodeCount(); if (depth == 0) output << "start "; else if ((depth % 2) == 0) output << "black "; else output << "white "; output << std::setw(7) << depth; std::string heuristicOutput; heuristicOutput += std::to_string(node->getHeuristic()); if (node->hasCutoff()) heuristicOutput += " -cutoff-"; output << std::setw(12) << heuristicOutput << "|"; std::string moveText; for (int indent = 0; indent < depth; ++indent) { moveText += " "; } moveText += node->getMoveName(); output << std::setw(20) << moveText; output << node->prettyPrintBoard() << "\n"; std::cout << output.str(); for (int i = 0; i < node->numChildren(); ++i) { _printTree(node->getChild(i), depth+1, maxDepth); } } }
void printTree(searchNode* head, int m, int n) { searchNode* cursor = head; std::cout << "Total Moves In Search Tree: " << nodeCounter + 1 << "\n"; std::cout << "\nindex player depth heuristic move board\n"; std::cout << "----------------------------------------------------------\n"; if (m > 0) cursor = _traverseBest(cursor,0,m); _printTree(cursor,m,n); }
void printTree(struct AVLTree *tree, printer printVal){ _printTree(tree->root, printVal); }
/** * 先根遍历,直观打印 */ void printTree(tnode *tree) { _printTree(tree, 0); }