@@ -79,14 +79,14 @@ <h2 class="section-title" id="header-functions">Functions</h2>
7979< div class ="desc "> < p > Calculates the depth (height) of a binary tree.</ p > </ div >
8080</ dd >
8181< dt id ="printBin.mapNodesToCodes "> < code class ="name flex ">
82- < span > def < span class ="ident "> mapNodesToCodes</ span > </ span > (< span > node: < a title =" printBin.BinaryNode " href =" #printBin.BinaryNode " > BinaryNode </ a > , < br > valueFillChar,< br > unitSize,< br > code='',< br > memo=None)</ span >
82+ < span > def < span class ="ident "> mapNodesToCodes</ span > </ span > (< span > node, valueFillChar, unitSize, code='', memo=None)</ span >
8383</ code > </ dt >
8484< dd >
8585< details class ="source ">
8686< summary >
8787< span > Expand source code</ span >
8888</ summary >
89- < pre > < code class ="python "> def mapNodesToCodes(node: BinaryNode , valueFillChar, unitSize, code="", memo=None):
89+ < pre > < code class ="python "> def mapNodesToCodes(node, valueFillChar, unitSize, code="", memo=None):
9090 """
9191 Recursively maps all nodes to their binary path codes.
9292
@@ -239,14 +239,14 @@ <h2 id="args">Args</h2>
239239</ dl > </ div >
240240</ dd >
241241< dt id ="printBin.nodeToString "> < code class ="name flex ">
242- < span > def < span class ="ident "> nodeToString</ span > </ span > (< span > node: < a title ="printBin.BinaryNode " href ="#printBin.BinaryNode "> BinaryNode</ a > ,< br > depth=-1,< br > valueFillChar=None,< br > connectorFillChar=None,< br > unitSize=None,< br > removeEmpty=True)</ span >
242+ < span > def < span class ="ident "> nodeToString</ span > </ span > (< span > node: < a title ="printBin.BinaryNode " href ="#printBin.BinaryNode "> BinaryNode</ a > ,< br > depth=-1,< br > valueFillChar=None,< br > connectorFillChar=None,< br > unitSize=None,< br > removeEmpty=True, < br > showConnectors=True )</ span >
243243</ code > </ dt >
244244< dd >
245245< details class ="source ">
246246< summary >
247247< span > Expand source code</ span >
248248</ summary >
249- < pre > < code class ="python "> def nodeToString(node: BinaryNode, depth=-1, valueFillChar=None, connectorFillChar=None, unitSize=None, removeEmpty=True):
249+ < pre > < code class ="python "> def nodeToString(node: BinaryNode, depth=-1, valueFillChar=None, connectorFillChar=None, unitSize=None, removeEmpty=True, showConnectors=True ):
250250 """
251251 Converts a binary tree into a string representation for visualization.
252252
@@ -257,10 +257,16 @@ <h2 id="args">Args</h2>
257257 connectorFillChar: Character for filling horizontal gaps between node pairs
258258 unitSize: Size for centering values
259259 removeEmpty: Whether to remove empty leading columns
260+ showConnectors: Whether to show connector lines (/ and \) between nodes
260261 """
261262 mat = nodeToMat(node, depth=depth, valueFillChar=valueFillChar,
262263 connectorFillChar=connectorFillChar, unitSize=unitSize, removeEmpty=removeEmpty)
263- return "\n".join("".join(row) for row in mat)</ code > </ pre >
264+
265+ if showConnectors:
266+ return "\n".join("".join(row) for row in mat)
267+ else:
268+ # Only include even rows (node values, skip odd rows with connectors)
269+ return "\n".join("".join(mat[i]) for i in range(0, len(mat), 2))</ code > </ pre >
264270</ details >
265271< div class ="desc "> < p > Converts a binary tree into a string representation for visualization.</ p >
266272< h2 id ="args "> Args</ h2 >
@@ -277,6 +283,8 @@ <h2 id="args">Args</h2>
277283< dd > Size for centering values</ dd >
278284< dt > < strong > < code > removeEmpty</ code > </ strong > </ dt >
279285< dd > Whether to remove empty leading columns</ dd >
286+ < dt > < strong > < code > showConnectors</ code > </ strong > </ dt >
287+ < dd > Whether to show connector lines (/ and ) between nodes</ dd >
280288</ dl > </ div >
281289</ dd >
282290</ dl >
0 commit comments