Skip to content

Commit 5069c36

Browse files
Merge pull request #8 from GiulioRossetti/ndlib-rest-2.0
Ndlib-rest v2.0.0 Bored Blackbird
2 parents cc824f0 + 5b24477 commit 5069c36

16 files changed

+842
-561
lines changed

.gitignore

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
env/
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*,cover
49+
.hypothesis/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Django stuff:
56+
*.log
57+
local_settings.py
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# dotenv
85+
.env
86+
87+
# virtualenv
88+
.venv
89+
venv/
90+
ENV/
91+
92+
# Spyder project settings
93+
.spyderproject
94+
95+
# Rope project settings
96+
.ropeproject
97+

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sudo: required
22

33
language: python
44
python:
5-
- "2.7"
5+
- "3.6"
66

77
before_install:
88
- pip install gunicorn

CHANGELOG.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4-
## [Unrealeased]
4+
## [To Add]
5+
- Dynamic Graph generator
6+
- Dynamic Graph upload/load
7+
8+
## [2.0.0]
9+
### Added
10+
- Python 3 support
11+
- Dynamic Network Support
12+
- Models
13+
- Dynamic SI
14+
- Dynamic SIS
15+
- Dynamic SIR
16+
17+
## [1.0.0]
518
### Added
6-
- Website
7-
- REST tutorial
8-
- Python client tutorial
19+
- Models
20+
- SEIS
21+
- SEIR
22+
23+
### Updated
24+
- Diffusion Library update: ndlib 2.x.x
25+
926

1027
## [0.9.2]
1128
### Added

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:2.7-slim
1+
FROM python:3.6-slim
22
MAINTAINER Salvo Rinzivillo <rinzivillo@isti.cnr.it>
33

