Interface HierarchicCluster<T>

Type Parameters:
T - Type of elements contained by the clusters
All Superinterfaces:
Cluster<T>
All Known Subinterfaces:
IDBasedHierarchicCluster

@Beta @PublicAPI public interface HierarchicCluster<T> extends Cluster<T>
Represents a group (cluster) of structures, possibly divided into further non overlapping clusters.

Further division is also possibly hierarchic. The further division is represented by the child clusters, returned by clusters().

Leaves (elements referenced by this cluster but not by others) are also directly available

The represented group is immutable, so List modification operators are not supported, they throw UnsupportedOperationException upon calling.

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

  • Method Details

    • clusters

      List<? extends HierarchicCluster<T>> clusters()
      Access further grouping of the represented elements.

      Note that a hierarchic cluster might represent structures without further divisions: it is valid to contain Cluster.members() but not contain clusters().

      Returns:
      List of child clusters. The returned list is empty when no child clusters contained.
    • leaves

      List<T> leaves()
      Access immediate leaves associated to this node.

      Leaves returned are part of members of this Cluster (returned by Cluster.members()) but not part of any of the child clusters (returned by clusters().

      Note that representant structure Cluster.representant() might be part of the leaves of this cluster or any of its child clusters leaves.

      Returns:
      List of leaves. The returned list is empty when no leaves associated (all represented nodes are further clustered).
    • depth

      int depth()
      Distance from the associated root.

      Note that interpretation is similar to D3's d3.hierarchy node.depth.

      Returns:
      Zero for a root node having no parent, otherwise depth() of parent plus one
    • height

      int height()
      Distance from the farthest leave.

      Note that interpretation is similar to D3's d3.hierarchy node.height for internal nodes.

      Returns:
      One for clusters having only immediate leaves() but no child clusters(), otherwise the maximum of the child clusters height() plus one.
    • immediateDescendantsCount

      int immediateDescendantsCount()
      Sum of child clusters count and leaves count.
      Returns:
      Sum of leaves and immediate children count
    • parent

      Optional<? extends HierarchicCluster<T>> parent()
      Get parent for non roots.
      Returns:
      Perent cluster for non root clusters.