derive_path_labels

derive_path_labels(dag, split_keywords, n_clusters, *, top_k=3)

Derive deterministic path labels for each cluster from the DAG.

Parameters

dag : CategoryGraph DAG from build_cluster_tree_dag(). split_keywords : dict Output of compute_split_keywords(). n_clusters : int Cluster resolution (e.g. 25). top_k : int Number of keywords per path step.

Returns

dict[int, str] {cluster_id: "keyword1, keyword2 / keyword3, keyword4"}. Single path → "cardiac / pacemaker". Straddling → "cardiac / {pacemaker, defibrillator}".