You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a proposed feature by Fahri Basegmez. I want to know if any others require this feature. I have a better implementation of a node ordering based on data property which could be customized by uses a lot.
Quoting the email:
I am using your treelib library and like it a lot. When I print a tree using tree.show() >sometimes I would like to control the way nodes are ordered. To be able to do that I modified >the source in a few places as shown below.
In node.py
Line 46
def init(self, tag=None, identifier=None, expanded=True, data=None, rank=0):
added the following line to Node. init ()
self.rank = rank
In tree.py
Line 214
if key is None:
def key(node):
return node.rank
Line 366
def create_node(self, tag=None, identifier=None, parent=None, data=None, rank=0):
Line 371 (in create_node()
node = self.node_class(tag=tag, identifier=identifier, data=data, rank=rank)
If a user never defines a rank then tree.show() behaves like it currently does. By adding ranks >to the desired nodes, print order of the nodes can be manipulated.
If you think this could be a useful modification please don't hesitate to use these changes.
Best regards,
Fahri Basegmez
P.S. print_rank or display_rank may be a better name than rank? Feel free to use whatever you >like.
In addition to these, a "use_rank = T/F" argument can be added to tree.show method.
The text was updated successfully, but these errors were encountered:
I feel this would be a good feature addition ,since i was also looking for a similar use case in which the nodes should be shown in the creation order rather than alphabeticaly.
This is a proposed feature by Fahri Basegmez. I want to know if any others require this feature. I have a better implementation of a node ordering based on
data
property which could be customized by uses a lot.Quoting the email:
The text was updated successfully, but these errors were encountered: