A Python library for Network Influence Maximization
Project description
PyNetIM
PyNetIM 是一个用于社交网络中影响力最大化的 Python 库,实现了多种经典算法和扩散模型。
功能特点
- 实现了多种影响力最大化算法
- 支持独立级联(IC)和线性阈值(LT)扩散模型,可以自定义扩展(继承BaseDiffusionModel)
- 提供图结构封装和边权重设置工具
- 支持单进程和多进程模式
- 包含算法性能计时器装饰器
算法实现
启发式算法
- SingleDiscountAlgorithm: 简单度折扣算法
- DegreeDiscountAlgorithm: 度折扣算法
模拟算法
- GreedyAlgorithm: 贪婪算法
- CELFAlgorithm: CELF算法(Cost-Effective Lazy Forward)
反向影响采样算法
- BaseRISAlgorithm: 基础RIS算法
- IMMAlgorithm: IMM算法(Influence Maximization via Martingales)
扩散模型
- IndependentCascadeModel: 独立级联模型(IC)
- LinearThresholdModel: 线性阈值模型(LT)
核心组件
图结构
- IMGraph: 影响力最大化图类,封装NetworkX图对象
工具函数
- set_edge_weight: 设置边权重
- run_monte_carlo_diffusion: 执行蒙特卡洛模拟扩散
- Timer: 计时器装饰器
安装
pip install pynetim
快速开始
import networkx as nx
from pynetim import IMGraph, IndependentCascadeModel
from pynetim.algorithms import DegreeDiscountAlgorithm
# 创建图对象
g = nx.erdos_renyi_graph(100, 0.1)
# 入度分之一作为权重
graph = IMGraph(g, edge_weight_type='WC')
# 使用算法
algorithm = DegreeDiscountAlgorithm(graph)
seeds = algorithm.run(k=10)
项目结构
pynetim/
├── algorithms/ # 算法实现
├── diffusion_model/ # 扩散模型
├── graph/ # 图结构封装
├── utils/ # 工具函数
├── decorator/ # 装饰器
└── __init__.py # 包初始化文件
许可证
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pynetim-0.2.3.tar.gz
(17.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pynetim-0.2.3-py3-none-any.whl
(29.0 kB
view details)
File details
Details for the file pynetim-0.2.3.tar.gz.
File metadata
- Download URL: pynetim-0.2.3.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba0f26c221c29bc0ccaff491c4c88916174900b4bb872a09484f5f748ac4a3f5
|
|
| MD5 |
cb9407c6110f88284eac994d768bdeee
|
|
| BLAKE2b-256 |
6834f2943cb65221cf098d42d3a1393b31b82a3d8f420b4741c0b75e194f8048
|
File details
Details for the file pynetim-0.2.3-py3-none-any.whl.
File metadata
- Download URL: pynetim-0.2.3-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c68b01253f5d6d241ef865bc93d1ab14c813afea09fb2b9ba453c43fd968d73
|
|
| MD5 |
6f8e39e878c19610a10bc732eaca036a
|
|
| BLAKE2b-256 |
53ceee5896979e08ee3aa0aa300c91cf450fffed1959375a21de97579f6bc243
|