Interface PostOrderDfsVisitor<T>

Type Parameters:
T - Resul of traversal

@Beta @PublicApi public interface PostOrderDfsVisitor<T>
Function passed for DFS post order traversal.

Instances of this interface can be passed to ClusteringUtils.traversePostOrderDFS(PostOrderDfsVisitor, IDBasedHierarchicClustering)

An instance of this interface represents the mutable state of a post order DFS tree traversal. visit(IDBasedHierarchicCluster, java.util.List, int) represents the visit of the clusters.

Traversal is done according the order in the structure. Each cluster is visited at most once. Visit invoked as soon as possible: either when all children visited or when children visit skip signalled.

Please note that this interface is marked with Beta annotation, so it can be subject of incompatible changes or removal in later releases.

See Also:
  • Method Details

    • skipChildTraversal

      boolean skipChildTraversal(IDBasedHierarchicCluster cluster, int depth)
      Decide if a cluster's children should be traversed.

      If a child traversal is skipped the actual cluster is immediately visited by invoking visit(IDBasedHierarchicCluster, java.util.List, int)

      Parameters:
      cluster - Cluster to visit
      depth - Visited node depth, distance from a root (0 for the root, 1 for its immediate children)
      Returns:
      true when the given cluster's children should not be traversed.
    • visit

      T visit(IDBasedHierarchicCluster cluster, List<T> childResults, int depth)
      Visit a cluster.
      Parameters:
      cluster - Cluster to visit
      childResults - Immutable list of the result of the children visits or null when children traversal is skipepd by true returned value from skipChildTraversal(IDBasedHierarchicCluster, int)
      depth - Visited node depth, distance from a root (0 for the root, 1 for its immediate children)
      Returns:
      Result (to pass to parent visit)