PathTreeAnalytics class
- class pathtreelib.analytics.PathTreeAnalytics(root, skip_properties=False)
Bases:
PathTreeAn extension to PathTree with more analytics functions.
- Parameters:
root (str | Path | PathNode) –
skip_properties (bool) –
- get_k_largest_nodes(k, keep_ancestors=False)
Return the k nodes with larger size.
By default, the list contains the nodes that have the largest size but in case two nodes in the same lineage belong to the top-k list, the ancestor is removed from the list. Still, all the ancestors of each node can be easily computed.
Keeping only the last nodes in the hierarchy allows to go deeper in the tree and highlight the large nodes, ignoring (typically) less meaningfull ancestors.
- Parameters:
k (int) – the number of largest nodes requested.
keep_ancestors (bool) – if true, return exactly the k largest nodes, if
false –
nodes (return the k largest) –
for (taking at max one node) –
lineage. (each) –
- Returns:
The top-k largest nodes.
- Return type:
list[PathNode]