This repository implements and compares three metaheuristic algorithms — Tabu Search, Simulated Annealing, and Genetic Algorithm — with a simple degree-based Greedy baseline, for the Influence Maximization problem under the Linear Threshold (LT) model.
All algorithms use random node thresholds and weighted edges.
influence-maximization/
├── algorithms/ # Algorithm implementations
│ ├── __init__.py
│ ├── tabu_search.py # Tabu Search
│ ├── simulated_annealing.py # Simulated Annealing
│ └── genetic_algorithm.py # Genetic Algorithm
├── network.txt # Small test network dataset (with weights)
├── run_experiments.py # Main script: run comparative experiments
├── requirements.txt # Dependencies
├── .gitignore
└── README.md # This file
- Filename:
network.txt - Format: Edge list with weights, space-separated (three columns per line)
Example: 1 2 0.5 → directed edge from node 1 to node 2 with weight 0.5
- Purpose: Used for quick validation and comparison of algorithms under LT model (typically tested with seed set sizes k = 3 to 10)
To test on larger networks (e.g., NetHEPT, Epinions, etc.), simply replace
network.txtwith your own file and update the path inrun_experiments.pyif needed.
- Unified interface: each algorithm returns
(best_seed_set: set[int], influence_spread: int) - LT propagation: cumulative weighted influence from activated neighbors
- Comparative experiments: average spread and runtime over multiple runs
- Baseline: simple degree-greedy method for quick comparison
Python 3.8 or higher
# Recommended: use a virtual environment
python -m venv venv
source venv/bin/activate # Linux / macOS
# Windows: venv\Scripts\activate
Install dependencies: pip install -r requirements.txt
Make sure network.txt is in the project root directory
Run the main experiment script:
python run_experiments.py
- Loads the graph from network.txt
- For each k in [3, 4, 5, 6, 8, 10]:
- Randomly assigns thresholds (0.01–0.99) to nodes
- Runs Greedy, Tabu Search, SA, and GA (3 repeats each)
- Prints per-run results
- Finally displays a summary table:
k | Greedy | Tabu Search | SA | GA
| spread time(s) | spread time(s) | spread time(s) | spread time(s)
--------------------------------------------------------------------------------
3 | 12.0 0.01 | 15.3 2.45 | 14.7 1.89 | 16.0 4.21
Each algorithm is implemented as a standalone Python module under algorithms/, so you can directly import and reuse them in your own projects.
You can easily tune parameters inside run_experiments.py:
- Change K_VALUES, REPEATS
- Adjust algorithm-specific parameters in the ALGORITHMS list (iterations, population size, cooling rate, etc.)
- Monte-Carlo averaging over multiple threshold realizations
- Additional baselines (CELF, Degree DiscountIC, etc.)
- Support for larger real-world datasets
- Visualization of spread vs. k curves
Shuntao Wang