Netmax
NetMax is a python library that provides the implementation of several algorithms for the problem of Influence Maximization in Social Networks. It also addresses the problem of Competitive Influence Maximization as an extensive-form strategic game setting.
Install / Use
/learn @lorenzobloise/NetmaxREADME
NetMax - Influence Maximization in Social Networks

NetMax is a Python library that provides the implementation of several algorithms for the problem of Influence Maximization in Social Networks, originally formulated in "Maximizing the Spread of Influence through a Social Network" (Kempe, Kleinberg and Tardos, 2003). NetMax is built upon NetworkX, a popular python library for working with graphs. It also addresses the problem of Competitive Influence Maximization, as an extensive-form strategic game setting in which multiple entities try to maximize their own influence across the network while minimizing the others'. It works with both signed and unsigned networks, implementing progressive, semi-progressive and non-progressive diffusion models.
Table of Contents:
Installation
To install the library you can run the following command:
pip install netmax
Requirements
NetMax was developed with Python 3.12 and requires the installation of several libraries, some of which are the following:
- networkx (version 3.3)
- numpy
- scipy
- tqdm
- heapdict
If you have already installed the library using pip, you don't need to install the requirements, otherwise you can simply run the following command:
pip install -r requirements.txt
Overview
This framework wants to be a useful tool for all those people who study the problem of Influence Maximization. The users instantiate the InfluenceMaximization class, setting some basic parameters:
input_graph: a directed graph representing the network (of typenetworkx.DiGraph)agents: a dictionary where the key is the agent name (str) and the value is his budget (int)alg: the algorithm to use for influence maximization (see Algorithms)diff_model: the diffusion model to use (see Diffusion models)inf_prob: the probability distribution used to generate (if needed) the probabilities of influence between nodes. The framework implements different influence probabilities, default isNone(see Influence probabilities)endorsement_policy: the policy that nodes use to choose which agent to endorse when they have been contacted by more than one agent. The framework implements different endorsement policies, default is'random'(see Endorsement policies)insert_opinion:Trueif the nodes do not contain any information about their opinion on the agents,Falseotherwise (or if the opinion is not used)inv_edges: aboolindicating whether to invert the edges of the graphfirst_random_seed: aboolindicating whether to insert a first node (chosen randomly) in the seed set of every agentr: number of simulations to execute (default is 100)verbose: ifTruesets the logging level toINFO, otherwise displays only the minimal information
Important: alg, diff_model, inf_prob and endorsement_policy can be either str or class parameters:
- If they are
strparameters, they represent thenameattribute of the corresponding class already present in the framework. This was done in order to prevent the user from directly importing and instantiating all the specific classes, which could have not been user-friendly. To view all the keywords for these parameters, see the corresponding section - Otherwise, they must extend the corresponding superclass depending on the parameters (
Algorithmforalg,DiffusionModelfordiff_model,InfluenceProbabilityforinf_prob,EndorsementPolicyforendorsement_policy). This way, the user can define his own custom classes
After creating the InfluenceMaximization object, the user may call its run() method, which returns:
seed: a dictionary where the key is the agent name and the value is the seed set foundspread: a dictionary where the key is the agent name and the value is the expected spreadexecution_time: the total execution time (in seconds)
All these values are also available in the result attribute (which is a dictionary) of the InfluenceMaximization object.
Algorithms
NetMax provides the implementation of many state-of-the-art algorithms.
Simulation-based
- Monte-Carlo Greedy: implemented by the class
MCGreedy(keyword:mcgreedy) - CELF: implemented by the class
CELF(keyword:celf) - CELF++: implemented by the class
CELF_PP(keyword:celfpp)
Proxy-based
- Highest Out-Degree Heuristic: implemented by the class
HighestOutDegree(keyword:outdeg) - Degree Discount: implemented by the class
DegDis(keyword:degdis) - Group PageRank: implemented by the class
Group_PR(keyword:group_pr)
Sketch-based
- StaticGreedy: implemented by the class
StaticGreedy(keyword:static_greedy) - RIS: implemented by the class
RIS(keyword:ris) - TIM: implemented by the class
TIM(keyword:tim) - TIM+: implemented by the class
TIMp(keyword:tim_p)
Diffusion models
The supported diffusion models are:
- Independent Cascade: implemented by the class
IndependentCascade(keyword:ic) - Linear Threshold: implemented by the class
LinearThreshold(keyword:lt) - Triggering Model: implemented by the class
Triggering(keyword:tr) - Decreasing Cascade: implemented by the class
DecreasingCascade(keyword:dc) - Semi-Progressive Friend-Foe Dynamic Linear Threshold: implemented by the class
SemiProgressiveFriendFoeDynamicLinearThreshold(keyword:sp_f2dlt) - Non-Progressive Friend-Foe Dynamic Linear Threshold: implemented by the class
NonProgressiveFriendFoeDynamicLinearThreshold(keyword:np_f2dlt)
Influence probabilities
The influence probabilities are used to label the edges between the network nodes if they are not already labeled. The user can choose between:
- A constant value, set by default at
0.1(keyword:constant) - A uniform distribution between
0.01and0.1(keyword:uniform) - A distribution based on similarity between nodes computed with SimRank algorithm (keyword:
similarity) - A ratio model which distributes the probability uniformly based on the in-degree of the target node (keyword:
ratio) - A hybrid approach based on the average degree of the graph (keyword:
hybrid) - An opinion-based approach (keyword:
opinion) which assigns to each node a vector of opinions (namely, values between0and1) and computes the influence probability comparing the opinions of the two nodes with cosine similarity and taking into account also their SimRank similarity, with the formula:
$p(u,v)=b+k*\left(\frac{1}{outdeg(u)}*similarity(u,v)+cossim(opinion(u),opinion(v))\right)$
Endorsement policies
In the competitive setting it is possible that, in the same time step, multiple agents contact the same node. Therefore, it is necessary an endorsement policy that dictates which agent the node chooses to endorse. Several endorsement policies are implemented:
- A random policy, which chooses randomly between the agents that contacted the node in that specific time step (keyword:
random) - A voting-based policy, which chooses the most occurring agent between the already activated neighbors of the node (keyword:
voting) - A community-based approach, which applies the voting strategy to the community the node belongs to instead of its neighbors (keyword:
community) - A similarity-based policy, which essentially is a weighted voting strategy based on the SimRank similarity between the node and its neighbors (keyword:
sim_endorsement)
Useful papers
Here is a non-exhaustive list of useful papers which have been studied thoroughly to develop this framework:
- Bharathi et al. - Competitive Influence Maximization in Social Networks
- Borgs et al. - Maximizing Social Influence in Nearly Optimal Time
- Borodin et al. - Threshold Models for Competitive Influence in Social Networks
- Budak et al. - Limiting the Spread of Misinformation in Social Networks
- Carnes et al. - Maximizing influence in a competitive social network
- Chen et al. - Efficient Influence Maximization in Social Networks
- Chen et al. - StaticGreedy Solving the Scalability-Accuracy Dilemma in Influence Maximization
- Goyal et al. - CELF++ Optimizing the Greedy Algorithm for Influence Maximization in Social Networks
- Goyal et al. - Learning Influence Probabilities In Social Networks
- Goyal et al. - SimPath An Efficient Algorithm for Influence Maximization under the Linear Threshold Model
- Gursoy et al. - Influence Maximization in Social Networks Under Deterministic Linear Threshold Model
- Huang et al. - Competitive and complementary influence maximization in social network A follower's perspective
- Kempe et al. - Influential Nodes in a Diffusion Model for Social Networks
- Kempe et al. - Maximizing the Spread of Influence through a Social Network
- Kong et al. - Online Influence Maximization under Decreasing Cascade Model
- Leskovec et al. - Cost-Effective Outbreak Detection in Networks
- Li et al. - GetReal Towards Realistic Selection of Influence Maximizatio
Related Skills
node-connect
342.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
84.7kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
84.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
342.0kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