44

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ This project offers a REST interface for the [ndlib](https://github.com/GiulioRo
1111
* Python REST client: ndlib-rest/client
1212

1313

14-
Python 2.7 required dependencies:
15-
16-
- [ndlib](https://github.com/GiulioRossetti/ndlib)
17-
- flask
18-
- flask-cors
19-
- flask_restful
20-
- flask_apidoc
21-
- networkx
22-
- numpy
23-
- scipy
14+
Python 3.6 required dependencies:
15+
16+
- [ndlib](https://github.com/GiulioRossetti/ndlib)=3.0.0
17+
- flask==0.12
18+
- flask-cors==3.0.2
19+
- flask_restful==0.3.5
20+
- flask_apidoc==1.0.0
21+
- networkx==1.11
22+
- numpy==1.12.0
23+
- scipy==0.18.1
24+
- [dynetx](https://github.com/GiulioRossetti/dynetx)==0.1.6
2425

2526
#### REST service setup
2627
Local testing

apidoc.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "(N)etwork (D)iffusion library REST service",
3-
"version": "0.9.2",
3+
"version": "2.0.0",
44
"description": "REST service for the simulation of diffusion models over networks.",
55
"title": "NDlib REST",
66
"url": "http://127.0.0.1:5000",
@@ -35,6 +35,8 @@
3535
"si",
3636
"sir",
3737
"sis",
38+
"seis",
39+
"seir",
3840
"threshold",
3941
"KerteszThreshold",
4042
"profile",
@@ -44,6 +46,9 @@
4446
"qvoter",
4547
"majority",
4648
"sznajd",
49+
"dsi",
50+
"dsis",
51+
"dsis",
4752
"Iterators",
4853
"iterator",
4954
"iteratorbunch"

client/NDlibClient.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,21 @@ def add_SIS(self, infected, beta, lbd):
111111
data={'infected': infected, 'beta': beta, 'lambda': lbd, 'token': self.token})
112112
return res.status_code
113113

114+
def add_SEIS(self, infected, beta, alpha, lbd):
115+
res = put('%s/api/SEIS' % self.base,
116+
data={'infected': infected, 'beta': beta, 'lambda': lbd, 'alpha': alpha, 'token': self.token})
117+
return res.status_code
118+
114119
def add_SIR(self, infected, beta, gamma):
115120
res = put('%s/api/SIR' % self.base,
116121
data={'infected': infected, 'beta': beta, 'gamma': gamma, 'token': self.token})
117122
return res.status_code
118123

124+
def add_SEIR(self, infected, beta, gamma, alpha):
125+
res = put('%s/api/SEIR' % self.base,
126+
data={'infected': infected, 'beta': beta, 'gamma': gamma, 'alpha': alpha, 'token': self.token})
127+
return res.status_code
128+
119129
def add_independent_cascades(self, infected):
120130
res = put('%s/api/IndependentCascades' % self.base, data={'infected': infected, 'token': self.token})
121131
return res.status_code
@@ -212,7 +222,7 @@ def load_exploratory(self, name):
212222
res = post('%s/api/Exploratory' % self.base, data={'exploratory': name, 'token': self.token})
213223
return res.status_code
214224

215-
def upload_graph(self, directed, graph):
225+
def upload_graph(self, directed, graph, dynamic=False):
216226
res = post('%s/api/UploadNetwork' % self.base,
217-
data={'directed': directed, 'graph': json.dumps(graph), 'token': self.token})
227+
data={'directed': directed, 'graph': json.dumps(graph), 'dynamic': dynamic, 'token': self.token})
218228
return res.status_code

client/example.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@
66
e = NDlibClient("http://127.0.0.1:5000")
77

88

9-
print "indipendent cascades"
10-
e.create_experiment()
11-
x = e.add_erdos_renyi_graph(300, 0.01)
12-
e.add_independent_cascades(0.1)
13-
tot = 0
14-
for it in xrange(0, 10):
15-
ex = e.get_iteration()
16-
for m in ex:
17-
print it, len(ex[m]['status'])
18-
19-
e.destroy_experiment()
20-
9+
# print "indipendent cascades"
10+
# e.create_experiment()
11+
# x = e.add_erdos_renyi_graph(300, 0.01)
12+
# e.add_independent_cascades(0.1)
13+
# tot = 0
14+
# for it in xrange(0, 10):
15+
# ex = e.get_iteration()
16+
# for m in ex:
17+
# print it, len(ex[m]['status'])
18+
#
19+
# e.destroy_experiment()
2120

22-
e.create_experiment()
23-
x = e.add_erdos_renyi_graph(300, 0.01)
24-
e.add_cognitiveopdyn(0.15, 0, 1, 0, 1, 1/3.0, 1/3.0, 1/3.0)
25-
tot = 0
26-
for it in xrange(0, 10):
27-
ex = e.get_iteration()
28-
for m in ex:
29-
print it, len(ex[m]['status'])
3021

31-
e.destroy_experiment()
22+
# e.create_experiment()
23+
# x = e.add_erdos_renyi_graph(300, 0.01)
24+
# e.add_cognitiveopdyn(0.15, 0, 1, 0, 1, 1/3.0, 1/3.0, 1/3.0)
25+
# tot = 0
26+
# for it in xrange(0, 10):
27+
# ex = e.get_iteration()
28+
# for m in ex:
29+
# print it, len(ex[m]['status'])
30+
#
31+
# e.destroy_experiment()
3232

3333
# rivedere i parametri del modello
3434

3535
#
3636
print "ClusteredBA_bottom"
3737
e.create_experiment()
3838
e.load_exploratory("ClusteredBA_bottom")
39-
e.add_kertesz_model(0.1, threshold=0.1, blocked=0.1, adopter_rate=0.1)
39+
e.add_kertesz_model(0.01, threshold=1, blocked=0.1, adopter_rate=0)
4040
tot = 0
4141
for it in xrange(0, 10):
4242
ex = e.get_iteration()
@@ -51,6 +51,8 @@
5151

5252
e.destroy_experiment()
5353

54+
exit()
55+
5456
# rivedere i parametri del modello
5557
print "ClusteredBA_top"
5658
e.create_experiment()

0 commit comments

Comments
 (0)