Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ktabe committed Apr 28, 2021
0 parents commit 2009178
Show file tree
Hide file tree
Showing 19 changed files with 2,426 additions and 0 deletions.
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2021 Kota Abe

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note:

sgsim contains a third-party package with a compatible license. See
sgsim/event_sim/LICENSE for detail.
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# sgsim: A Simple Skip Graph Simulator and Visualizer

## Overview
*sgsim* is a simple skip graph simulator and visualizer.

sgsim can:

- constructs a skip graph overlay network based on a random membership vector
- performs some simple experiments
- output some graphs

sgsim is written in Python and uses [pandas](https://pandas.pydata.org/) for statistics.


*sgsim* is developed by Kota Abe at Osaka City University, Japan
[[Link](https://www.media.osaka-cu.ac.jp/~k-abe/)]

![Unicast Image](https://github.com/abelab/sgsim/raw/main/images/unicast.png)

![Graph](https://github.com/abelab/sgsim/raw/main/images/sg_hops_vs_n.png)

## License
MIT License

## Installation
Tested with Python3.9

* pip install networkx
* pip install matplotlib
* pip install pandas
* pip install colorama

## Options
```
% python3 sg_main.py -h
usage: sg_main.py [-h] [-n N] [-a ALPHA] [--exp {basic,unicast,unicast_vary_n}]
[--unicast-algorithm {greedy,original}] [--fast-join] [--seed SEED] [--interactive]
[--output-topology-max-level OUTPUT_TOPOLOGY_MAX_LEVEL] [--output-hop-graph] [--diagonal]
[-v]
sgsim: Skip Graph Simulator and Visualizer
optional arguments:
-h, --help show this help message and exit
-n N number of nodes (default: 8)
-a ALPHA, --alpha ALPHA
base of membership vector (default: 2)
--exp {basic,unicast,unicast_vary_n}
experiment type
--unicast-algorithm {greedy,original}
unicast algorithm
--fast-join use fast (cheat) join
--seed SEED give a random seed
--interactive display graphs on a window rather than save to files
--output-topology-max-level OUTPUT_TOPOLOGY_MAX_LEVEL
render a topology from level 0 to the specified level (use with --exp basic)
--output-hop-graph render a hop graph (use with --exp unicast)
--diagonal draw diagonal line (use with --output-hop-graph)
-v, --verbose verbose output
```

Currently, a real (event-based) node insertion algorithm is not implemented.
You have to give `--fast-join` option to instruct statistically constructing a skip graph.

### Basic options:

- `--exp basic` Do statistics about routing tables.
- `--exp basic --output-topology-max-level=3` Output a topology graph from level 0 to 3 (sg_topology.png).
- `--exp unicast` Do simple unicast experiments. Output histograms of the number of hops (sg_hops_hist.png) and of messages (sg_msgs_hist.png).
- `--exp unicast --output-hop-graph` Output hop graphs (unicast-(algorithm)-#.png).
- `--exp unicast_vary_n` Compute an average number of hops, varying number of nodes. Output a graph (sg_hops_vs_n.png).
- `--unicast-algorithm greedy` Use a greedy algorithm for unicast
- `--unicast-algorithm original` Use an algorithm based on the article ["Skip Graphs"](https://dl.acm.org/doi/10.1145/1290672.1290674) for unicast

## Examples

- `python3 sg_main.py --fast-join --exp unicast --output-hop-graph -n 15 --unicast-algorithm original`
Binary file added images/sg_hops_vs_n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/unicast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added src/__init__.py
Empty file.
Loading

0 comments on commit 2009178

Please sign in to comment.