summaryrefslogtreecommitdiff
path: root/scripts/run_all.py
blob: c98b9a24829c4d44274bc75373e2ebe9b36add11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Master orchestration script: run all methods, compute accuracy and stats, generate plots."""

import sys
import os
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

from config import NETWORKS, METHODS


def main():
    start = time.time()

    print("=" * 60)
    print("EC-SBM Community Detection Analysis Pipeline")
    print("=" * 60)

    # Step 1: Run community detection methods
    for net_name in NETWORKS:
        for method in METHODS:
            m_name = method["name"]
            m_type = method["type"]

            print(f"\n{'='*60}")
            print(f"Running {m_name} on {net_name}")
            print(f"{'='*60}")

            if m_type == "leiden":
                from run_leiden import run_leiden
                run_leiden(net_name, m_name, method["quality"],
                           method.get("resolution"))
            elif m_type == "infomap":
                from run_infomap import run_infomap
                run_infomap(net_name)
            elif m_type == "graphtool_sbm":
                from run_graphtool_sbm import run_graphtool_sbm
                run_graphtool_sbm(net_name)

    # Step 2: Compute accuracy
    print(f"\n{'='*60}")
    print("Computing accuracy metrics")
    print(f"{'='*60}")
    from compute_accuracy import compute_all_accuracy
    compute_all_accuracy()

    # Step 3: Compute cluster stats
    print(f"\n{'='*60}")
    print("Computing cluster statistics")
    print(f"{'='*60}")
    from compute_stats import compute_all_stats
    compute_all_stats()

    # Step 4: Generate plots and tables
    print(f"\n{'='*60}")
    print("Generating plots and LaTeX tables")
    print(f"{'='*60}")
    from generate_plots import generate_all
    generate_all()

    elapsed = time.time() - start
    print(f"\n{'='*60}")
    print(f"Pipeline complete in {elapsed:.1f}s")
    print(f"{'='*60}")


if __name__ == "__main__":
    main()