MCPcopy Create free account
hub / github.com/InternScience/InternAgent / dfs_print

Function dfs_print

visualize_mcts.py:160–178  ·  view source on GitHub ↗
(node_id: str, prefix: str, is_last: bool, depth: int)

Source from the content-addressed store, hash-verified

158 print("="*80 + "\n")
159
160 def dfs_print(node_id: str, prefix: str, is_last: bool, depth: int):
161 if depth > max_depth:
162 return
163
164 node = nodes[node_id]
165
166 # 打印当前节点
167 current_prefix = "└── " if is_last else "├── "
168 print(prefix + current_prefix + str(node))
169
170 # 更新前缀
171 extension = " " if is_last else "│ "
172 new_prefix = prefix + extension
173
174 # 递归打印子节点
175 children = node.children_ids
176 for i, child_id in enumerate(children):
177 is_last_child = (i == len(children) - 1)
178 dfs_print(child_id, new_prefix, is_last_child, depth + 1)
179
180 # 打印根节点
181 dfs_print(root_id, "", True, 0)

Callers 1

print_tree_asciiFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected