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 # 包初始化文件
版本
当前版本: 0.1.0
许可证
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.2.tar.gz
(16.4 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.2-py3-none-any.whl
(24.3 kB
view details)
File details
Details for the file pynetim-0.2.2.tar.gz.
File metadata
- Download URL: pynetim-0.2.2.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2938912b887f6ea911c6110da874d4a058eb9404b7d2da2a93f194b32802908b
|
|
| MD5 |
994c70d2a2739df4f185c86009430928
|
|
| BLAKE2b-256 |
1b22130613d5233ad3a91b4a65afa307dcc64f14c4c6b51f7e828b810a0f4f06
|
File details
Details for the file pynetim-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pynetim-0.2.2-py3-none-any.whl
- Upload date:
- Size: 24.3 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 |
1640c31d1bc1fa19a2e81ac1d93288a99d51651030945a8ccf40186845db3dcf
|
|
| MD5 |
9c856adb1e3b4eb38a7a37e36e4f5a6b
|
|
| BLAKE2b-256 |
0ad2e74d6b7bdf6e1731c821b85c3f0f963fdf95cf17b20002891192e55f9ba0
|