cdlib.lifecycles.flow_null¶
- cdlib.lifecycles.flow_null(lc: object, target: str, direction: str, min_branch_size: int = 1, iterations: int = 1000) dict¶
Compare the flow with a null model. Each branch of each flow is compared with a null branch of the same size. The null model is generated by randomly sampling elements from the reference partition iterations times. The mean and standard deviation of the null model are used to compute a z-score for each branch, which is then used to compute a p-value.
- Parameters:
lc – a CommunityMatching object
target – target set identifier
direction – temporal direction
min_branch_size – minimum size of a branch to be considered
iterations – number of random draws to be used to generate the null model
- Returns:
a dictionary keyed by set identifier and valued by mean, std, and p-value
- Example:
>>> from cdlib import TemporalClustering, LifeCycle >>> from cdlib import algorithms >>> from cdlib.lifecycles.algorithms import flow_null >>> from networkx.generators.community import LFR_benchmark_graph >>> tc = TemporalClustering() >>> for t in range(0, 10): >>> g = LFR_benchmark_graph( >>> n=250, >>> tau1=3, >>> tau2=1.5, >>> mu=0.1, >>> average_degree=5, >>> min_community=20, >>> seed=10, >>> ) >>> coms = algorithms.louvain(g) # here any CDlib algorithm can be applied >>> tc.add_clustering(coms, t) >>> events = LifeCycle(tc) >>> events.compute_events("facets") >>> validated = flow_null(events, "0_2", "+")