Skip to content

Commit 997f2ce

Browse files
committed
use list
1 parent 75752ea commit 997f2ce

File tree

1 file changed

+3
-3
lines changed
  • src/compas/datastructures/tree

1 file changed

+3
-3
lines changed

src/compas/datastructures/tree/tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,22 @@ def hierarchy(self, max_depth=None):
454454
455455
"""
456456

457-
hierarchy = {"string": ""}
457+
hierarchy = []
458458

459459
def traverse(node, hierarchy, prefix="", last=True, depth=0):
460460

461461
if max_depth is not None and depth > max_depth:
462462
return
463463

464464
connector = "└── " if last else "├── "
465-
hierarchy["string"] += "{}{}{}\n".format(prefix, connector, node)
465+
hierarchy.append("{}{}{}".format(prefix, connector, node))
466466
prefix += " " if last else "│ "
467467
for i, child in enumerate(node.children):
468468
traverse(child, hierarchy, prefix, i == len(node.children) - 1, depth + 1)
469469

470470
traverse(self.root, hierarchy)
471471

472-
return hierarchy["string"]
472+
return "\n".join(hierarchy)
473473

474474
def to_graph(self, key_mapper=None):
475475
"""Convert the tree to a graph.

0 commit comments

Comments
 (0)