PathTreeAnalytics class

class pathtreelib.analytics.PathTreeAnalytics(root, skip_properties=False)

Bases: PathTree

An 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]

get_large_nodes(limit)

Return the list of nodes larger than the passed limit.

Parameters:

limit (int) – the limit size, nodes with larger size will be included.

Returns:

The nodes with size larger than the passed limit.

Return type:

list[PathNode]