hdag

Module for dealing with the Hierarchy Directed Acyclic Graph (HDAG) data object.

treesegmentation.hdag.calculate_depth(h1, h2, shared_patches)

Calculate node depth, level depth, and shared cell count for a pair of connected hierarchies.

Parameters
  • h1 – hierarchy

  • h2 – hierarchy

  • shared_patches – list of patch objects

Returns

depth statistics level_depth (float), node_depth(float), shared_cell_count (int)

treesegmentation.hdag.calculate_edge_weight(hierarchies, connected_hierarchies, weights)

Compute statistics for a pair of connected hierarchies and calculate the edge weight from those statistics. Give this weight to set_weight_and_orientation() to create a directed edge in the H-DAG. Return

Parameters
  • hierarchies – List of Hierarchy objects

  • connected_hierarchies – List of connected hierarchy pairs

  • weights – The constants to apply to each statistic for the final weight computation

Returns

Hdag Object (Hierarchy directed acyclic graph)

treesegmentation.hdag.find_connected_hierarchies(patch_dict)

From a dictionary of all patches, find unique hierarchies that share patches.

Parameters

patch_dict – dictionary of patch objects

Returns

a list of tuples of connected hierarchies.

treesegmentation.hdag.set_weight_and_orientation(h1, h2, weight, h1_cc, h2_cc, hdag)

Assign weight an orientation to hierarchy nodes in the directed graph (Hdag object).

Parameters
  • h1 – hierarchy

  • h2 – hierarchy

  • weight – float

  • h1_cc – int, the cell count of the hierarchy

  • h2_cc – int, the cell count of the hierarchy

  • hdag – the Hdag object to add edges to

Returns

None