@@ -84,6 +84,9 @@ def build_graph(fragments: list[Fragment], repo_root: Path | None = None) -> Gra
8484_SUPPRESSION_EXEMPT = frozenset ({"semantic" , "structural" , "test_edge" })
8585
8686
87+ _HUB_OUT_DEGREE_THRESHOLD = 3
88+
89+
8790def _apply_hub_suppression (
8891 edges : dict [tuple [FragmentId , FragmentId ], float ],
8992 edge_categories : dict [tuple [FragmentId , FragmentId ], str ],
@@ -110,4 +113,14 @@ def _apply_hub_suppression(
110113 weight = weight / max (1.0 , math .log (1 + deg ))
111114 suppressed [(src , dst )] = weight
112115
116+ sem_out_degree : dict [FragmentId , int ] = {}
117+ for (src , _dst ), cat in edge_categories .items ():
118+ if cat == "semantic" :
119+ sem_out_degree [src ] = sem_out_degree .get (src , 0 ) + 1
120+
121+ for src , dst in list (suppressed .keys ()):
122+ out_deg = sem_out_degree .get (src , 0 )
123+ if out_deg >= _HUB_OUT_DEGREE_THRESHOLD and edge_categories .get ((src , dst )) == "semantic" :
124+ suppressed [(src , dst )] = suppressed [(src , dst )] / math .sqrt (out_deg )
125+
113126 return suppressed
0 commit comments