smx.graph.centrality#
LRC (Local Reaching Centrality) computation and cross-seed aggregation.
Functions#
|
Compute Local Reaching Centrality (LRC) for every node of graph. |
|
Aggregate per-seed LRC DataFrames into a mean-aggregated ranking. |
Module Contents#
- smx.graph.centrality.compute_lrc(graph: networkx.DiGraph, predicates_df: pandas.DataFrame) pandas.DataFrame[source]#
Compute Local Reaching Centrality (LRC) for every node of graph.
LRC measures how well a node can reach other nodes in the graph, weighted by edge weights. Higher LRC → more central / important.
Parameters#
- graphnx.DiGraph
Directed predicate graph (e.g., from
smx.graph.builder.PredicateGraphBuilder).- predicates_dfpd.DataFrame
Predicate catalogue with columns
'rule','zone','thresholds','operator'.
Returns#
- pd.DataFrame
Columns:
Node,Local_Reaching_Centrality,Zone,Threshold,Operator. Sorted descending by LRC.
- smx.graph.centrality.aggregate_lrc_across_seeds(lrc_by_seed: Dict[int, pandas.DataFrame], random_seeds: List[int]) Tuple[pandas.DataFrame, pandas.DataFrame][source]#
Aggregate per-seed LRC DataFrames into a mean-aggregated ranking.
Parameters#
- lrc_by_seeddict
{seed: lrc_df}where each lrc_df is returned bycompute_lrc()(must have column'Node'plus'Local_Reaching_Centrality','Zone','Threshold','Operator').- random_seedslist of int
Seeds to include in the aggregation (keys of lrc_by_seed).
Returns#
- lrc_summed_dfpd.DataFrame
Mean-aggregated LRC for all predicates, sorted descending.
- lrc_summed_unique_dfpd.DataFrame
Zone-deduplicated version of lrc_summed_df (one row per zone), keeping the highest-ranked predicate per zone.