Skip to content

Pareto fronts

These functions expose the full candidate set a detector selects its final partition from, letting you inspect or re-select solutions yourself.

Six of the ten detector entry points have one. gdpso and cdrme optimize a single scalar, so they have no Pareto front and no gdpso_fronts / cdrme_fronts; mocd_q and mocd_d are multi-objective but expose no front accessor.

pymocd.rimpso_fronts

rimpso_fronts(
    graph: Any,
    pop_size: int = 100,
    num_gens: int = 100,
    inertia: float = 0.4,
    cognitive: float = 0.7,
    social: float = 0.7,
    local_rate: float = 0.35,
    archive: int = 100,
    ls_period: int = 10,
    seed: int = 0,
) -> typing.Any

rimpso's archive: the graph's resolution profile.

Returns (fronts, objectives, selected) where fronts is a list of dict[node, community], objectives the matching (cut, pair) pairs, and selected the index the selector picks — the member a degree-corrected assortative block model fits best. cut is the fraction of edges leaving their community — the partition's own mixing parameter — and pair the fraction of node pairs sharing one.

Takes the same keyword arguments as rimpso, with the same defaults, and searches identically — only the return shape differs.

pymocd.rimpso_select

rimpso_select(
    graph: Any, candidates: Sequence[Mapping[int, int]]
) -> typing.Any

Run rimpso's label-free selection rule over partitions produced elsewhere.

candidates is a list of dict[node, community]. Returns (selected_index, objectives) where objectives holds the (cut, pair) point of each candidate. This exists so the selector can be evaluated independently of the search that normally feeds it.

pymocd.hpmocd_fronts

hpmocd_fronts(graph: Any) -> typing.Any

HP-MOCD's full Pareto front, the candidate set hpmocd selects from.

hpmocd applies max-modularity selection to this front and returns one partition; this returns every member, so HP-MOCD can be compared against other detectors on the SAME footing (best-in-front, i.e. selector-free). Without it, comparing hpmocd's single selected partition against another detector's front oracle silently handicaps HP-MOCD.

Note the HpMocd class is NOT registered with PyO3, so HpMocd.generate_pareto_front is unreachable from Python. This function is the supported route to the front.

Parameters:

Name Type Description Default
graph Any

networkx.Graph or DiGraph (integer node ids).

required

Returns:

Type Description
Any

list[dict[node, community]]. Isolated nodes get community -1.

pymocd.mmcomo_fronts

mmcomo_fronts(
    graph: Any,
    pop_size: int = 100,
    num_gens: int = 50,
    cross_rate: float = 0.1,
    mut_rate: float = 0.1,
    gap: int = 10,
    beta: float = 0.05,
) -> typing.Any

MMCoMO's merged rank-1 front, the candidate set mmcomo selects from. Isolated nodes get -1.

pymocd.ccm_fronts

ccm_fronts(
    graph: Any,
    pop_size: int = 200,
    num_gens: int = 100,
    cross_rate: float = 0.8,
    mut_rate: float = 0.014705882352941176,
    r: float = 1.0,
    alpha: float = 1.0,
    divisions: int = 12,
) -> builtins.list[builtins.dict[builtins.int, builtins.int]]

The rank-1 Pareto front ccm selects from, as a list of partitions.

ccm returns only the max-modularity member; Shaik et al. report the best-NMI and best-modularity solutions of the front, so reproducing their Tables 1–2 needs the whole candidate set.

Parameters:

Name Type Description Default
graph Any

networkx.Graph or igraph.Graph (integer node ids).

required
r float

Community Score power-mean exponent (Shaik default 1).

1.0
alpha float

Community Fitness exponent (Shaik default 1).

1.0
divisions int

Das–Dennis reference-point granularity p (default 12 → 91 reference points for the 3 objectives).

12

Returns:

Type Description
list[dict[int, int]]

list[dict[node, community]]. Isolated nodes get community -1.

pymocd.krm_fronts

krm_fronts(
    graph: Any,
    pop_size: int = 100,
    num_gens: int = 100,
    cross_rate: float = 0.8,
    mut_rate: float = 0.029411764705882353,
    divisions: int = 12,
) -> builtins.list[builtins.dict[builtins.int, builtins.int]]

The rank-1 Pareto front krm selects from, as a list of partitions.

krm returns only the max-modularity member; Shaik et al. report the best-NMI and best-modularity solutions of the front, so reproducing their Tables 1–2 needs the whole candidate set.

Parameters:

Name Type Description Default
graph Any

networkx.Graph or igraph.Graph (integer node ids).

required
divisions int

Das–Dennis reference-point granularity p (default 12 → 91 reference points for the 3 objectives).

12

Returns:

Type Description
list[dict[int, int]]

list[dict[node, community]]. Isolated nodes get community -1.

pymocd.moga_net_fronts

moga_net_fronts(
    graph: Any,
    pop_size: int = 300,
    num_gens: int = 30,
    cross_rate: float = 0.8,
    mut_rate: float = 0.2,
    r: float = 2.0,
    alpha: float = 1.0,
) -> builtins.list[builtins.dict[builtins.int, builtins.int]]

The rank-1 Pareto front moga_net selects from, as a list of partitions.

moga_net returns only the max-modularity member; Pizzuti's Table 1 reports the best-NMI solution of the front, so reproducing it needs the whole candidate set.

Parameters:

Name Type Description Default
graph Any

networkx.Graph or igraph.Graph (integer node ids).

required
r float

Community Score power-mean exponent. TEVC 2012 Sec. VI-C fixes it at 2, which is the default here.

2.0
alpha float

Community Fitness exponent. It does not set a community size: CF ≤ Σ_i deg(i)^(1−alpha) for every alpha, with equality only for the single-community partition. Pizzuti default 1.

1.0

Returns:

Type Description
list[dict[int, int]]

list[dict[node, community]]. Isolated nodes get community -1.