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.0.tar.gz
(16.0 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.0-py3-none-any.whl
(24.2 kB
view details)
File details
Details for the file pynetim-0.2.0.tar.gz.
File metadata
- Download URL: pynetim-0.2.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36739307c21565db8a9e041dfd6f703e3ef7be5a9da262e1d5c4d7e07da4c03b
|
|
| MD5 |
8398f30f71dc95512368a131d0bc8752
|
|
| BLAKE2b-256 |
08377ede09ea7982bfe818e5b1eeb40788dd989afe23571c7bcd85c848479552
|
File details
Details for the file pynetim-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pynetim-0.2.0-py3-none-any.whl
- Upload date:
- Size: 24.2 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 |
2743c172e052732e5733080a4cf518052acd8efcb9542ab5b5d40d5305003bdc
|
|
| MD5 |
6dae5f389e4bffc2c86cd6cc455a833f
|
|
| BLAKE2b-256 |
70afa16d3968d2ece5b63902b215961384126cd471988c2c795eb0558a8cebf8
|