#pragma once
#include <vector>
#include <utility>

/**
 * FAGSO — Fast Algorithm for Greedy Surprise Optimisation (Jiang et al. 2014).
 *
 * Ranks every edge by Jaccard similarity, then iterates in decreasing order:
 * each edge that would merge two communities is accepted if ΔS > 0.
 * Uses an inter-community edge map for O(1) ΔM/Δp per candidate merge.
 */
std::vector<int> fagso_surprise(
    const std::vector<std::pair<int,int>>& edges,
    int n_nodes
);

/**
 * SP4 — Pre_CS + Louvain (with super-node aggregation) + Post_CS
 *       (Tang et al. 2019, algorithm SP4).
 *
 * Phase 0 : Pre_CS  — common-neighbour seeding of the initial partition.
 * Phase 1 : Louvain — node-movement sweeps + super-node aggregation
 *           (communities become super-nodes; repeat until stable).
 * Phase 2 : Post_CS — final node-movement pass on the original graph.
 *
 * n_restarts independent runs; best exact-Surprise partition is returned.
 */
std::vector<int> sp4_surprise(
    const std::vector<std::pair<int,int>>& edges,
    int n_nodes,
    int n_restarts = 8,
    int seed       = 42
);
