diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..a7cdd590 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +[run] +branch = True +omit = + */pyrgg/__main__.py + */pyrgg/__init__.py +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + pragma: no cover diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..ba04a5c0 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at sepand@qpage.ir. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..c74692be --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contribution + +Changes and improvements are more than welcome! ❤️ Feel free to fork and open a pull request. + + +Please consider the following : + + +1. Fork it! +2. Create your feature branch (under `dev` branch) +3. Add your functions/methods to proper files +4. Add standard `docstring` to your functions/methods +5. Add tests for your functions/methods (`doctest` testcases in `test` folder) +6. Pass all CI tests +7. Update `CHANGELOG.md` + - Describe changes under `[Unreleased]` section +8. Submit a pull request into `dev` (please complete the pull request template) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..d588340f --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +#### Description + +#### Steps/Code to Reproduce + +#### Expected Behavior + +#### Actual Behavior + +#### Operating System + +#### Python Version + +#### Pyrgg Version diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..590816d5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +#### Reference Issues/PRs + +#### What does this implement/fix? Explain your changes. + + +#### Any other comments? + diff --git a/.gitignore b/.gitignore index 06a80920..d581dd61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,110 @@ +# Created by .ignore support plugin (hsz.mobi) +### Python template +# Byte-compiled / optimized / DLL files node_modules/ datasets/ +__pycache__/ +*.py[cod] +*$py.class + +*.gr +*.json +*.csv +*.wel +*.lp +*.p +*.dl +*.tgf + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# 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 + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +.venv/ +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject +### Example user template template +### Example user template + +# IntelliJ project files +.idea +*.iml +out +gen diff --git a/.travis.yml b/.travis.yml index 7374b5be..362edaf6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,39 @@ -sudo: true - language: python -python: - - 3.5 - +matrix: + include: + - os: linux + python: 3.7 + dist: xenial + - os: linux + python: 3.6 + - os: linux + python: 3.5 + - os: linux + python: 3.4 + - os: linux + python: 2.7 + - os: osx + language: generic + env: TOXENV=py36 + - os: linux + python: 3.7-dev + dist: xenial + - os: linux + python: 3.8-dev + dist: xenial + - os: linux + python: nightly + dist: xenial + allow_failures: + - os: linux + python: 2.7 install: - - pip3 install -r requirements.txt - - python3 setup.py install - + - chmod +x .travis/install.sh + - .travis/install.sh +before_script: + - chmod +x .travis/test.sh script: - - python3 -m pyrgg test + - .travis/test.sh after_success: - codecov \ No newline at end of file diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100644 index 00000000..64aebec2 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Dump Environment (so that we can check PATH, UT_FLAGS, etc.) + set -e + set -x + PYTHON_COMMAND=python + PIP_COMMAND=pip + if [ "$TRAVIS_OS_NAME" == "osx" ] + then + PYTHON_COMMAND=python3 + PIP_COMMAND=pip3 + fi + + $PIP_COMMAND install -r requirements.txt + $PYTHON_COMMAND setup.py install + $PYTHON_COMMAND -m pyrgg test + + if [ "$TRAVIS_OS_NAME" == "osx" ] + then + $PIP_COMMAND install --upgrade --upgrade-strategy=only-if-needed -r dev-requirements.txt --user + else + $PIP_COMMAND install --upgrade --upgrade-strategy=only-if-needed -r dev-requirements.txt + fi \ No newline at end of file diff --git a/.travis/test.sh b/.travis/test.sh new file mode 100644 index 00000000..d75539ef --- /dev/null +++ b/.travis/test.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Dump Environment (so that we can check PATH, UT_FLAGS, etc.) + set -e + set -x + IS_IN_TRAVIS=false + PYTHON_COMMAND=python + + if [ "$TRAVIS_OS_NAME" == "osx" ] + then + PYTHON_COMMAND=python3 + fi + + if [ "$CI" = 'true' ] && [ "$TRAVIS" = 'true' ] + then + IS_IN_TRAVIS=true + fi + $PYTHON_COMMAND -m pytest test --cov=pyrgg --cov-report=term + if [ "$IS_IN_TRAVIS" = 'false' ] || [ "$TRAVIS_PYTHON_VERSION" = '3.6' ] + then + $PYTHON_COMMAND -m vulture pyrgg setup.py otherfile --min-confidence 65 --sort-by-size + $PYTHON_COMMAND -m bandit -r pyrgg -s B311,B403,B322 + $PYTHON_COMMAND otherfile/version_check.py + $PYTHON_COMMAND -m pydocstyle --match-dir=pyrgg + fi + $PYTHON_COMMAND -m cProfile -s cumtime otherfile/pyrgg_profile.py + + \ No newline at end of file diff --git a/AUTHORS.md b/AUTHORS.md index 79a462ae..e1298b66 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,4 +1,4 @@ # Core Developers # ---------- -- Sepand Haghighi - Sharif University Of Technology/Moduland Co - ([http://github.com/sepandhaghighi](http://github.com/sepandhaghighi)) ([sepand@qpage.ir](mailto:sepand@qpage.ir)) \ No newline at end of file +- Sepand Haghighi - Sharif University Of Technology - ([@sepandhaghighi](http://github.com/sepandhaghighi)) ([sepand@qpage.ir](mailto:sepand@qpage.ir)) \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..6b1d9846 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] +## [0.3] - 2019-11-29 +### Added +- `__version__` variable +- `CHANGELOG.md` +- `dev-requirements.txt` +- `requirements.txt` +- `CODE_OF_CONDUCT.md` +- `ISSUE_TEMPLATE.md` +- `PULL_REQUEST_TEMPLATE.md` +- `CONTRIBUTING.md` +- `version_check.py` +- `pyrgg_profile.py` +- Unweighted graph +- Undirected graph +- Exe version +### Changed +- Test system modified +- `README.md` modified +- Docstrings modified +- `get_input` function modified +- `edge_gen` function modified +- Parameters moved to `params.py` + +## [0.2] - 2017-09-20 +### Added +- CSV format +- YAML format +- Weighted edge list format (WEL) +- ASP format +- Trivial graph format (TGF) +- UCINET DL format +- Pickle format + +## [0.1] - 2017-08-19 +### Added +- DIMACS format +- JSON format +- README + +[Unreleased]: https://github.com/sepandhaghighi/pyrgg/compare/v0.3...dev +[0.3]: https://github.com/sepandhaghighi/pyrgg/compare/v0.2...v0.3 +[0.2]: https://github.com/sepandhaghighi/pyrgg/compare/v0.1...v0.2 +[0.1]: https://github.com/sepandhaghighi/pyrgg/compare/1e238cd...v0.1 + + + diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..a9d121d9 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,9 @@ +include LICENSE +include *.md +include *.spec +include *.txt +include *.yml +include *.ini +recursive-include paper *.bib +recursive-include paper *.md +recursive-include paper *.pdf \ No newline at end of file diff --git a/PYRGG.spec b/PYRGG.spec new file mode 100644 index 00000000..3515f778 --- /dev/null +++ b/PYRGG.spec @@ -0,0 +1,31 @@ +# -*- mode: python -*- + +block_cipher = None + + +a = Analysis(['pyrgg/__main__.py'], + pathex=['pyrgg'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + name='PYRGG', + debug=False, + strip=False, + upx=True, + runtime_tmpdir=None, + icon='otherfile/icon.ico', + version="otherfile/Version.rc", + console=True ) diff --git a/README.md b/README.md index 7f8fa35c..afd09aac 100644 --- a/README.md +++ b/README.md @@ -6,83 +6,122 @@

Random Graph Generator

- + PyPI version -DOI - - + Codecov built with Python3 - + + +---------- +## Table of contents + * [Overview](https://github.com/sepandhaghighi/pyrgg#overview) + * [Installation](https://github.com/sepandhaghighi/pyrgg#installation) + * [Usage](https://github.com/sepandhaghighi/pyrgg#usage) + * [Issues & Bug Reports](https://github.com/sepandhaghighi/pyrgg#issues--bug-reports) + * [Todo](https://github.com/sepandhaghighi/pyrgg#todo) + * [Sample Files](https://github.com/sepandhaghighi/pyrgg#sample-files) + * [Example Of Usage](https://github.com/sepandhaghighi/pyrgg#example-of-usage) + * [Supported Formats](https://github.com/sepandhaghighi/pyrgg#supported-formats) + * [Similar Works](https://github.com/sepandhaghighi/pyrgg#similar-works) + * [Dependencies](https://github.com/sepandhaghighi/pyrgg#dependencies) + * [Contribution](https://github.com/sepandhaghighi/pyrgg/blob/master/.github/CONTRIBUTING.md) + * [References](https://github.com/sepandhaghighi/pyrgg#references) + * [Citing](https://github.com/sepandhaghighi/pyrgg#citing) + * [Authors](https://github.com/sepandhaghighi/pyrgg/blob/master/AUTHORS.md) + * [License](https://github.com/sepandhaghighi/pyrgg#license) + * [Donate](https://github.com/sepandhaghighi/pyrgg#donate-to-our-project) + * [Changelog](https://github.com/sepandhaghighi/pyrgg/blob/master/CHANGELOG.md) + * [Code of Conduct](https://github.com/sepandhaghighi/pyrgg/blob/master/.github/CODE_OF_CONDUCT.md) ## Overview Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various graph file formats including DIMACS .gr files. Pyrgg has the ability to generate graphs of different sizes and is designed to provide input files for broad range of graph-based research applications, including but not limited to testing, benchmarking and performance-analysis of graph processing frameworks. Pyrgg target audiences are computer scientists who study graph algorithms and graph processing frameworks. - -## Installation - -### Source Code -- Download [Version 0.2](https://github.com/sepandhaghighi/pyrgg/archive/v0.2.zip) or [Latest Source ](https://github.com/sepandhaghighi/pyrgg/archive/master.zip) -- `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access) -- `python3 setup.py install` or `python setup.py install` (Need root access) - -### PyPI + + + + + + + + + + + + + +
Open Hub
PyPI Counter
Github Stars
-- Check [Python Packaging User Guide](https://packaging.python.org/installing/) -- `pip install pyrgg` or `pip3 install pyrgg` (Need root access) - + + + + + + + + + + + + + + + + +
Branchmasterdev
Travis
AppVeyor
-## Usage + + + + + + +
Code QualityCodeFactor
-
- +## Installation -
-pyrgg output -

Fig. 1. DIMACS .gr output format

+### Source Code +- Download [Version 0.3](https://github.com/sepandhaghighi/pyrgg/archive/v0.3.zip) or [Latest Source ](https://github.com/sepandhaghighi/pyrgg/archive/dev.zip) +- `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access) +- `python3 setup.py install` or `python setup.py install` (Need root access) -
+### PyPI +- Check [Python Packaging User Guide](https://packaging.python.org/installing/) +- `pip install pyrgg==0.3` or `pip3 install pyrgg==0.3` (Need root access) -## Test +### Conda +- Check [Conda Managing Package](https://conda.io) +- `conda install -c sepandhaghighi pyrgg` (Need root access) +### Exe Version (Only Windows) +- Download [Exe-Version 0.3](https://github.com/sepandhaghighi/pyrgg/releases/download/v0.3/PYRGG-0.3.exe) +- Run `PYRGG-0.3.exe` -`python3 -m pyrgg test` or `python -m pyrgg test` - -This test run automatically in each commit ;-) - -
- - - - +### System Requirements +Pyrgg will likely run on a modern dual core PC. Typical configuration is: - +- Dual Core CPU (2.0 Ghz+) +- 4GB of RAM - - - +Note that it may run on lower end equipment though good performance is not guaranteed. - -
LinuxWindows
+## Usage -
-
-pyrgg test - +
@@ -103,12 +142,14 @@ or send an email to [sepand@qpage.ir](mailto:sepand@qpage.ir "sepand@qpage.ir"). - [x] ASP - [x] TGF - [x] UCINET DL + - [ ] GEXF - [ ] Sizes - [x] Small - [x] Medium - [ ] Large - [x] Weighted Graph - [x] Signed Weights +- [x] Unweighted Graph - [x] Dense Graph - [x] Sparse Graph - [x] Directed Graph @@ -154,7 +195,7 @@ or send an email to [sepand@qpage.ir](mailto:sepand@qpage.ir "sepand@qpage.ir"). - [CuSha](https://github.com/farkhor/CuSha "CuSha")
-

Fig. 2. Rand Graph Generation

+

Fig. 1. Rand Graph Generation

- Generate synthetic data for graph benchmark suite like [GAP](https://github.com/sbeamer/gapbs) @@ -296,14 +337,7 @@ or send an email to [sepand@qpage.ir](mailto:sepand@qpage.ir "sepand@qpage.ir"). n k weight_n ``` - [Pickle(.p)](https://docs.python.org/3.5/library/pickle.html) (Binary Format) - - - -## Contribution - -You can fork the repository, improve or fix some part of it and then send the pull requests back if you want to see them here. I really appreciate that. ❤️ - -Remember to write a few tests for your code before sending pull requests. + ## Similar Works - [Random Modular Network Generator](https://github.com/prathasah/random-modular-network-generator) Generates random graphs with tunable strength of community structure @@ -311,9 +345,23 @@ Remember to write a few tests for your code before sending pull requests. - [Graph1](https://github.com/Saptaparni/Graph1) Random Graph Generator with Max capacity paths (C++) +## Dependencies + + + + + + + + + + +
masterdev
Requirements StatusRequirements Status
+ + ## Citing -If you use pyrgg in your research , please cite the [JOSS paper](http://joss.theoj.org/papers/da33f691984d9a35f66ff93a391bbc26 "Pyrgg JOSS Paper") ;-) +If you use pyrgg in your research, please cite the [JOSS paper](http://joss.theoj.org/papers/da33f691984d9a35f66ff93a391bbc26 "Pyrgg JOSS Paper") ;-)
 @article{Haghighi2017,
@@ -329,14 +377,25 @@ If you use pyrgg in your research , please cite the [JOSS paper](http://joss.the
   journal = {The Journal of Open Source Software}
 }
 
+ + + + + + + + + + +
JOSS
ZenodoDOI
## License - + -## Reference +## References
@@ -346,13 +405,8 @@ If you use pyrgg in your research , please cite the [JOSS paper](http://joss.the
-## Donate to our project -

Beerpay :

- -Hey dude! Help me out for a couple of :beers:! - - -[![Beerpay](https://beerpay.io/sepandhaghighi/pyrgg/badge.svg?style=beer-square)](https://beerpay.io/sepandhaghighi/pyrgg) [![Beerpay](https://beerpay.io/sepandhaghighi/pyrgg/make-wish.svg?style=flat-square)](https://beerpay.io/sepandhaghighi/pyrgg?focus=wish) +## Donate to our project +

Bitcoin :

diff --git a/appveyor.yml b/appveyor.yml index 1bb1dc72..507d6bf2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,10 +6,27 @@ environment: - PYTHON: "C:\\Python35" PYTHON_VERSION: "3.5.2" PYTHON_ARCH: "32" - - PYTHON: "C:\\Python35" PYTHON_VERSION: "3.5.2" PYTHON_ARCH: "64" + - PYTHON: "C:\\Python37" + PYTHON_VERSION: "3.7.0" + PYTHON_ARCH: "64" + - PYTHON: "C:\\Python37" + PYTHON_VERSION: "3.7.0" + PYTHON_ARCH: "32" + - PYTHON: "C:\\Python36" + PYTHON_VERSION: "3.6.0" + PYTHON_ARCH: "64" + - PYTHON: "C:\\Python36" + PYTHON_VERSION: "3.6.0" + PYTHON_ARCH: "32" + - PYTHON: "C:\\Python34" + PYTHON_VERSION: "3.4.0" + PYTHON_ARCH: "64" + - PYTHON: "C:\\Python34" + PYTHON_VERSION: "3.4.0" + PYTHON_ARCH: "32" @@ -21,4 +38,7 @@ install: - "%PYTHON%/python.exe setup.py install" test_script: - - "%PYTHON%/python.exe -m pyrgg test" \ No newline at end of file + - "%PYTHON%/python.exe -m pyrgg test" + - "%PYTHON%/Scripts/pip.exe install -r dev-requirements.txt" + - "%PYTHON%/python.exe -m pytest test --cov=pyrgg --cov-report=term" + - "%PYTHON%/python.exe otherfile/version_check.py" \ No newline at end of file diff --git a/autopep8.bat b/autopep8.bat new file mode 100644 index 00000000..34cfb7c9 --- /dev/null +++ b/autopep8.bat @@ -0,0 +1,3 @@ +python -m autopep8 pyrgg --recursive --aggressive --aggressive --in-place --pep8-passes 2000 --verbose +python -m autopep8 setup.py --recursive --aggressive --aggressive --in-place --pep8-passes 2000 --verbose +python -m autopep8 version_check.py --recursive --aggressive --aggressive --in-place --pep8-passes 2000 --verbose \ No newline at end of file diff --git a/build_exe.bat b/build_exe.bat new file mode 100644 index 00000000..03e54fa1 --- /dev/null +++ b/build_exe.bat @@ -0,0 +1,11 @@ +@echo off +python --version | find /i "Python 3.4" > nul +echo ----- +if errorlevel 1 ( + echo Warning : Please use Python 3.4.x +) else ( + echo Python version check done! +) +echo ----- +python -m PyInstaller PYRGG.spec +pause \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..ee9fba11 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,10 @@ +art==4.2 +pyyaml==5.1.2 +codecov>=2.0.15 +pytest>=4.3.1 +pytest-cov>=2.6.1 +setuptools>=40.8.0 +vulture>=1.0 +bandit>=1.5.1 +pydocstyle>=3.0.0 + diff --git a/otherfile/Version.rc b/otherfile/Version.rc new file mode 100644 index 00000000..b8ff0b8b --- /dev/null +++ b/otherfile/Version.rc @@ -0,0 +1,28 @@ +VSVersionInfo( + ffi=FixedFileInfo( + filevers=(0, 3, 0, 0), + prodvers=(0, 3, 0, 0), + mask=0x3f, + flags=0x0, + OS=0x40004, + fileType=0x1, + subtype=0x0, + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + u'040904B0', + [StringStruct(u'CompanyName', u'Sepand Haghighi'), + StringStruct(u'FileDescription', u'PYRGG.exe'), + StringStruct(u'FileVersion', u'0.3.0.0'), + StringStruct(u'InternalName', u'PYRGG.exe'), + StringStruct(u'LegalCopyright', u'Copyright (c) 2019 Sepand Haghighi'), + StringStruct(u'OriginalFilename', u'PYRGG.exe'), + StringStruct(u'ProductName', u'PYRGG'), + StringStruct(u'ProductVersion', u'0, 3, 0, 0')]) + ]), + VarFileInfo([VarStruct(u'Translation', [1033, 1200])]) + ] +) \ No newline at end of file diff --git a/otherfile/icon.ico b/otherfile/icon.ico new file mode 100644 index 00000000..c23a9140 Binary files /dev/null and b/otherfile/icon.ico differ diff --git a/otherfile/pyrgg_profile.py b/otherfile/pyrgg_profile.py new file mode 100644 index 00000000..b2a6f790 --- /dev/null +++ b/otherfile/pyrgg_profile.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +"""Profile file.""" +from pyrgg import * + + +dimacs_maker('profile', 1, 5000, 300000, 1, 60, 0, 1) diff --git a/otherfile/version_check.py b/otherfile/version_check.py new file mode 100644 index 00000000..2a000400 --- /dev/null +++ b/otherfile/version_check.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +"""Version-check script.""" +import os +import sys +import codecs +Failed = 0 +VERSION = "0.3" + +VERSION_1 = VERSION.split(".")[0] +VERSION_2 = str(int(float(VERSION) * 10 - int(VERSION_1) * 10)) +VERSION_3 = str(int(float(VERSION) * 100 - int(VERSION_1) + * 100 - int(VERSION_2) * 10)) +VERSION_4 = "0" + +SETUP_ITEMS = [ + "version='{0}'", + 'https://github.com/sepandhaghighi/pyrgg/tarball/v{0}'] +README_ITEMS = [ + "[Version {0}](https://github.com/sepandhaghighi/pyrgg/archive/v{0}.zip)", + "[Exe-Version {0}](https://github.com/sepandhaghighi/pyrgg/releases/download/v{0}/PYRGG-{0}.exe)", + "Run `PYRGG-{0}.exe`", + "pip install pyrgg=={0}", + "pip3 install pyrgg=={0}"] +CHANGELOG_ITEMS = [ + "## [{0}]", + "https://github.com/sepandhaghighi/pyrgg/compare/v{0}...dev", + "[{0}]:"] +RC_ITEMS = [ + "filevers=({0}, {1}, {2}, {3})", + "prodvers=({0}, {1}, {2}, {3})", + "(u'FileVersion', u'{0}.{1}.{2}.{3}'),", + "(u'ProductVersion', u'{0}, {1}, {2}, {3}')"] +PARAMS_ITEMS = ['PYRGG_VERSION = "{0}"'] +FILES = { + "setup.py": SETUP_ITEMS, + "README.md": README_ITEMS, + "CHANGELOG.md": CHANGELOG_ITEMS, + os.path.join( + "pyrgg", + "params.py"): PARAMS_ITEMS} + +TEST_NUMBER = len(FILES.keys()) + 1 + + +def print_result(failed=False): + """ + Print final result. + + :param failed: failed flag + :type failed: bool + :return: None + """ + message = "Version tag tests " + if not failed: + print("\n" + message + "passed!") + else: + print("\n" + message + "failed!") + print("Passed : " + str(TEST_NUMBER - Failed) + "/" + str(TEST_NUMBER)) + + +if __name__ == "__main__": + for file_name in FILES.keys(): + try: + file_content = codecs.open( + file_name, "r", "utf-8", 'ignore').read() + for test_item in FILES[file_name]: + if file_content.find(test_item.format(VERSION)) == -1: + print("Incorrect version tag in " + file_name) + Failed += 1 + break + except Exception as e: + Failed += 1 + print("Error in " + file_name + "\n" + "Message : " + str(e)) + try: + file_content = codecs.open( + os.path.join( + "otherfile", + "Version.rc"), + "r", + "utf-8", + 'ignore').read() + for test_item in RC_ITEMS: + if file_content.find( + test_item.format( + VERSION_1, + VERSION_2, + VERSION_3, + VERSION_4)) == -1: + print("Incorrect version tag in " + "Version.rc") + Failed += 1 + break + except Exception as e: + Failed += 1 + print("Error in Version.rc" + "\n" + "Message : " + str(e)) + + if Failed == 0: + print_result(False) + sys.exit(0) + else: + print_result(True) + sys.exit(1) diff --git a/pyrgg/__init__.py b/pyrgg/__init__.py index e7107355..fd6a113a 100644 --- a/pyrgg/__init__.py +++ b/pyrgg/__init__.py @@ -1 +1,5 @@ -from .pyrgg import * \ No newline at end of file +# -*- coding: utf-8 -*- +"""Pyrgg modules.""" +from .pyrgg import * +from .params import * +__version__ = PYRGG_VERSION diff --git a/pyrgg/__main__.py b/pyrgg/__main__.py index 8f135a05..d3e41645 100644 --- a/pyrgg/__main__.py +++ b/pyrgg/__main__.py @@ -1,8 +1,30 @@ -from .pyrgg import * +# -*- coding: utf-8 -*- +"""Pyrgg main.""" +from pyrgg.pyrgg import * +from pyrgg.params import * import time import sys import doctest +from art import tprint + +GENERATOR_MENU = { + 1: dimacs_maker, + 2: json_maker, + 3: csv_maker, + 4: json_maker, + 5: wel_maker, + 6: lp_maker, + 7: json_maker, + 8: dl_maker, + 9: tgf_maker} + + def run(): + """ + Run proper converter. + + :return: None + """ first_time = time.perf_counter() input_dict = get_input() file_name = input_dict["file_name"] @@ -12,50 +34,52 @@ def run(): min_edge = input_dict["min_edge"] max_edge = input_dict["max_edge"] sign = input_dict["sign"] + direct = input_dict["direct"] print("Generating . . . ") - if input_dict["output_format"]==1: - edge_number = dimacs_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name+".gr") - elif input_dict["output_format"]==2: - edge_number = json_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".json") - elif input_dict["output_format"]==3 : - edge_number = csv_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".csv") - elif input_dict["output_format"]==4: - edge_number = json_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) + edge_number = GENERATOR_MENU[input_dict["output_format"]]( + file_name, + min_weight, + max_weight, + vertices_number, + min_edge, + max_edge, + sign, + direct) + if input_dict["output_format"] == 4: json_to_yaml(file_name) - filesize(file_name + ".yaml") - elif input_dict["output_format"]==5 : - edge_number = wel_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".wel") - elif input_dict["output_format"]==6: - edge_number = lp_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".lp") - elif input_dict["output_format"] == 7: - edge_number = json_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) + if input_dict["output_format"] == 7: json_to_pickle(file_name) - filesize(file_name + ".p") - elif input_dict["output_format"] == 8: - edge_number=dl_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".dl") - else : - edge_number=tgf_maker(file_name, min_weight, max_weight, vertices_number, min_edge, max_edge, sign) - filesize(file_name + ".tgf") + filesize(file_name + SUFFIX_MENU[input_dict["output_format"]]) second_time = time.perf_counter() elapsed_time = second_time - first_time elapsed_time_format = time_convert(str(elapsed_time)) print("Graph Generated In " + elapsed_time_format) - print("Where --> " + Source_dir) - logger(vertices_number, edge_number, file_name + ".gr", elapsed_time_format) -if __name__=="__main__": - args=sys.argv - if len(args)>1: - if args[1].upper()=="TEST": - doctest.testfile("test.py",verbose=True) + print("Where --> " + SOURCE_DIR) + logger( + vertices_number, + edge_number, + file_name + ".gr", + elapsed_time_format) + + +if __name__ == "__main__": + tprint("Pyrgg", "larry3d") + tprint("v" + PYRGG_VERSION) + description_print() + args = sys.argv + if len(args) > 1: + if args[1].upper() == "TEST": + error_flag = doctest.testfile("test.py", verbose=False)[0] + sys.exit(error_flag) else: print("Bad Input!") print("Test (Run doctest)") print("Without arg --> Normal Run") else: - run() + EXIT_FLAG = False + while not EXIT_FLAG: + run() + INPUTINDEX = str( + input("Press [R] to restart Pyrgg or any other key to exit.")) + if INPUTINDEX.upper() != "R": + EXITFLAG = True diff --git a/pyrgg/params.py b/pyrgg/params.py new file mode 100644 index 00000000..1ec4f21d --- /dev/null +++ b/pyrgg/params.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +"""Pyrgg params.""" +import os + +MENU_ITEMS1 = { + "file_name": "File Name : ", + "output_format": "Graph Format : \nDIMACS(.gr)[1] | JSON(.json)[2] | CSV(.csv)[3] | YAML(.yaml)[4]\n| WEL(.wel)[5] | ASP(.lp)[6] | Pickle(.p)[7] | UCINET DL Format(.dl)[8] | TGF(.tgf)[9]", + "weight": "Weighted[1] or Unweighted[2]"} + +MENU_ITEMS2 = {"vertices": "Vertices Number : ", + "max_weight": "Max Weight : ", + "min_weight": "Min Weight : ", + "min_edge": "Min Edge Number :", + "max_edge": "Max Edge Number :", + "sign": "Signed[1] or Unsigned[2]", + "direct": "Directed[1] or Undirected[2]"} + + +SUFFIX_MENU = { + 1: ".gr", + 2: ".json", + 3: ".csv", + 4: ".yaml", + 5: ".wel", + 6: ".lp", + 7: ".p", + 8: ".dl", + 9: ".tgf"} + + +PYRGG_VERSION = "0.3" + +SOURCE_DIR = os.getcwd() + +PYRGG_LINKS = """ +Webpage : http://pyrgg.shaghighi.ir/ +Repository : https://github.com/sepandhaghighi/pyrgg +Paper : https://doi.org/10.21105/joss.00331 +* If you use Pyrgg in your research, please cite our paper +""" + +PYRGG_DESCRIPTION = ''' +Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various graph file formats +including DIMACS .gr files. Pyrgg has the ability to generate graphs of different sizes and is designed to provide input files +for broad range of graph-based research applications, including but not limited to testing, benchmarking and performance-analysis +of graph processing frameworks. Pyrgg target audiences are computer scientists who study graph algorithms and graph processing frameworks. +''' + + +DIMACS_FIX = """c FILE :{0}.gr +c No. of vertices :{1} +c No. of edges :{2} +c Max. weight :{3} +c Min. weight :{4} +c Min. edge :{5} +c Max. edge :{6} +p sp {1} {2} +""" diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 2b8bd53e..4338805a 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +"""Pyrgg module.""" import random import os import datetime @@ -5,302 +7,604 @@ import yaml import json import pickle +from pyrgg.params import * + +# random_system=random.SystemRandom() +random_system = random + + +def left_justify(words, width): + """ + Left justify words. + + :param words: list of words + :type words : list + :param width: width of each line + :type width: int + :return: left justified words as list + """ + return ' '.join(words).ljust(width) + + +def justify(words, width): + """ + Justify input words. + + :param words: list of words + :type words : list + :param width: width of each line + :type width : int + :return: list of justified words as list + """ + line = [] + col = 0 + for word in words: + if line and col + len(word) > width: + if len(line) == 1: + yield left_justify(line, width) + else: + # After n + 1 spaces are placed between each pair of + # words, there are r spaces left over; these result in + # wider spaces at the left. + n, r = divmod(width - col + 1, len(line) - 1) + narrow = ' ' * (n + 1) + if r == 0: + yield narrow.join(line) + else: + wide = ' ' * (n + 2) + yield wide.join(line[:r] + [narrow.join(line[r:])]) + line, col = [], 0 + line.append(word) + col += len(word) + 1 + if line: + yield left_justify(line, width) + + +def description_print(): + """ + Print justified description for overview in console. + + :return: None + """ + print(PYRGG_LINKS) + line(40) + print("\n") + print("\n".join(justify(PYRGG_DESCRIPTION.split(), 100))) + print("\n") + line(40) + + +def line(num=11, char="#"): + """ + Print line of char. + + :param num: number of character in this line + :type num : int + :param char: character + :type char : str + :return: None + """ + print(char * num) -Source_dir=os.getcwd() -#random_system=random.SystemRandom() -random_system=random def convert_bytes(num): """ - convert num to idiomatic byte unit + Convert num to idiomatic byte unit. + :param num: the input number. - :type num:int + :type num: int :return: str """ for x in ['bytes', 'KB', 'MB', 'GB', 'TB']: if num < 1024.0: return "%3.1f %s" % (num, x) num /= 1024.0 -def filesize(fileaddr): - ''' - This function calculate output file size + + +def filesize(fileaddr): # pragma: no cover + """ + Calculate output file size. + :param fileaddr: file addresses - :type fileaddr:str + :type fileaddr: str :return: file size for print as string - ''' - file_info=os.stat(fileaddr) - file_size= file_info.st_size - print("Graph File Size : "+convert_bytes(file_size)) - -def logger(vertices_number,edge_number,file_name,elapsed_time): - ''' - This function save generated graphs log - :param vertices_number: nubmer of vertices + """ + file_info = os.stat(fileaddr) + file_size = file_info.st_size + print("Graph File Size : " + convert_bytes(file_size)) + + +def logger(vertices_number, edge_number, file_name, elapsed_time): + """ + Save generated graphs log. + + :param vertices_number: number of vertices :type vertices_number:int - :param edge_number: Number of edges - :type edge_number:int; - :param file_name: File Name - :type file_name:str - :param elapsed_time: Elapsed Time - :type elapsed_time : str + :param edge_number: number of edges + :type edge_number: int + :param file_name: file name + :type file_name: str + :param elapsed_time: elapsed time + :type elapsed_time : str :return: None - ''' + """ try: file = open("logfile.log", "a") - file.write(str(datetime.datetime.now())+"\n") - file.write("Filename : "+file_name+"\n") - file.write("Vertices : "+str(vertices_number)+"\n") - file.write("Edges : "+str(edge_number)+"\n") + file.write(str(datetime.datetime.now()) + "\n") + file.write("Filename : " + file_name + "\n") + file.write("Vertices : " + str(vertices_number) + "\n") + file.write("Edges : " + str(edge_number) + "\n") file.write("Elapsed Time : " + str(elapsed_time) + "\n") file.write("-------------------------------\n") file.close() except Exception: print("[Error] Logger Faild!") + def zero_insert(input_string): - ''' - This function get a string as input if input is one digit add a zero + """ + Get a string as input if input is one digit add a zero. + :param input_string: input digit az string - :type input_string:str + :type input_string: str :return: modified output as str - >>> zero_insert("22") - >>> '22' - ''' - if len(input_string)==1: - return "0"+input_string + """ + if len(input_string) == 1: + return "0" + input_string return input_string + def time_convert(input_string): - ''' - This function convert input_string from sec to DD,HH,MM,SS Format + """ + Convert input_string from sec to DD,HH,MM,SS format. + :param input_string: input time string in sec - :type input_string:str - :return: converted time as string - ''' - input_sec=float(input_string) - input_minute=input_sec//60 - input_sec=int(input_sec-input_minute*60) - input_hour=input_minute//60 - input_minute=int(input_minute-input_hour*60) - input_day=int(input_hour//24) - input_hour=int(input_hour-input_day*24) - return zero_insert(str(input_day))+" days, "+zero_insert(str(input_hour))+" hour, "+zero_insert(str(input_minute))+" minutes, "+zero_insert(str(input_sec))+" seconds" + :type input_string: str + :return: converted time as str + """ + input_sec = float(input_string) + input_minute = input_sec // 60 + input_sec = int(input_sec - input_minute * 60) + input_hour = input_minute // 60 + input_minute = int(input_minute - input_hour * 60) + input_day = int(input_hour // 24) + input_hour = int(input_hour - input_day * 24) + return zero_insert(str(input_day)) + " days, " + zero_insert(str(input_hour)) + " hour, " + \ + zero_insert(str(input_minute)) + " minutes, " + zero_insert(str(input_sec)) + " seconds" + + +def input_filter(input_dict): + """ + Filter input data. + + :param input_dict: input dictionary + :type input_dict: dict + :return: filtered data as dict + """ + filtered_dict = input_dict.copy() + if filtered_dict["min_edge"] < 0: + filtered_dict["min_edge"] = -1 * filtered_dict["min_edge"] + if filtered_dict["max_edge"] < 0: + filtered_dict["max_edge"] = -1 * filtered_dict["max_edge"] + if filtered_dict["min_weight"] > filtered_dict["max_weight"]: + temp = filtered_dict["min_weight"] + filtered_dict["min_weight"] = filtered_dict["max_weight"] + filtered_dict["max_weight"] = temp + if filtered_dict["min_edge"] > filtered_dict["max_edge"]: + temp = filtered_dict["min_edge"] + filtered_dict["min_edge"] = filtered_dict["max_edge"] + filtered_dict["max_edge"] = temp + filtered_dict["max_edge"] = min( + filtered_dict["max_edge"], + filtered_dict["vertices"]) + filtered_dict["min_edge"] = min( + filtered_dict["min_edge"], + filtered_dict["vertices"]) + if filtered_dict["sign"] not in [1, 2]: + filtered_dict["sign"] = 2 + if filtered_dict["direct"] not in [1, 2]: + filtered_dict["direct"] = 1 + if filtered_dict["output_format"] not in list(range(1, 10)): + filtered_dict["output_format"] = 1 + return filtered_dict def get_input(input_func=input): - ''' - This function get input from user and return as dictionary - :return: inputs as dictionary - ''' + """ + Get input from user and return as dictionary. + + :param input_func : input function + :type input_func : function object + :return: inputs as dict + """ try: - file_name=input_func("File Name : ") - if file_name+".gr" in os.listdir(): - raise Exception("There is file with this name") - vertices=int(input_func("Vertices Number : ")) - max_weight=int(input_func("Max Weight : ")) - min_weight = int(input_func("Min Weight : ")) - min_edge=int(input_func("Min Edge Number :")) - min_edge=max(0,min_edge) - max_edge=int(input_func("Max Edge Number :")) - max_edge=min(max_edge,vertices) - sign_flag=int(input_func("Signed[1] or Unsigned[2]")) - output_format=int(input_func("Graph Format : \nDIMACS(.gr)[1] | JSON(.json)[2] | CSV(.csv)[3] | YAML(.yaml)[4]\n| WEL(.wel)[5] | ASP(.lp)[6] | Pickle(.p)[7] | UCINET DL Format(.dl)[8] | TGF(.tgf)[9]")) - if sign_flag not in [1,2]: - sign_flag=2 - if output_format not in list(range(1,10)): - output_format=1 - return {"file_name":file_name,"vertices":vertices,"max_weight":max_weight,"min_weight":min_weight,"min_edge":min_edge,"max_edge":max_edge,"sign":sign_flag,"output_format":output_format} + result_dict = { + "file_name": "", + "vertices": 0, + "max_weight": 1, + "min_weight": 1, + "min_edge": 0, + "max_edge": 0, + "sign": 1, + "output_format": 1, + "weight": 1, + "direct": 1} + MENU_ITEMS_KEYS1 = sorted(list(MENU_ITEMS1.keys())) + MENU_ITEMS_KEYS2 = sorted(list(MENU_ITEMS2.keys())) + for item in MENU_ITEMS_KEYS1: + exit_flag = False + while not exit_flag: + try: + if item != "file_name": + result_dict[item] = int(input_func(MENU_ITEMS1[item])) + else: + result_dict[item] = input_func(MENU_ITEMS1[item]) + exit_flag = True + except Exception: + print("[Error] Bad Input!") + + for item in MENU_ITEMS_KEYS2: + exit_flag = False + if result_dict["weight"] != 1 and ( + item == "max_weight" or item == "min_weight"): + continue + while not exit_flag: + try: + result_dict[item] = int(input_func(MENU_ITEMS2[item])) + exit_flag = True + except Exception: + print("[Error] Bad Input!") + result_dict = input_filter(result_dict) + return result_dict except Exception: print("[Error] Bad Input!") sys.exit() + def sign_gen(): - ''' - This function return random sign + """ + Return random sign. + :return: 1 or -1 - ''' - flag=random_system.randint(0,1) - if flag==0: + """ + flag = random_system.randint(0, 1) + if flag == 0: return 1 - else: - return -1 -def branch_gen(random_edge,vertices_number,min_range,max_range,sign): - ''' - This function generate branch and weight vector of each vertex + return -1 + + +def branch_gen( + vertex_index, + random_edge, + min_weight, + max_weight, + sign, + direct, + all_vertices, + used_vertices): + """ + Generate branch and weight vector of each vertex. + + :param vertex_index: origin vertex index + :type vertex_index: int :param random_edge: number of vertex edges - :type random_edge:int - :param vertices_number: number of vertices - :type vertices_number:int - :param min_range: weight min range - :type min_range:int - :param max_range: weight max range - :type max_range:int + :type random_edge: int + :param min_weight: weight min range + :type min_weight: int + :param max_weight: weight max range + :type max_weight: int + :param sign: weight sign flag + :type sign: int + :param direct: directed and undirected graph flag + :type direct: int + :param all_vertices : all vertices list + :type all_vertices : list + :param used_vertices: used vertices dictionary + :type used_vertices: dict :return: branch and weight list - ''' + """ index = 0 branch_list = [] - weight_list=[] - while (index < random_edge): - random_tail = random_system.randint(1, vertices_number + 1) - if sign==2: - random_weight=random_system.randint(min_range,max_range) + weight_list = [] + reference_vertices = all_vertices + if direct == 2 and (vertex_index in used_vertices.keys()): + reference_vertices = list( + set(reference_vertices) - set(used_vertices[vertex_index])) + threhold = min(random_edge, len(reference_vertices)) + while (index < threhold): + random_tail = random_system.choice(reference_vertices) + if direct == 2: + if random_tail in used_vertices.keys(): + used_vertices[random_tail].append(vertex_index) + else: + used_vertices[random_tail] = [vertex_index] + if sign == 2: + random_weight = random_system.randint(min_weight, max_weight) else: - random_weight = sign_gen() * random_system.randint(min_range, max_range) + random_weight = sign_gen() * random_system.randint(min_weight, max_weight) if random_tail not in branch_list: branch_list.append(random_tail) weight_list.append(random_weight) index += 1 - return [branch_list,weight_list] -def edge_gen(vertices_number,min_range,max_range,min_edge,max_edge,sign): - ''' - This function generate each vertex connection number + return [branch_list, weight_list] + + +def edge_gen( + vertices_number, + min_weight, + max_weight, + min_edge, + max_edge, + sign, + direct): + """ + Generate each vertex connection number. + :param vertices_number: number of vertices - :type vertices_number:int - :param min_range: weight min_range - :type min_range:int - :param max_range: weight max_range - :type max_range:int - :return: list of 2 dictionary - ''' - temp=0 - vertices_id=list(range(1,vertices_number+1)) - vertices_edge=[] - weight_list=[] - i=0 - while(i>> from pyrgg import * ->>> import coverage >>> import random +>>> import os >>> import json >>> import yaml >>> import pickle ->>> cov = coverage.Coverage(omit=['*/home/travis/virtualenv/python3.5.3/lib/python3.5/site-packages/yaml/*']) ->>> cov.start() ->>> logger(100,50,"test","2min") +>>> logger(2,2,2,2) +[Error] Logger Faild! +>>> result = input_filter({"file_name": "test","vertices": 5,"max_weight": 1000,"min_weight":455,"min_edge": -45,"max_edge": -11,"sign": 5,"output_format": 19,"direct": 2}) +>>> result == {'output_format': 1, 'min_weight': 455, 'min_edge': 5, 'max_edge': 5, 'file_name': 'test', 'vertices': 5, 'max_weight': 1000, 'sign': 2, "direct": 2} +True +>>> result = input_filter({"file_name": "test2","vertices": 23,"max_weight": 2,"min_weight": 80,"min_edge": 23,"max_edge": 1,"sign": 1,"output_format": 1,"direct": 2}) +>>> result == {'min_weight': 2, 'vertices': 23, 'file_name': 'test2', 'max_edge': 23, 'min_edge': 1, 'max_weight': 80, 'output_format': 1, 'sign': 1,"direct": 2} +True +>>> logger(100,50,'test','2min') >>> convert_bytes(200) '200.0 bytes' >>> convert_bytes(6000) '5.9 KB' >>> convert_bytes(80000) '78.1 KB' ->>> zero_insert("22") +>>> zero_insert('22') '22' ->>> zero_insert("320") +>>> zero_insert('320') '320' ->>> zero_insert("2") +>>> zero_insert('2') '02' >>> zero_insert(22) Traceback (most recent call last): @@ -31,71 +34,75 @@ TypeError: object of type 'int' has no len() >>> time_convert('33') '00 days, 00 hour, 00 minutes, 33 seconds' ->>> time_convert("15000") +>>> time_convert('15000') '00 days, 04 hour, 10 minutes, 00 seconds' ->>> time_convert("sadasdasd") +>>> time_convert('sadasdasd') Traceback (most recent call last): ... ValueError: could not convert string to float: 'sadasdasd' +>>> line(12,"*") +************ >>> random.seed(2) >>> sign_gen() 1 >>> random.seed(11) >>> sign_gen() -1 +>>> used_vertices = {k:[] for k in range(1,41)} +>>> all_vertices = list(range(1, 41)) >>> random.seed(2) ->>> branch_gen(10,40,1,20,1) -[[4, 24, 17, 3, 41, 18, 25, 11, 15, 21], [3, 10, 20, 14, -17, 1, -17, 8, 6, 5]] +>>> branch_gen(1,10,1,20,1,1,all_vertices,used_vertices) +[[4, 24, 17, 3, 26, 29, 2, 21, 34, 12], [3, 10, 20, 14, -18, -2, -15, -14, 18, 8]] >>> random.seed(20) ->>> branch_gen(4,40,1,20,2) -[[10, 41, 21, 11], [9, 4, 19, 1]] +>>> branch_gen(1,4,1,20,2,1,all_vertices,used_vertices) +[[10, 7, 37, 2], [9, 11, 6, 14]] >>> branch_gen(40,1,20,1) Traceback (most recent call last): ... -TypeError: branch_gen() missing 1 required positional argument: 'sign' +TypeError: branch_gen() missing 4 required positional arguments: 'sign', 'direct', 'all_vertices', and 'used_vertices' >>> random.seed(2) ->>> edge_gen(20,0,400,2,10,1) -[{1: [3, 6], 2: [20, 6, 13, 15, 1], 3: [13, 6, 8, 11, 17, 18, 14], 4: [12, 13, 17, 9, 15, 19, 8], 5: [20, 16, 17, 7], 6: [20, 1, 4, 21, 19, 8, 14], 7: [12, 1, 3, 5, 6, 19, 11], 8: [15, 13, 8, 11, 19, 17], 9: [9, 14, 18, 2, 5, 4, 8], 10: [15, 3, 20, 14, 1], 11: [14, 17, 4, 6, 7, 15, 18, 19], 12: [19, 16, 17, 12, 14, 10, 1, 7, 15, 9], 13: [20, 13, 4], 14: [2, 12, 17, 14, 10, 6, 9, 3, 5], 15: [21, 10, 11], 16: [10, 18, 11, 17, 6, 8, 19, 15, 13, 9], 17: [21, 18, 3, 20, 13, 15, 6, 19], 18: [13, 19, 20], 19: [16, 19, 7, 1, 3, 11, 17, 13], 20: [2, 13, 10, 12]}, {1: [184, -128], 2: [297, -326, -278, -18, -238], 3: [-269, 120, 90, 69, -263, 228, -303], 4: [-82, -335, 250, -256, -179, -249, -358], 5: [-395, -155, -159, -262], 6: [174, 381, 294, 139, 349, 30, 29], 7: [127, 58, 20, 376, 197, 126, -15], 8: [135, 242, 338, 12, -249, -73], 9: [-310, 358, 343, -17, 87, -325, 126], 10: [128, 319, -131, -269, 18], 11: [56, 123, 10, 53, 266, -158, -108, 214], 12: [48, -9, 312, -353, 53, 396, -30, 2, 385, 62], 13: [-328, 354, 316], 14: [-148, -72, -368, -348, -118, -305, -356, 36, -34], 15: [65, -118, -88], 16: [79, -49, 366, -86, -360, -183, 238, 304, 201, -129], 17: [-184, -365, 272, 206, 160, -332, 8, -110], 18: [140, 250, 4], 19: [-262, 239, 179, -272, -345, -136, -14, -345], 20: [255, -345, 5, 275]}, 123] +>>> edge_gen(20,0,400,2,10,1,1) +[{1: [3, 6], 2: [20, 6, 13, 15, 1], 3: [13, 6, 8, 11, 17, 18, 14], 4: [12, 13, 17, 9, 15, 19, 8], 5: [20, 16, 17, 7], 6: [20, 1, 4, 2, 8, 17, 14], 7: [12, 1, 3, 5, 6, 19, 11], 8: [15, 13, 8, 11, 19, 17], 9: [9, 14, 18, 2, 5, 4, 8], 10: [15, 3, 20, 14, 1], 11: [14, 17, 4, 6, 7, 15, 18, 19], 12: [19, 16, 17, 12, 14, 10, 1, 7, 15, 9], 13: [20, 13, 4], 14: [2, 12, 17, 14, 10, 6, 9, 3, 5], 15: [2, 13, 11], 16: [10, 18, 11, 17, 6, 8, 19, 15, 13, 9], 17: [16, 11, 8, 13, 15, 6, 19, 4], 18: [9, 20, 7, 1, 3], 19: [15, 20, 13, 5, 16, 10, 12], 20: [19, 10, 5, 18, 9, 11, 13, 7]}, {1: [184, -128], 2: [297, -326, -278, -18, -238], 3: [-269, 120, 90, 69, -263, 228, -303], 4: [-82, -335, 250, -256, -179, -249, -358], 5: [-395, -155, -159, -262], 6: [174, 381, 294, -302, 386, 136, 29], 7: [127, 58, 20, 376, 197, 126, -15], 8: [135, 242, 338, 12, -249, -73], 9: [-310, 358, 343, -17, 87, -325, 126], 10: [128, 319, -131, -269, 18], 11: [56, 123, 10, 53, 266, -158, -108, 214], 12: [48, -9, 312, -353, 53, 396, -30, 2, 385, 62], 13: [-328, 354, 316], 14: [-148, -72, -368, -348, -118, -305, -356, 36, -34], 15: [151, 362, -88], 16: [79, -49, 366, -86, -360, -183, 238, 304, 201, -129], 17: [-280, 389, 206, 160, -332, 8, -110, -285], 18: [250, 4, 179, -272, -345], 19: [-257, -88, -345, 83, -237, 5, 275], 20: [-104, -332, -353, -39, -155, -334, 260, -305]}, 128] >>> random.seed(11) ->>> edge_gen(20,0,100,2,10,2) -[{1: [18, 15, 17, 7, 21, 6, 5, 20, 1], 2: [2, 7, 20], 3: [11, 19, 17, 21, 16, 3, 14, 9, 8], 4: [1, 19, 4, 13, 7, 16], 5: [14, 19, 7, 9, 3, 11, 4, 8], 6: [1, 15, 6], 7: [7, 17, 5, 21, 4, 14, 1, 19, 6, 20], 8: [2, 7, 9], 9: [10, 3, 19, 8, 20, 12, 15], 10: [19, 13, 21, 10, 20, 7, 14, 4, 2], 11: [8, 13, 14, 16, 17, 3], 12: [16, 21, 20, 9, 7], 13: [3, 14], 14: [2, 6, 12, 19, 3], 15: [15, 17, 5, 2], 16: [12, 10, 1, 21, 16, 5, 3, 18, 2], 17: [11, 3, 16, 14], 18: [19, 20, 13, 3, 21, 9, 11, 15, 18], 19: [17, 10, 3, 1, 4, 20, 16, 11, 15, 8], 20: [9, 21, 7, 13, 19, 5, 12, 3]}, {1: [99, 57, 75, 23, 78, 12, 11, 50, 67], 2: [4, 30, 3], 3: [56, 25, 29, 37, 0, 58, 70, 40, 65], 4: [8, 98, 51, 8, 6, 48], 5: [9, 80, 99, 43, 39, 1, 17, 90], 6: [7, 62, 87], 7: [57, 24, 53, 49, 50, 27, 34, 38, 50, 82], 8: [18, 56, 1], 9: [49, 9, 81, 1, 47, 79, 16], 10: [17, 23, 19, 29, 31, 20, 6, 13, 65], 11: [94, 32, 76, 37, 22, 16], 12: [71, 78, 9, 27, 95], 13: [34, 57], 14: [5, 36, 67, 16, 46], 15: [42, 74, 75, 2], 16: [89, 4, 76, 9, 8, 9, 57, 47, 94], 17: [45, 87, 9, 3], 18: [1, 84, 48, 11, 14, 53, 49, 59, 10], 19: [3, 76, 61, 29, 63, 84, 32, 84, 63, 41], 20: [25, 55, 27, 28, 40, 63, 5, 35]}, 129] +>>> edge_gen(20,0,100,2,10,2,1) +[{1: [18, 15, 17, 7, 20, 4, 10, 3, 2], 2: [15, 20, 6, 1, 3, 2, 8, 7], 3: [10, 1, 3, 9, 18], 4: [11, 8, 10, 3, 4, 13], 5: [1, 7], 6: [13, 3, 7, 9, 11, 14, 4, 8, 2], 7: [6, 18, 15, 7, 5, 13, 9, 10, 19], 8: [5, 15], 9: [20, 10], 10: [3, 7, 8], 11: [12, 15, 19, 13, 5, 8, 7], 12: [7, 13, 20, 14, 4, 2, 9, 16, 17, 3], 13: [16, 20, 3, 7, 1], 14: [14, 8, 2, 10, 17, 5], 15: [5, 11, 17, 2, 16, 10, 1], 16: [16, 10, 5], 17: [15, 12, 2], 18: [11, 3, 16, 14], 19: [19, 20, 13, 3, 4, 14, 11, 15, 18], 20: [17, 10, 3, 1, 4, 20, 16, 11, 15, 8]}, {1: [99, 57, 75, 23, 23, 57, 18, 68, 76], 2: [83, 83, 79, 67, 7, 24, 76, 66], 3: [63, 84, 58, 52, 10], 4: [97, 65, 3, 72, 51, 8], 5: [27, 6], 6: [90, 72, 99, 43, 1, 97, 17, 90, 59], 7: [87, 24, 65, 93, 53, 14, 75, 2, 12], 8: [27, 33], 9: [42, 49], 10: [11, 74, 1], 11: [79, 16, 61, 23, 39, 78, 20], 12: [87, 61, 10, 6, 13, 65, 30, 37, 22, 16], 13: [71, 78, 35, 26, 8], 14: [57, 7, 22, 47, 73, 11], 15: [57, 84, 74, 2, 45, 4, 76], 16: [8, 40, 9], 17: [69, 94, 94], 18: [45, 87, 9, 3], 19: [1, 84, 48, 11, 32, 93, 49, 59, 10], 20: [3, 76, 61, 29, 63, 84, 32, 84, 63, 41]}, 119] >>> edge_gen(0,400,2,10,1) Traceback (most recent call last): ... -TypeError: edge_gen() missing 1 required positional argument: 'sign' +TypeError: edge_gen() missing 2 required positional arguments: 'sign' and 'direct' >>> random.seed(2) ->>> dimacs_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> dimacs_maker('testfile', 0, 200, 10, 0, 2, 0, 1) 7 ->>> file=open("testfile.gr","r") +>>> file=open('testfile.gr','r') >>> print(file.read()) c FILE :testfile.gr c No. of vertices :10 -c No. of directed edges :7 +c No. of edges :7 c Max. weight :200 c Min. weight :0 -c Min. edge :0 -c Max. edge :2 +c Min. edge :0 +c Max. edge :2 p sp 10 7 a 4 3 -64 a 5 4 148 -a 5 11 110 -a 6 7 -139 -a 6 8 -9 -a 8 8 -97 -a 9 9 143 +a 5 3 -163 +a 6 9 -139 +a 7 9 -9 +a 9 8 -97 +a 10 9 143 >>> random.seed(4) ->>> dimacs_maker("testfile2",0,50,30,0,4,0) +>>> dimacs_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.gr","r") +>>> file=open('testfile2.gr','r') >>> print(file.read()) c FILE :testfile2.gr c No. of vertices :30 -c No. of directed edges :41 +c No. of edges :41 c Max. weight :50 c Min. weight :0 -c Min. edge :0 -c Max. edge :4 +c Min. edge :0 +c Max. edge :4 p sp 30 41 a 1 10 46 a 2 16 5 @@ -103,7 +110,7 @@ a 2 18 -48 a 4 17 -17 a 5 27 16 -a 6 31 41 +a 6 30 41 a 7 26 -12 a 7 6 -18 a 8 3 -42 @@ -140,18 +147,18 @@ a 27 14 7 >>> random.seed(20) ->>> dimacs_maker("testfile3",10,30,100,0,4,2) -191 ->>> file=open("testfile3.gr","r") +>>> dimacs_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.gr','r') >>> print(file.read()) c FILE :testfile3.gr c No. of vertices :100 -c No. of directed edges :191 +c No. of edges :189 c Max. weight :30 c Min. weight :10 -c Min. edge :0 -c Max. edge :4 -p sp 100 191 +c Min. edge :0 +c Max. edge :4 +p sp 100 189 a 1 34 30 a 3 74 15 a 3 4 23 @@ -188,285 +195,283 @@ a 18 67 16 a 19 23 15 a 19 11 13 -a 19 101 19 -a 21 87 22 -a 21 59 26 -a 23 16 24 -a 24 43 10 -a 24 10 28 -a 24 96 13 -a 24 12 20 -a 25 83 12 -a 25 85 19 -a 28 29 26 -a 29 90 10 -a 29 21 10 -a 29 86 26 -a 29 18 19 -a 30 54 18 -a 32 13 16 -a 32 31 16 -a 32 29 13 -a 33 17 27 -a 33 50 14 -a 35 63 10 -a 35 23 16 -a 35 82 19 -a 36 13 19 -a 36 27 21 -a 36 80 19 -a 37 87 13 -a 39 8 22 -a 39 48 19 -a 40 60 13 -a 40 9 28 -a 40 61 16 -a 42 9 27 -a 42 80 20 -a 42 92 10 -a 42 23 18 -a 43 78 13 -a 43 1 11 -a 44 96 16 -a 45 52 29 -a 45 11 28 -a 45 47 19 -a 45 57 11 -a 46 80 22 -a 47 51 22 -a 47 33 10 -a 47 100 24 -a 47 12 28 -a 48 41 17 -a 48 100 16 -a 48 38 24 -a 49 49 16 -a 49 80 11 -a 50 18 12 -a 50 96 21 -a 53 31 27 -a 53 19 19 -a 53 100 10 -a 54 88 21 -a 55 68 14 -a 55 3 17 -a 56 68 24 -a 56 32 22 -a 56 50 27 -a 57 65 29 -a 57 84 19 -a 58 98 12 -a 58 84 25 -a 58 35 21 -a 58 95 14 -a 59 85 17 -a 59 63 14 -a 59 46 20 -a 60 19 30 -a 60 96 27 -a 60 97 13 -a 60 83 11 -a 61 25 21 -a 61 51 16 -a 61 70 26 -a 61 91 19 -a 62 81 15 -a 62 18 14 -a 62 36 10 -a 63 86 12 -a 63 100 15 -a 63 44 18 -a 63 32 20 -a 65 34 18 -a 67 39 12 -a 68 6 26 -a 68 61 22 -a 68 92 26 -a 70 91 19 -a 71 71 23 -a 71 22 24 -a 71 57 26 -a 71 62 14 -a 72 25 16 -a 73 16 16 -a 73 58 22 -a 74 9 19 -a 74 82 27 -a 74 15 16 -a 75 94 19 -a 76 65 19 -a 77 61 13 -a 77 47 26 -a 77 32 15 -a 78 74 21 -a 78 38 14 -a 78 2 20 -a 78 49 14 -a 79 66 14 -a 79 23 29 -a 80 67 11 -a 80 15 18 -a 80 54 28 -a 80 12 27 -a 81 78 24 -a 82 53 11 -a 82 92 15 -a 82 23 13 -a 83 91 29 -a 83 73 30 -a 83 39 15 -a 84 36 17 -a 87 89 27 -a 87 76 24 -a 87 56 20 -a 87 101 17 -a 88 94 15 -a 88 66 11 -a 88 58 12 -a 88 65 10 -a 89 4 18 -a 89 99 21 -a 90 40 27 -a 90 52 30 -a 92 2 11 -a 92 74 15 -a 93 30 30 -a 95 54 11 -a 95 1 29 -a 95 97 16 -a 96 70 27 -a 96 60 12 -a 96 37 24 -a 97 38 20 -a 97 14 24 -a 97 25 14 -a 97 80 30 -a 100 24 16 -a 100 38 10 +a 19 38 10 +a 20 87 22 +a 20 59 26 +a 22 16 24 +a 23 43 10 +a 23 10 28 +a 23 96 13 +a 23 12 20 +a 24 83 12 +a 24 85 19 +a 27 29 26 +a 28 90 10 +a 28 21 10 +a 28 86 26 +a 28 18 19 +a 29 54 18 +a 31 13 16 +a 31 31 16 +a 31 29 13 +a 32 17 27 +a 32 50 14 +a 34 63 10 +a 34 23 16 +a 34 82 19 +a 35 13 19 +a 35 27 21 +a 35 80 19 +a 36 87 13 +a 38 8 22 +a 38 48 19 +a 39 60 13 +a 39 9 28 +a 39 61 16 +a 41 9 27 +a 41 80 20 +a 41 92 10 +a 41 23 18 +a 42 78 13 +a 42 1 11 +a 43 96 16 +a 44 52 29 +a 44 11 28 +a 44 47 19 +a 44 57 11 +a 45 80 22 +a 46 51 22 +a 46 33 10 +a 46 100 24 +a 46 12 28 +a 47 41 17 +a 47 100 16 +a 47 38 24 +a 48 49 16 +a 48 80 11 +a 49 18 12 +a 49 96 21 +a 52 31 27 +a 52 19 19 +a 52 100 10 +a 53 88 21 +a 54 68 14 +a 54 3 17 +a 55 68 24 +a 55 32 22 +a 55 50 27 +a 56 65 29 +a 56 84 19 +a 57 98 12 +a 57 84 25 +a 57 35 21 +a 57 95 14 +a 58 85 17 +a 58 63 14 +a 58 46 20 +a 59 19 30 +a 59 96 27 +a 59 97 13 +a 59 83 11 +a 60 25 21 +a 60 51 16 +a 60 70 26 +a 60 91 19 +a 61 81 15 +a 61 18 14 +a 61 36 10 +a 62 86 12 +a 62 100 15 +a 62 44 18 +a 62 32 20 +a 64 34 18 +a 66 39 12 +a 67 6 26 +a 67 61 22 +a 67 92 26 +a 69 91 19 +a 70 71 23 +a 70 22 24 +a 70 57 26 +a 70 62 14 +a 71 25 16 +a 72 16 16 +a 72 58 22 +a 73 9 19 +a 73 82 27 +a 73 15 16 +a 74 94 19 +a 75 65 19 +a 76 61 13 +a 76 47 26 +a 76 32 15 +a 77 74 21 +a 77 38 14 +a 77 2 20 +a 77 49 14 +a 78 66 14 +a 78 23 29 +a 79 67 11 +a 79 15 18 +a 79 54 28 +a 79 12 27 +a 80 78 24 +a 81 53 11 +a 81 92 15 +a 81 23 13 +a 82 91 29 +a 82 73 30 +a 82 39 15 +a 83 36 17 +a 86 89 27 +a 86 76 24 +a 86 56 20 +a 86 31 27 +a 87 66 11 +a 88 12 26 +a 88 4 19 +a 88 99 21 +a 89 40 27 +a 89 52 30 +a 91 2 11 +a 91 74 15 +a 92 30 30 +a 94 54 11 +a 94 1 29 +a 94 97 16 +a 95 70 27 +a 95 60 12 +a 95 37 24 +a 96 38 20 +a 96 14 24 +a 96 25 14 +a 96 80 30 +a 99 24 16 +a 99 38 10 ->>> dimacs_maker("testfile", 0, 200, 10, 0,0) +>>> dimacs_maker('testfile', 0, 200, 10, 0,0) Traceback (most recent call last): ... -TypeError: dimacs_maker() missing 1 required positional argument: 'sign' +TypeError: dimacs_maker() missing 2 required positional arguments: 'sign' and 'direct' >>> random.seed(2) ->>> json_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> json_maker('testfile', 0, 200, 10, 0, 2, 0, 1) 7 ->>> file=open("testfile.json","r") +>>> file=open('testfile.json','r') >>> testfile_1=json.load(file) ->>> testfile_1["graph"]["nodes"][1] +>>> testfile_1['graph']['nodes'][1] {'id': '2'} ->>> testfile_1["graph"]["edges"][1]["source"] +>>> testfile_1['graph']['edges'][1]['source'] '5' ->>> testfile_1["graph"]["edges"][1]["target"] +>>> testfile_1['graph']['edges'][1]['target'] '4' ->>> testfile_1["graph"]["edges"][1]["weight"] +>>> testfile_1['graph']['edges'][1]['weight'] '148' ->>> json_to_yaml("testfile") ->>> file=open("testfile.yaml","r") +>>> json_to_yaml('testfile') +>>> file=open('testfile.yaml','r') >>> testfile_1_yaml=yaml.load(file) ->>> testfile_1_yaml["graph"]["edges"][1]["source"] +>>> testfile_1_yaml['graph']['edges'][1]['source'] '5' ->>> testfile_1_yaml["graph"]["edges"][1]["target"] +>>> testfile_1_yaml['graph']['edges'][1]['target'] '4' ->>> testfile_1_yaml["graph"]["edges"][1]["weight"] +>>> testfile_1_yaml['graph']['edges'][1]['weight'] '148' ->>> json_to_pickle("testfile") ->>> testfile_1_p=pickle.load( open( "testfile.p", "rb" ) ) ->>> testfile_1_p["graph"]["edges"][1]["source"] +>>> json_to_pickle('testfile') +>>> testfile_1_p=pickle.load( open( 'testfile.p', 'rb' ) ) +>>> testfile_1_p['graph']['edges'][1]['source'] '5' ->>> testfile_1_p["graph"]["edges"][1]["target"] +>>> testfile_1_p['graph']['edges'][1]['target'] '4' ->>> testfile_1_p["graph"]["edges"][1]["weight"] +>>> testfile_1_p['graph']['edges'][1]['weight'] '148' >>> random.seed(4) ->>> json_maker("testfile2",0,50,30,0,4,0) +>>> json_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.json","r") +>>> file=open('testfile2.json','r') >>> testfile_2=json.load(file) ->>> testfile_2["graph"]["nodes"][1] +>>> testfile_2['graph']['nodes'][1] {'id': '2'} ->>> testfile_2["graph"]["edges"][1]["source"] +>>> testfile_2['graph']['edges'][1]['source'] '2' ->>> testfile_2["graph"]["edges"][1]["target"] +>>> testfile_2['graph']['edges'][1]['target'] '16' ->>> testfile_2["graph"]["edges"][1]["weight"] +>>> testfile_2['graph']['edges'][1]['weight'] '5' ->>> json_to_yaml("testfile2") ->>> file=open("testfile2.yaml","r") +>>> json_to_yaml('testfile2') +>>> file=open('testfile2.yaml','r') >>> testfile_2_yaml=yaml.load(file) ->>> testfile_2_yaml["graph"]["nodes"][1] +>>> testfile_2_yaml['graph']['nodes'][1] {'id': '2'} ->>> testfile_2_yaml["graph"]["edges"][1]["source"] +>>> testfile_2_yaml['graph']['edges'][1]['source'] '2' ->>> testfile_2_yaml["graph"]["edges"][1]["target"] +>>> testfile_2_yaml['graph']['edges'][1]['target'] '16' ->>> testfile_2_yaml["graph"]["edges"][1]["weight"] +>>> testfile_2_yaml['graph']['edges'][1]['weight'] '5' ->>> json_to_pickle("testfile2") ->>> testfile_2_p=pickle.load( open( "testfile2.p", "rb" ) ) ->>> testfile_2_p["graph"]["edges"][1]["source"] +>>> json_to_pickle('testfile2') +>>> testfile_2_p=pickle.load( open( 'testfile2.p', 'rb' ) ) +>>> testfile_2_p['graph']['edges'][1]['source'] '2' ->>> testfile_2_p["graph"]["edges"][1]["target"] +>>> testfile_2_p['graph']['edges'][1]['target'] '16' ->>> testfile_2_p["graph"]["edges"][1]["weight"] +>>> testfile_2_p['graph']['edges'][1]['weight'] '5' >>> random.seed(20) ->>> json_maker("testfile3",10,30,100,0,4,2) -191 ->>> file=open("testfile3.json","r") +>>> json_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.json','r') >>> testfile_3=json.load(file) ->>> testfile_3["graph"]["nodes"][1] +>>> testfile_3['graph']['nodes'][1] {'id': '2'} ->>> testfile_3["graph"]["edges"][1]["source"] +>>> testfile_3['graph']['edges'][1]['source'] '3' ->>> testfile_3["graph"]["edges"][1]["target"] +>>> testfile_3['graph']['edges'][1]['target'] '74' ->>> testfile_3["graph"]["edges"][1]["weight"] +>>> testfile_3['graph']['edges'][1]['weight'] '15' ->>> json_to_yaml("testfile3") ->>> file=open("testfile3.yaml","r") +>>> json_to_yaml('testfile3') +>>> file=open('testfile3.yaml','r') >>> testfile_3_yaml=yaml.load(file) ->>> testfile_3_yaml["graph"]["nodes"][1] +>>> testfile_3_yaml['graph']['nodes'][1] {'id': '2'} ->>> testfile_3_yaml["graph"]["edges"][1]["source"] +>>> testfile_3_yaml['graph']['edges'][1]['source'] '3' ->>> testfile_3_yaml["graph"]["edges"][1]["target"] +>>> testfile_3_yaml['graph']['edges'][1]['target'] '74' ->>> testfile_3_yaml["graph"]["edges"][1]["weight"] +>>> testfile_3_yaml['graph']['edges'][1]['weight'] '15' ->>> json_to_yaml("testfile24") +>>> json_to_yaml('testfile24') [Error] Bad Input File ->>> json_to_pickle("testfile24") +>>> json_to_pickle('testfile24') [Error] Bad Input File ->>> json_maker("testfile", 0, 200, 10, 0, 0) +>>> json_maker('testfile', 0, 200, 10, 0, 0) Traceback (most recent call last): ... -TypeError: json_maker() missing 1 required positional argument: 'sign' ->>> json_to_pickle("testfile3") ->>> testfile_3_p=pickle.load( open( "testfile3.p", "rb" ) ) ->>> testfile_3_p["graph"]["edges"][1]["source"] +TypeError: json_maker() missing 2 required positional arguments: 'sign' and 'direct' +>>> json_to_pickle('testfile3') +>>> testfile_3_p=pickle.load( open( 'testfile3.p', 'rb' ) ) +>>> testfile_3_p['graph']['edges'][1]['source'] '3' ->>> testfile_3_p["graph"]["edges"][1]["target"] +>>> testfile_3_p['graph']['edges'][1]['target'] '74' ->>> testfile_3_p["graph"]["edges"][1]["weight"] +>>> testfile_3_p['graph']['edges'][1]['weight'] '15' >>> random.seed(2) ->>> csv_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> csv_maker('testfile', 0, 200, 10, 0, 2, 0, 1) 7 ->>> file=open("testfile.csv","r") +>>> file=open('testfile.csv','r') >>> print(file.read()) 4,3,-64 5,4,148 -5,11,110 -6,7,-139 -6,8,-9 -8,8,-97 -9,9,143 +5,3,-163 +6,9,-139 +7,9,-9 +9,8,-97 +10,9,143 >>> random.seed(4) ->>> csv_maker("testfile2",0,50,30,0,4,0) +>>> csv_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.csv","r") +>>> file=open('testfile2.csv','r') >>> print(file.read()) 1,10,46 2,16,5 @@ -474,7 +479,7 @@ 2,18,-48 4,17,-17 5,27,16 -6,31,41 +6,30,41 7,26,-12 7,6,-18 8,3,-42 @@ -511,9 +516,9 @@ 27,14,7 >>> random.seed(20) ->>> csv_maker("testfile3",10,30,100,0,4,2) -191 ->>> file=open("testfile3.csv","r") +>>> csv_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.csv','r') >>> print(file.read()) 1,34,30 3,74,15 @@ -551,183 +556,181 @@ 18,67,16 19,23,15 19,11,13 -19,101,19 -21,87,22 -21,59,26 -23,16,24 -24,43,10 -24,10,28 -24,96,13 -24,12,20 -25,83,12 -25,85,19 -28,29,26 -29,90,10 -29,21,10 -29,86,26 -29,18,19 -30,54,18 -32,13,16 -32,31,16 -32,29,13 -33,17,27 -33,50,14 -35,63,10 -35,23,16 -35,82,19 -36,13,19 -36,27,21 -36,80,19 -37,87,13 -39,8,22 -39,48,19 -40,60,13 -40,9,28 -40,61,16 -42,9,27 -42,80,20 -42,92,10 -42,23,18 -43,78,13 -43,1,11 -44,96,16 -45,52,29 -45,11,28 -45,47,19 -45,57,11 -46,80,22 -47,51,22 -47,33,10 -47,100,24 -47,12,28 -48,41,17 -48,100,16 -48,38,24 -49,49,16 -49,80,11 -50,18,12 -50,96,21 -53,31,27 -53,19,19 -53,100,10 -54,88,21 -55,68,14 -55,3,17 -56,68,24 -56,32,22 -56,50,27 -57,65,29 -57,84,19 -58,98,12 -58,84,25 -58,35,21 -58,95,14 -59,85,17 -59,63,14 -59,46,20 -60,19,30 -60,96,27 -60,97,13 -60,83,11 -61,25,21 -61,51,16 -61,70,26 -61,91,19 -62,81,15 -62,18,14 -62,36,10 -63,86,12 -63,100,15 -63,44,18 -63,32,20 -65,34,18 -67,39,12 -68,6,26 -68,61,22 -68,92,26 -70,91,19 -71,71,23 -71,22,24 -71,57,26 -71,62,14 -72,25,16 -73,16,16 -73,58,22 -74,9,19 -74,82,27 -74,15,16 -75,94,19 -76,65,19 -77,61,13 -77,47,26 -77,32,15 -78,74,21 -78,38,14 -78,2,20 -78,49,14 -79,66,14 -79,23,29 -80,67,11 -80,15,18 -80,54,28 -80,12,27 -81,78,24 -82,53,11 -82,92,15 -82,23,13 -83,91,29 -83,73,30 -83,39,15 -84,36,17 -87,89,27 -87,76,24 -87,56,20 -87,101,17 -88,94,15 -88,66,11 -88,58,12 -88,65,10 -89,4,18 -89,99,21 -90,40,27 -90,52,30 -92,2,11 -92,74,15 -93,30,30 -95,54,11 -95,1,29 -95,97,16 -96,70,27 -96,60,12 -96,37,24 -97,38,20 -97,14,24 -97,25,14 -97,80,30 -100,24,16 -100,38,10 +19,38,10 +20,87,22 +20,59,26 +22,16,24 +23,43,10 +23,10,28 +23,96,13 +23,12,20 +24,83,12 +24,85,19 +27,29,26 +28,90,10 +28,21,10 +28,86,26 +28,18,19 +29,54,18 +31,13,16 +31,31,16 +31,29,13 +32,17,27 +32,50,14 +34,63,10 +34,23,16 +34,82,19 +35,13,19 +35,27,21 +35,80,19 +36,87,13 +38,8,22 +38,48,19 +39,60,13 +39,9,28 +39,61,16 +41,9,27 +41,80,20 +41,92,10 +41,23,18 +42,78,13 +42,1,11 +43,96,16 +44,52,29 +44,11,28 +44,47,19 +44,57,11 +45,80,22 +46,51,22 +46,33,10 +46,100,24 +46,12,28 +47,41,17 +47,100,16 +47,38,24 +48,49,16 +48,80,11 +49,18,12 +49,96,21 +52,31,27 +52,19,19 +52,100,10 +53,88,21 +54,68,14 +54,3,17 +55,68,24 +55,32,22 +55,50,27 +56,65,29 +56,84,19 +57,98,12 +57,84,25 +57,35,21 +57,95,14 +58,85,17 +58,63,14 +58,46,20 +59,19,30 +59,96,27 +59,97,13 +59,83,11 +60,25,21 +60,51,16 +60,70,26 +60,91,19 +61,81,15 +61,18,14 +61,36,10 +62,86,12 +62,100,15 +62,44,18 +62,32,20 +64,34,18 +66,39,12 +67,6,26 +67,61,22 +67,92,26 +69,91,19 +70,71,23 +70,22,24 +70,57,26 +70,62,14 +71,25,16 +72,16,16 +72,58,22 +73,9,19 +73,82,27 +73,15,16 +74,94,19 +75,65,19 +76,61,13 +76,47,26 +76,32,15 +77,74,21 +77,38,14 +77,2,20 +77,49,14 +78,66,14 +78,23,29 +79,67,11 +79,15,18 +79,54,28 +79,12,27 +80,78,24 +81,53,11 +81,92,15 +81,23,13 +82,91,29 +82,73,30 +82,39,15 +83,36,17 +86,89,27 +86,76,24 +86,56,20 +86,31,27 +87,66,11 +88,12,26 +88,4,19 +88,99,21 +89,40,27 +89,52,30 +91,2,11 +91,74,15 +92,30,30 +94,54,11 +94,1,29 +94,97,16 +95,70,27 +95,60,12 +95,37,24 +96,38,20 +96,14,24 +96,25,14 +96,80,30 +99,24,16 +99,38,10 ->>> csv_maker("testfile", 0, 200, 10, 0,0) +>>> csv_maker('testfile', 0, 200, 10, 0,0) Traceback (most recent call last): ... -TypeError: csv_maker() missing 1 required positional argument: 'sign' +TypeError: csv_maker() missing 2 required positional arguments: 'sign' and 'direct' >>> random.seed(2) ->>> wel_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> wel_maker('testfile', 0, 200, 10, 0, 2, 0,1) 7 ->>> file=open("testfile.wel","r") +>>> file=open('testfile.wel','r') >>> print(file.read()) 4 3 -64 5 4 148 -5 11 110 -6 7 -139 -6 8 -9 -8 8 -97 -9 9 143 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 >>> random.seed(4) ->>> wel_maker("testfile2",0,50,30,0,4,0) +>>> wel_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.wel","r") +>>> file=open('testfile2.wel','r') >>> print(file.read()) 1 10 46 2 16 5 @@ -735,7 +738,7 @@ 2 18 -48 4 17 -17 5 27 16 -6 31 41 +6 30 41 7 26 -12 7 6 -18 8 3 -42 @@ -772,9 +775,9 @@ 27 14 7 >>> random.seed(20) ->>> wel_maker("testfile3",10,30,100,0,4,2) -191 ->>> file=open("testfile3.wel","r") +>>> wel_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.wel','r') >>> print(file.read()) 1 34 30 3 74 15 @@ -812,170 +815,168 @@ 18 67 16 19 23 15 19 11 13 -19 101 19 -21 87 22 -21 59 26 -23 16 24 -24 43 10 -24 10 28 -24 96 13 -24 12 20 -25 83 12 -25 85 19 -28 29 26 -29 90 10 -29 21 10 -29 86 26 -29 18 19 -30 54 18 -32 13 16 -32 31 16 -32 29 13 -33 17 27 -33 50 14 -35 63 10 -35 23 16 -35 82 19 -36 13 19 -36 27 21 -36 80 19 -37 87 13 -39 8 22 -39 48 19 -40 60 13 -40 9 28 -40 61 16 -42 9 27 -42 80 20 -42 92 10 -42 23 18 -43 78 13 -43 1 11 -44 96 16 -45 52 29 -45 11 28 -45 47 19 -45 57 11 -46 80 22 -47 51 22 -47 33 10 -47 100 24 -47 12 28 -48 41 17 -48 100 16 -48 38 24 -49 49 16 -49 80 11 -50 18 12 -50 96 21 -53 31 27 -53 19 19 -53 100 10 -54 88 21 -55 68 14 -55 3 17 -56 68 24 -56 32 22 -56 50 27 -57 65 29 -57 84 19 -58 98 12 -58 84 25 -58 35 21 -58 95 14 -59 85 17 -59 63 14 -59 46 20 -60 19 30 -60 96 27 -60 97 13 -60 83 11 -61 25 21 -61 51 16 -61 70 26 -61 91 19 -62 81 15 -62 18 14 -62 36 10 -63 86 12 -63 100 15 -63 44 18 -63 32 20 -65 34 18 -67 39 12 -68 6 26 -68 61 22 -68 92 26 -70 91 19 -71 71 23 -71 22 24 -71 57 26 -71 62 14 -72 25 16 -73 16 16 -73 58 22 -74 9 19 -74 82 27 -74 15 16 -75 94 19 -76 65 19 -77 61 13 -77 47 26 -77 32 15 -78 74 21 -78 38 14 -78 2 20 -78 49 14 -79 66 14 -79 23 29 -80 67 11 -80 15 18 -80 54 28 -80 12 27 -81 78 24 -82 53 11 -82 92 15 -82 23 13 -83 91 29 -83 73 30 -83 39 15 -84 36 17 -87 89 27 -87 76 24 -87 56 20 -87 101 17 -88 94 15 -88 66 11 -88 58 12 -88 65 10 -89 4 18 -89 99 21 -90 40 27 -90 52 30 -92 2 11 -92 74 15 -93 30 30 -95 54 11 -95 1 29 -95 97 16 -96 70 27 -96 60 12 -96 37 24 -97 38 20 -97 14 24 -97 25 14 -97 80 30 -100 24 16 -100 38 10 +19 38 10 +20 87 22 +20 59 26 +22 16 24 +23 43 10 +23 10 28 +23 96 13 +23 12 20 +24 83 12 +24 85 19 +27 29 26 +28 90 10 +28 21 10 +28 86 26 +28 18 19 +29 54 18 +31 13 16 +31 31 16 +31 29 13 +32 17 27 +32 50 14 +34 63 10 +34 23 16 +34 82 19 +35 13 19 +35 27 21 +35 80 19 +36 87 13 +38 8 22 +38 48 19 +39 60 13 +39 9 28 +39 61 16 +41 9 27 +41 80 20 +41 92 10 +41 23 18 +42 78 13 +42 1 11 +43 96 16 +44 52 29 +44 11 28 +44 47 19 +44 57 11 +45 80 22 +46 51 22 +46 33 10 +46 100 24 +46 12 28 +47 41 17 +47 100 16 +47 38 24 +48 49 16 +48 80 11 +49 18 12 +49 96 21 +52 31 27 +52 19 19 +52 100 10 +53 88 21 +54 68 14 +54 3 17 +55 68 24 +55 32 22 +55 50 27 +56 65 29 +56 84 19 +57 98 12 +57 84 25 +57 35 21 +57 95 14 +58 85 17 +58 63 14 +58 46 20 +59 19 30 +59 96 27 +59 97 13 +59 83 11 +60 25 21 +60 51 16 +60 70 26 +60 91 19 +61 81 15 +61 18 14 +61 36 10 +62 86 12 +62 100 15 +62 44 18 +62 32 20 +64 34 18 +66 39 12 +67 6 26 +67 61 22 +67 92 26 +69 91 19 +70 71 23 +70 22 24 +70 57 26 +70 62 14 +71 25 16 +72 16 16 +72 58 22 +73 9 19 +73 82 27 +73 15 16 +74 94 19 +75 65 19 +76 61 13 +76 47 26 +76 32 15 +77 74 21 +77 38 14 +77 2 20 +77 49 14 +78 66 14 +78 23 29 +79 67 11 +79 15 18 +79 54 28 +79 12 27 +80 78 24 +81 53 11 +81 92 15 +81 23 13 +82 91 29 +82 73 30 +82 39 15 +83 36 17 +86 89 27 +86 76 24 +86 56 20 +86 31 27 +87 66 11 +88 12 26 +88 4 19 +88 99 21 +89 40 27 +89 52 30 +91 2 11 +91 74 15 +92 30 30 +94 54 11 +94 1 29 +94 97 16 +95 70 27 +95 60 12 +95 37 24 +96 38 20 +96 14 24 +96 25 14 +96 80 30 +99 24 16 +99 38 10 ->>> wel_maker("testfile", 0, 200, 10, 0,0) +>>> wel_maker('testfile', 0, 200, 10, 0,0) Traceback (most recent call last): ... -TypeError: wel_maker() missing 1 required positional argument: 'sign' +TypeError: wel_maker() missing 2 required positional arguments: 'sign' and 'direct' >>> random.seed(2) ->>> lp_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> lp_maker('testfile', 0, 200, 10, 0, 2, 0,1) 7 ->>> file=open("testfile.lp","r") +>>> file=open('testfile.lp','r') >>> print(file.read()) node(1). node(2). @@ -989,16 +990,16 @@ node(10). edge(4,3,-64). edge(5,4,148). -edge(5,11,110). -edge(6,7,-139). -edge(6,8,-9). -edge(8,8,-97). -edge(9,9,143). +edge(5,3,-163). +edge(6,9,-139). +edge(7,9,-9). +edge(9,8,-97). +edge(10,9,143). >>> random.seed(4) ->>> lp_maker("testfile2",0,50,30,0,4,0) +>>> lp_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.lp","r") +>>> file=open('testfile2.lp','r') >>> print(file.read()) node(1). node(2). @@ -1036,7 +1037,7 @@ edge(2,18,-48). edge(4,17,-17). edge(5,27,16). -edge(6,31,41). +edge(6,30,41). edge(7,26,-12). edge(7,6,-18). edge(8,3,-42). @@ -1073,26 +1074,26 @@ edge(27,14,7). >>> input_dic=get_input(input_func=print_test) ->>> input_dic["sign"] +>>> input_dic['sign'] 2 >>> input_dic['vertices'] -2 +18 >>> input_dic['min_edge'] -2 +17 >>> input_dic['min_weight'] -2 +1 >>> input_dic['output_format'] -2 +1 >>> input_dic['max_weight'] -2 +1 >>> input_dic['file_name'] -'2' +'12' >>> input_dic['max_edge'] -2 +17 >>> random.seed(2) ->>> tgf_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> tgf_maker('testfile', 0, 200, 10, 0, 2, 0, 1) 7 ->>> file=open("testfile.tgf","r") +>>> file=open('testfile.tgf','r') >>> print(file.read()) 1 2 @@ -1107,16 +1108,16 @@ # 4 3 -64 5 4 148 -5 11 110 -6 7 -139 -6 8 -9 -8 8 -97 -9 9 143 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 >>> random.seed(4) ->>> tgf_maker("testfile2",0,50,30,0,4,0) +>>> tgf_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.tgf","r") +>>> file=open('testfile2.tgf','r') >>> print(file.read()) 1 2 @@ -1155,7 +1156,7 @@ 2 18 -48 4 17 -17 5 27 16 -6 31 41 +6 30 41 7 26 -12 7 6 -18 8 3 -42 @@ -1192,9 +1193,9 @@ 27 14 7 >>> random.seed(2) ->>> dl_maker("testfile", 0, 200, 10, 0, 2, 0) +>>> dl_maker('testfile', 0, 200, 10, 0, 2, 0,1) 7 ->>> file=open("testfile.dl","r") +>>> file=open('testfile.dl','r') >>> print(file.read()) dl format=edgelist1 @@ -1202,16 +1203,16 @@ data: 4 3 -64 5 4 148 -5 11 110 -6 7 -139 -6 8 -9 -8 8 -97 -9 9 143 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 >>> random.seed(4) ->>> dl_maker("testfile2",0,50,30,0,4,0) +>>> dl_maker('testfile2',0,50,30,0,4,0,1) 41 ->>> file=open("testfile2.dl","r") +>>> file=open('testfile2.dl','r') >>> print(file.read()) dl format=edgelist1 @@ -1223,7 +1224,7 @@ 2 18 -48 4 17 -17 5 27 16 -6 31 41 +6 30 41 7 26 -12 7 6 -18 8 3 -42 @@ -1259,55 +1260,31 @@ 26 19 28 27 14 7 ->>> filesize("testfile.csv") -Graph File Size : 64.0 bytes ->>> filesize("testfile.dl") -Graph File Size : 99.0 bytes ->>> filesize("testfile.gr") -Graph File Size : 294.0 bytes ->>> filesize("testfile.json") -Graph File Size : 858.0 bytes ->>> filesize("testfile.lp") -Graph File Size : 214.0 bytes ->>> filesize("testfile.p") -Graph File Size : 421.0 bytes ->>> filesize("testfile.tgf") -Graph File Size : 98.0 bytes ->>> filesize("testfile.wel") -Graph File Size : 64.0 bytes ->>> filesize("testfile.yaml") -Graph File Size : 531.0 bytes ->>> filesize("testfile2.csv") -Graph File Size : 401.0 bytes ->>> filesize("testfile2.dl") -Graph File Size : 436.0 bytes ->>> filesize("testfile2.gr") -Graph File Size : 701.0 bytes ->>> filesize("testfile2.json") -Graph File Size : 3.9 KB ->>> filesize("testfile2.lp") -Graph File Size : 1009.0 bytes ->>> filesize("testfile2.p") -Graph File Size : 1.9 KB ->>> filesize("testfile2.tgf") -Graph File Size : 515.0 bytes ->>> filesize("testfile2.wel") -Graph File Size : 401.0 bytes ->>> filesize("testfile2.yaml") -Graph File Size : 2.6 KB ->>> filesize("testfile3.csv") -Graph File Size : 1.8 KB ->>> filesize("testfile3.gr") -Graph File Size : 2.4 KB ->>> filesize("testfile3.json") -Graph File Size : 16.8 KB ->>> filesize("testfile3.p") -Graph File Size : 10.8 KB ->>> filesize("testfile3.wel") -Graph File Size : 1.8 KB ->>> filesize("testfile3.yaml") -Graph File Size : 11.4 KB ->>> cov.stop() ->>> cov.save() +>>> file.close() +>>> os.remove('testfile.csv') +>>> os.remove('testfile.dl') +>>> os.remove('testfile.gr') +>>> os.remove('testfile.json') +>>> os.remove('testfile.lp') +>>> os.remove('testfile.p') +>>> os.remove('testfile.tgf') +>>> os.remove('testfile.wel') +>>> os.remove('testfile.yaml') +>>> os.remove('testfile2.csv') +>>> os.remove('testfile2.dl') +>>> os.remove('testfile2.gr') +>>> os.remove('testfile2.json') +>>> os.remove('testfile2.lp') +>>> os.remove('testfile2.p') +>>> os.remove('testfile2.tgf') +>>> os.remove('testfile2.wel') +>>> os.remove('testfile2.yaml') +>>> os.remove('testfile3.csv') +>>> os.remove('testfile3.gr') +>>> os.remove('testfile3.json') +>>> os.remove('testfile3.p') +>>> os.remove('testfile3.wel') +>>> os.remove('testfile3.yaml') +>>> os.remove('logfile.log') -''' \ No newline at end of file +""" diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..075adf53 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +# content of pytest.ini +[pytest] +addopts = --doctest-modules +doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 642569aa..379430a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ -pyyaml -codecov - - +pyyaml>=3.12 +art>=0.7 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..7c2b2874 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 \ No newline at end of file diff --git a/setup.py b/setup.py index b31c3776..761975f9 100644 --- a/setup.py +++ b/setup.py @@ -1,25 +1,71 @@ -from distutils.core import setup -setup( - name = 'pyrgg', - packages = ['pyrgg'], - version = '0.2', - description = 'Python Random Graph Generator', - long_description='''Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various +# -*- coding: utf-8 -*- +"""Setup module.""" +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + + +def get_requires(): + """Read requirements.txt.""" + requirements = open("requirements.txt", "r").read() + return list(filter(lambda x: x != "", requirements.split())) + + +def read_description(): + """Read README.md and CHANGELOG.md.""" + try: + with open("README.md") as r: + description = "\n" + description += r.read() + with open("CHANGELOG.md") as c: + description += "\n" + description += c.read() + return description + except Exception: + return '''Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various graph file formats including DIMACS .gr files. Pyrgg has the ability to generate graphs of different sizes and is designed to provide input files for broad range of graph-based research applications, including but not limited to testing, benchmarking and performance-analysis of graph processing frameworks. - Pyrgg target audiences are computer scientists who study graph algorithms and graph processing frameworks.''', - author = 'Sepand Haghighi', - author_email = 'sepand@qpage.ir', - url = 'https://github.com/sepandhaghighi/pyrgg', - download_url = 'https://github.com/sepandhaghighi/pyrgg/tarball/v0.2', - keywords = ['random', 'graph', 'python3','python','generator',"graph-process","generator", - "moduland","DIMACS","JSON","YAML","Pickle","CSV","WEL","ASP","TGF","UCINET", - ], - install_requires=[ - 'pyyaml', - 'codecov', - ], - classifiers = [], - license='MIT', + Pyrgg target audiences are computer scientists who study graph algorithms and graph processing frameworks.''' + + +setup( + name='pyrgg', + packages=['pyrgg'], + version='0.3', + description='Python Random Graph Generator', + long_description=read_description(), + long_description_content_type='text/markdown', + author='Sepand Haghighi', + author_email='sepand@qpage.ir', + url='https://github.com/sepandhaghighi/pyrgg', + download_url='https://github.com/sepandhaghighi/pyrgg/tarball/v0.3', + keywords='random graph python3 python generator graph-process generator DIMACS JSON YAML Pickle CSV WEL ASP TGF UCINET', + install_requires=get_requires(), + python_requires='>=3.4', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Natural Language :: English', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Intended Audience :: Developers', + 'Intended Audience :: Education', + 'Intended Audience :: End Users/Desktop', + 'Intended Audience :: Manufacturing', + 'Intended Audience :: Science/Research', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Education', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Scientific/Engineering :: Human Machine Interfaces', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Scientific/Engineering :: Physics', + ], + license='MIT', ) diff --git a/test/test.py b/test/test.py new file mode 100644 index 00000000..63541cc0 --- /dev/null +++ b/test/test.py @@ -0,0 +1,1307 @@ +# -*- coding: utf-8 -*- +""" +>>> from pyrgg import * +>>> import random +>>> import os +>>> import json +>>> import yaml +>>> import pickle +>>> logger(2,2,2,2) +[Error] Logger Faild! +>>> description_print() +Webpage : http://pyrgg.shaghighi.ir/ +Repository : https://github.com/sepandhaghighi/pyrgg +Paper : https://doi.org/10.21105/joss.00331 +* If you use Pyrgg in your research, please cite our paper + +######################################## + + +Pyrgg is an easy-to-use synthetic random graph generator written in Python which supports various +graph file formats including DIMACS .gr files. Pyrgg has the ability to generate graphs of different +sizes and is designed to provide input files for broad range of graph-based research applications, +including but not limited to testing, benchmarking and performance-analysis of graph processing +frameworks. Pyrgg target audiences are computer scientists who study graph algorithms and graph +processing frameworks. + + +######################################## +>>> result = input_filter({"file_name": "test","vertices": 5,"max_weight": 1000,"min_weight":455,"min_edge": -45,"max_edge": -11,"sign": 5,"output_format": 19, "direct": 2}) +>>> result == {'output_format': 1, 'min_weight': 455, 'min_edge': 5, 'max_edge': 5, 'file_name': 'test', 'vertices': 5, 'max_weight': 1000, 'sign': 2, "direct": 2} +True +>>> result = input_filter({"file_name": "test2","vertices": 23,"max_weight": 2,"min_weight": 80,"min_edge": 23,"max_edge": 1,"sign": 1,"output_format": 1, "direct": 2}) +>>> result == {'min_weight': 2, 'vertices': 23, 'file_name': 'test2', 'max_edge': 23, 'min_edge': 1, 'max_weight': 80, 'output_format': 1, 'sign': 1, "direct": 2} +True +>>> logger(100,50,'test','2min') +>>> convert_bytes(200) +'200.0 bytes' +>>> convert_bytes(6000) +'5.9 KB' +>>> convert_bytes(80000) +'78.1 KB' +>>> zero_insert('22') +'22' +>>> zero_insert('320') +'320' +>>> zero_insert('2') +'02' +>>> zero_insert(22) +Traceback (most recent call last): + ... +TypeError: object of type 'int' has no len() +>>> time_convert('33') +'00 days, 00 hour, 00 minutes, 33 seconds' +>>> time_convert('15000') +'00 days, 04 hour, 10 minutes, 00 seconds' +>>> time_convert('sadasdasd') +Traceback (most recent call last): + ... +ValueError: could not convert string to float: 'sadasdasd' +>>> line(12,"*") +************ +>>> random.seed(2) +>>> sign_gen() +1 +>>> random.seed(11) +>>> sign_gen() +-1 +>>> used_vertices = {k:[] for k in range(1,41)} +>>> all_vertices = list(range(1, 41)) +>>> random.seed(2) +>>> branch_gen(1,10,1,20,1,1,all_vertices ,used_vertices) +[[4, 24, 17, 3, 26, 29, 2, 21, 34, 12], [3, 10, 20, 14, -18, -2, -15, -14, 18, 8]] +>>> random.seed(20) +>>> branch_gen(1,4,1,20,2,1,all_vertices,used_vertices) +[[10, 7, 37, 2], [9, 11, 6, 14]] +>>> branch_gen(40,1,20,1) +Traceback (most recent call last): + ... +TypeError: branch_gen() missing 1 required positional argument: 'sign' +>>> random.seed(2) +>>> edge_gen(20,0,400,2,10,1,1) +[{1: [3, 6], 2: [20, 6, 13, 15, 1], 3: [13, 6, 8, 11, 17, 18, 14], 4: [12, 13, 17, 9, 15, 19, 8], 5: [20, 16, 17, 7], 6: [20, 1, 4, 2, 8, 17, 14], 7: [12, 1, 3, 5, 6, 19, 11], 8: [15, 13, 8, 11, 19, 17], 9: [9, 14, 18, 2, 5, 4, 8], 10: [15, 3, 20, 14, 1], 11: [14, 17, 4, 6, 7, 15, 18, 19], 12: [19, 16, 17, 12, 14, 10, 1, 7, 15, 9], 13: [20, 13, 4], 14: [2, 12, 17, 14, 10, 6, 9, 3, 5], 15: [2, 13, 11], 16: [10, 18, 11, 17, 6, 8, 19, 15, 13, 9], 17: [16, 11, 8, 13, 15, 6, 19, 4], 18: [9, 20, 7, 1, 3], 19: [15, 20, 13, 5, 16, 10, 12], 20: [19, 10, 5, 18, 9, 11, 13, 7]}, {1: [184, -128], 2: [297, -326, -278, -18, -238], 3: [-269, 120, 90, 69, -263, 228, -303], 4: [-82, -335, 250, -256, -179, -249, -358], 5: [-395, -155, -159, -262], 6: [174, 381, 294, -302, 386, 136, 29], 7: [127, 58, 20, 376, 197, 126, -15], 8: [135, 242, 338, 12, -249, -73], 9: [-310, 358, 343, -17, 87, -325, 126], 10: [128, 319, -131, -269, 18], 11: [56, 123, 10, 53, 266, -158, -108, 214], 12: [48, -9, 312, -353, 53, 396, -30, 2, 385, 62], 13: [-328, 354, 316], 14: [-148, -72, -368, -348, -118, -305, -356, 36, -34], 15: [151, 362, -88], 16: [79, -49, 366, -86, -360, -183, 238, 304, 201, -129], 17: [-280, 389, 206, 160, -332, 8, -110, -285], 18: [250, 4, 179, -272, -345], 19: [-257, -88, -345, 83, -237, 5, 275], 20: [-104, -332, -353, -39, -155, -334, 260, -305]}, 128] +>>> random.seed(11) +>>> edge_gen(20,0,100,2,10,2,1) +[{1: [18, 15, 17, 7, 20, 4, 10, 3, 2], 2: [15, 20, 6, 1, 3, 2, 8, 7], 3: [10, 1, 3, 9, 18], 4: [11, 8, 10, 3, 4, 13], 5: [1, 7], 6: [13, 3, 7, 9, 11, 14, 4, 8, 2], 7: [6, 18, 15, 7, 5, 13, 9, 10, 19], 8: [5, 15], 9: [20, 10], 10: [3, 7, 8], 11: [12, 15, 19, 13, 5, 8, 7], 12: [7, 13, 20, 14, 4, 2, 9, 16, 17, 3], 13: [16, 20, 3, 7, 1], 14: [14, 8, 2, 10, 17, 5], 15: [5, 11, 17, 2, 16, 10, 1], 16: [16, 10, 5], 17: [15, 12, 2], 18: [11, 3, 16, 14], 19: [19, 20, 13, 3, 4, 14, 11, 15, 18], 20: [17, 10, 3, 1, 4, 20, 16, 11, 15, 8]}, {1: [99, 57, 75, 23, 23, 57, 18, 68, 76], 2: [83, 83, 79, 67, 7, 24, 76, 66], 3: [63, 84, 58, 52, 10], 4: [97, 65, 3, 72, 51, 8], 5: [27, 6], 6: [90, 72, 99, 43, 1, 97, 17, 90, 59], 7: [87, 24, 65, 93, 53, 14, 75, 2, 12], 8: [27, 33], 9: [42, 49], 10: [11, 74, 1], 11: [79, 16, 61, 23, 39, 78, 20], 12: [87, 61, 10, 6, 13, 65, 30, 37, 22, 16], 13: [71, 78, 35, 26, 8], 14: [57, 7, 22, 47, 73, 11], 15: [57, 84, 74, 2, 45, 4, 76], 16: [8, 40, 9], 17: [69, 94, 94], 18: [45, 87, 9, 3], 19: [1, 84, 48, 11, 32, 93, 49, 59, 10], 20: [3, 76, 61, 29, 63, 84, 32, 84, 63, 41]}, 119] +>>> edge_gen(0,400,2,10,1) +Traceback (most recent call last): + ... +TypeError: edge_gen() missing 1 required positional argument: 'sign' +>>> random.seed(2) +>>> dimacs_maker('testfile', 0, 200, 10, 0, 2, 0, 1) +7 +>>> file=open('testfile.gr','r') +>>> print(file.read()) +c FILE :testfile.gr +c No. of vertices :10 +c No. of edges :7 +c Max. weight :200 +c Min. weight :0 +c Min. edge :0 +c Max. edge :2 +p sp 10 7 +a 4 3 -64 +a 5 4 148 +a 5 3 -163 +a 6 9 -139 +a 7 9 -9 +a 9 8 -97 +a 10 9 143 + +>>> random.seed(4) +>>> dimacs_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.gr','r') +>>> print(file.read()) +c FILE :testfile2.gr +c No. of vertices :30 +c No. of edges :41 +c Max. weight :50 +c Min. weight :0 +c Min. edge :0 +c Max. edge :4 +p sp 30 41 +a 1 10 46 +a 2 16 5 +a 2 3 25 +a 2 18 -48 +a 4 17 -17 +a 5 27 16 +a 6 30 41 +a 7 26 -12 +a 7 6 -18 +a 8 3 -42 +a 8 13 11 +a 9 16 -5 +a 10 27 0 +a 10 30 -36 +a 10 23 -48 +a 10 17 26 +a 11 20 -27 +a 11 15 14 +a 11 10 -2 +a 14 21 -33 +a 14 18 -44 +a 14 11 43 +a 15 3 -12 +a 16 9 22 +a 16 14 -40 +a 16 18 20 +a 19 9 7 +a 20 30 18 +a 20 15 2 +a 21 23 18 +a 21 24 -1 +a 22 10 -9 +a 22 25 -39 +a 24 20 28 +a 24 10 16 +a 25 20 21 +a 25 19 23 +a 25 2 -10 +a 26 26 -18 +a 26 19 28 +a 27 14 7 + +>>> random.seed(20) +>>> dimacs_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.gr','r') +>>> print(file.read()) +c FILE :testfile3.gr +c No. of vertices :100 +c No. of edges :189 +c Max. weight :30 +c Min. weight :10 +c Min. edge :0 +c Max. edge :4 +p sp 100 189 +a 1 34 30 +a 3 74 15 +a 3 4 23 +a 4 10 13 +a 4 17 20 +a 4 61 28 +a 5 53 16 +a 5 26 20 +a 5 81 20 +a 6 55 12 +a 6 81 26 +a 7 52 12 +a 7 27 28 +a 7 32 11 +a 8 13 12 +a 9 33 19 +a 10 89 18 +a 10 21 29 +a 13 91 17 +a 13 29 28 +a 14 8 10 +a 15 39 18 +a 15 18 30 +a 15 43 29 +a 15 93 24 +a 16 82 18 +a 17 56 15 +a 17 22 22 +a 17 91 13 +a 17 89 14 +a 18 55 21 +a 18 29 13 +a 18 78 11 +a 18 67 16 +a 19 23 15 +a 19 11 13 +a 19 38 10 +a 20 87 22 +a 20 59 26 +a 22 16 24 +a 23 43 10 +a 23 10 28 +a 23 96 13 +a 23 12 20 +a 24 83 12 +a 24 85 19 +a 27 29 26 +a 28 90 10 +a 28 21 10 +a 28 86 26 +a 28 18 19 +a 29 54 18 +a 31 13 16 +a 31 31 16 +a 31 29 13 +a 32 17 27 +a 32 50 14 +a 34 63 10 +a 34 23 16 +a 34 82 19 +a 35 13 19 +a 35 27 21 +a 35 80 19 +a 36 87 13 +a 38 8 22 +a 38 48 19 +a 39 60 13 +a 39 9 28 +a 39 61 16 +a 41 9 27 +a 41 80 20 +a 41 92 10 +a 41 23 18 +a 42 78 13 +a 42 1 11 +a 43 96 16 +a 44 52 29 +a 44 11 28 +a 44 47 19 +a 44 57 11 +a 45 80 22 +a 46 51 22 +a 46 33 10 +a 46 100 24 +a 46 12 28 +a 47 41 17 +a 47 100 16 +a 47 38 24 +a 48 49 16 +a 48 80 11 +a 49 18 12 +a 49 96 21 +a 52 31 27 +a 52 19 19 +a 52 100 10 +a 53 88 21 +a 54 68 14 +a 54 3 17 +a 55 68 24 +a 55 32 22 +a 55 50 27 +a 56 65 29 +a 56 84 19 +a 57 98 12 +a 57 84 25 +a 57 35 21 +a 57 95 14 +a 58 85 17 +a 58 63 14 +a 58 46 20 +a 59 19 30 +a 59 96 27 +a 59 97 13 +a 59 83 11 +a 60 25 21 +a 60 51 16 +a 60 70 26 +a 60 91 19 +a 61 81 15 +a 61 18 14 +a 61 36 10 +a 62 86 12 +a 62 100 15 +a 62 44 18 +a 62 32 20 +a 64 34 18 +a 66 39 12 +a 67 6 26 +a 67 61 22 +a 67 92 26 +a 69 91 19 +a 70 71 23 +a 70 22 24 +a 70 57 26 +a 70 62 14 +a 71 25 16 +a 72 16 16 +a 72 58 22 +a 73 9 19 +a 73 82 27 +a 73 15 16 +a 74 94 19 +a 75 65 19 +a 76 61 13 +a 76 47 26 +a 76 32 15 +a 77 74 21 +a 77 38 14 +a 77 2 20 +a 77 49 14 +a 78 66 14 +a 78 23 29 +a 79 67 11 +a 79 15 18 +a 79 54 28 +a 79 12 27 +a 80 78 24 +a 81 53 11 +a 81 92 15 +a 81 23 13 +a 82 91 29 +a 82 73 30 +a 82 39 15 +a 83 36 17 +a 86 89 27 +a 86 76 24 +a 86 56 20 +a 86 31 27 +a 87 66 11 +a 88 12 26 +a 88 4 19 +a 88 99 21 +a 89 40 27 +a 89 52 30 +a 91 2 11 +a 91 74 15 +a 92 30 30 +a 94 54 11 +a 94 1 29 +a 94 97 16 +a 95 70 27 +a 95 60 12 +a 95 37 24 +a 96 38 20 +a 96 14 24 +a 96 25 14 +a 96 80 30 +a 99 24 16 +a 99 38 10 + +>>> dimacs_maker('testfile', 0, 200, 10, 0,0) +Traceback (most recent call last): + ... +TypeError: dimacs_maker() missing 1 required positional argument: 'sign' +>>> random.seed(2) +>>> json_maker('testfile', 0, 200, 10, 0, 2, 0, 1) +7 +>>> file=open('testfile.json','r') +>>> testfile_1=json.load(file) +>>> testfile_1['graph']['nodes'][1] +{'id': '2'} +>>> testfile_1['graph']['edges'][1]['source'] +'5' +>>> testfile_1['graph']['edges'][1]['target'] +'4' +>>> testfile_1['graph']['edges'][1]['weight'] +'148' +>>> json_to_yaml('testfile') +>>> file=open('testfile.yaml','r') +>>> testfile_1_yaml=yaml.load(file) +>>> testfile_1_yaml['graph']['edges'][1]['source'] +'5' +>>> testfile_1_yaml['graph']['edges'][1]['target'] +'4' +>>> testfile_1_yaml['graph']['edges'][1]['weight'] +'148' +>>> json_to_pickle('testfile') +>>> testfile_1_p=pickle.load( open( 'testfile.p', 'rb' ) ) +>>> testfile_1_p['graph']['edges'][1]['source'] +'5' +>>> testfile_1_p['graph']['edges'][1]['target'] +'4' +>>> testfile_1_p['graph']['edges'][1]['weight'] +'148' +>>> random.seed(4) +>>> json_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.json','r') +>>> testfile_2=json.load(file) +>>> testfile_2['graph']['nodes'][1] +{'id': '2'} +>>> testfile_2['graph']['edges'][1]['source'] +'2' +>>> testfile_2['graph']['edges'][1]['target'] +'16' +>>> testfile_2['graph']['edges'][1]['weight'] +'5' +>>> json_to_yaml('testfile2') +>>> file=open('testfile2.yaml','r') +>>> testfile_2_yaml=yaml.load(file) +>>> testfile_2_yaml['graph']['nodes'][1] +{'id': '2'} +>>> testfile_2_yaml['graph']['edges'][1]['source'] +'2' +>>> testfile_2_yaml['graph']['edges'][1]['target'] +'16' +>>> testfile_2_yaml['graph']['edges'][1]['weight'] +'5' +>>> json_to_pickle('testfile2') +>>> testfile_2_p=pickle.load( open( 'testfile2.p', 'rb' ) ) +>>> testfile_2_p['graph']['edges'][1]['source'] +'2' +>>> testfile_2_p['graph']['edges'][1]['target'] +'16' +>>> testfile_2_p['graph']['edges'][1]['weight'] +'5' +>>> random.seed(20) +>>> json_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.json','r') +>>> testfile_3=json.load(file) +>>> testfile_3['graph']['nodes'][1] +{'id': '2'} +>>> testfile_3['graph']['edges'][1]['source'] +'3' +>>> testfile_3['graph']['edges'][1]['target'] +'74' +>>> testfile_3['graph']['edges'][1]['weight'] +'15' +>>> json_to_yaml('testfile3') +>>> file=open('testfile3.yaml','r') +>>> testfile_3_yaml=yaml.load(file) +>>> testfile_3_yaml['graph']['nodes'][1] +{'id': '2'} +>>> testfile_3_yaml['graph']['edges'][1]['source'] +'3' +>>> testfile_3_yaml['graph']['edges'][1]['target'] +'74' +>>> testfile_3_yaml['graph']['edges'][1]['weight'] +'15' +>>> json_to_yaml('testfile24') +[Error] Bad Input File +>>> json_to_pickle('testfile24') +[Error] Bad Input File +>>> json_maker('testfile', 0, 200, 10, 0, 0) +Traceback (most recent call last): + ... +TypeError: json_maker() missing 1 required positional argument: 'sign' +>>> json_to_pickle('testfile3') +>>> testfile_3_p=pickle.load( open( 'testfile3.p', 'rb' ) ) +>>> testfile_3_p['graph']['edges'][1]['source'] +'3' +>>> testfile_3_p['graph']['edges'][1]['target'] +'74' +>>> testfile_3_p['graph']['edges'][1]['weight'] +'15' +>>> random.seed(2) +>>> csv_maker('testfile', 0, 200, 10, 0, 2, 0, 1) +7 +>>> file=open('testfile.csv','r') +>>> print(file.read()) +4,3,-64 +5,4,148 +5,3,-163 +6,9,-139 +7,9,-9 +9,8,-97 +10,9,143 + +>>> random.seed(4) +>>> csv_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.csv','r') +>>> print(file.read()) +1,10,46 +2,16,5 +2,3,25 +2,18,-48 +4,17,-17 +5,27,16 +6,30,41 +7,26,-12 +7,6,-18 +8,3,-42 +8,13,11 +9,16,-5 +10,27,0 +10,30,-36 +10,23,-48 +10,17,26 +11,20,-27 +11,15,14 +11,10,-2 +14,21,-33 +14,18,-44 +14,11,43 +15,3,-12 +16,9,22 +16,14,-40 +16,18,20 +19,9,7 +20,30,18 +20,15,2 +21,23,18 +21,24,-1 +22,10,-9 +22,25,-39 +24,20,28 +24,10,16 +25,20,21 +25,19,23 +25,2,-10 +26,26,-18 +26,19,28 +27,14,7 + +>>> random.seed(20) +>>> csv_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.csv','r') +>>> print(file.read()) +1,34,30 +3,74,15 +3,4,23 +4,10,13 +4,17,20 +4,61,28 +5,53,16 +5,26,20 +5,81,20 +6,55,12 +6,81,26 +7,52,12 +7,27,28 +7,32,11 +8,13,12 +9,33,19 +10,89,18 +10,21,29 +13,91,17 +13,29,28 +14,8,10 +15,39,18 +15,18,30 +15,43,29 +15,93,24 +16,82,18 +17,56,15 +17,22,22 +17,91,13 +17,89,14 +18,55,21 +18,29,13 +18,78,11 +18,67,16 +19,23,15 +19,11,13 +19,38,10 +20,87,22 +20,59,26 +22,16,24 +23,43,10 +23,10,28 +23,96,13 +23,12,20 +24,83,12 +24,85,19 +27,29,26 +28,90,10 +28,21,10 +28,86,26 +28,18,19 +29,54,18 +31,13,16 +31,31,16 +31,29,13 +32,17,27 +32,50,14 +34,63,10 +34,23,16 +34,82,19 +35,13,19 +35,27,21 +35,80,19 +36,87,13 +38,8,22 +38,48,19 +39,60,13 +39,9,28 +39,61,16 +41,9,27 +41,80,20 +41,92,10 +41,23,18 +42,78,13 +42,1,11 +43,96,16 +44,52,29 +44,11,28 +44,47,19 +44,57,11 +45,80,22 +46,51,22 +46,33,10 +46,100,24 +46,12,28 +47,41,17 +47,100,16 +47,38,24 +48,49,16 +48,80,11 +49,18,12 +49,96,21 +52,31,27 +52,19,19 +52,100,10 +53,88,21 +54,68,14 +54,3,17 +55,68,24 +55,32,22 +55,50,27 +56,65,29 +56,84,19 +57,98,12 +57,84,25 +57,35,21 +57,95,14 +58,85,17 +58,63,14 +58,46,20 +59,19,30 +59,96,27 +59,97,13 +59,83,11 +60,25,21 +60,51,16 +60,70,26 +60,91,19 +61,81,15 +61,18,14 +61,36,10 +62,86,12 +62,100,15 +62,44,18 +62,32,20 +64,34,18 +66,39,12 +67,6,26 +67,61,22 +67,92,26 +69,91,19 +70,71,23 +70,22,24 +70,57,26 +70,62,14 +71,25,16 +72,16,16 +72,58,22 +73,9,19 +73,82,27 +73,15,16 +74,94,19 +75,65,19 +76,61,13 +76,47,26 +76,32,15 +77,74,21 +77,38,14 +77,2,20 +77,49,14 +78,66,14 +78,23,29 +79,67,11 +79,15,18 +79,54,28 +79,12,27 +80,78,24 +81,53,11 +81,92,15 +81,23,13 +82,91,29 +82,73,30 +82,39,15 +83,36,17 +86,89,27 +86,76,24 +86,56,20 +86,31,27 +87,66,11 +88,12,26 +88,4,19 +88,99,21 +89,40,27 +89,52,30 +91,2,11 +91,74,15 +92,30,30 +94,54,11 +94,1,29 +94,97,16 +95,70,27 +95,60,12 +95,37,24 +96,38,20 +96,14,24 +96,25,14 +96,80,30 +99,24,16 +99,38,10 + +>>> csv_maker('testfile', 0, 200, 10, 0,0) +Traceback (most recent call last): + ... +TypeError: csv_maker() missing 1 required positional argument: 'sign' +>>> random.seed(2) +>>> wel_maker('testfile', 0, 200, 10, 0, 2, 0,1) +7 +>>> file=open('testfile.wel','r') +>>> print(file.read()) +4 3 -64 +5 4 148 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 + +>>> random.seed(4) +>>> wel_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.wel','r') +>>> print(file.read()) +1 10 46 +2 16 5 +2 3 25 +2 18 -48 +4 17 -17 +5 27 16 +6 30 41 +7 26 -12 +7 6 -18 +8 3 -42 +8 13 11 +9 16 -5 +10 27 0 +10 30 -36 +10 23 -48 +10 17 26 +11 20 -27 +11 15 14 +11 10 -2 +14 21 -33 +14 18 -44 +14 11 43 +15 3 -12 +16 9 22 +16 14 -40 +16 18 20 +19 9 7 +20 30 18 +20 15 2 +21 23 18 +21 24 -1 +22 10 -9 +22 25 -39 +24 20 28 +24 10 16 +25 20 21 +25 19 23 +25 2 -10 +26 26 -18 +26 19 28 +27 14 7 + +>>> random.seed(20) +>>> wel_maker('testfile3',10,30,100,0,4,2,1) +189 +>>> file=open('testfile3.wel','r') +>>> print(file.read()) +1 34 30 +3 74 15 +3 4 23 +4 10 13 +4 17 20 +4 61 28 +5 53 16 +5 26 20 +5 81 20 +6 55 12 +6 81 26 +7 52 12 +7 27 28 +7 32 11 +8 13 12 +9 33 19 +10 89 18 +10 21 29 +13 91 17 +13 29 28 +14 8 10 +15 39 18 +15 18 30 +15 43 29 +15 93 24 +16 82 18 +17 56 15 +17 22 22 +17 91 13 +17 89 14 +18 55 21 +18 29 13 +18 78 11 +18 67 16 +19 23 15 +19 11 13 +19 38 10 +20 87 22 +20 59 26 +22 16 24 +23 43 10 +23 10 28 +23 96 13 +23 12 20 +24 83 12 +24 85 19 +27 29 26 +28 90 10 +28 21 10 +28 86 26 +28 18 19 +29 54 18 +31 13 16 +31 31 16 +31 29 13 +32 17 27 +32 50 14 +34 63 10 +34 23 16 +34 82 19 +35 13 19 +35 27 21 +35 80 19 +36 87 13 +38 8 22 +38 48 19 +39 60 13 +39 9 28 +39 61 16 +41 9 27 +41 80 20 +41 92 10 +41 23 18 +42 78 13 +42 1 11 +43 96 16 +44 52 29 +44 11 28 +44 47 19 +44 57 11 +45 80 22 +46 51 22 +46 33 10 +46 100 24 +46 12 28 +47 41 17 +47 100 16 +47 38 24 +48 49 16 +48 80 11 +49 18 12 +49 96 21 +52 31 27 +52 19 19 +52 100 10 +53 88 21 +54 68 14 +54 3 17 +55 68 24 +55 32 22 +55 50 27 +56 65 29 +56 84 19 +57 98 12 +57 84 25 +57 35 21 +57 95 14 +58 85 17 +58 63 14 +58 46 20 +59 19 30 +59 96 27 +59 97 13 +59 83 11 +60 25 21 +60 51 16 +60 70 26 +60 91 19 +61 81 15 +61 18 14 +61 36 10 +62 86 12 +62 100 15 +62 44 18 +62 32 20 +64 34 18 +66 39 12 +67 6 26 +67 61 22 +67 92 26 +69 91 19 +70 71 23 +70 22 24 +70 57 26 +70 62 14 +71 25 16 +72 16 16 +72 58 22 +73 9 19 +73 82 27 +73 15 16 +74 94 19 +75 65 19 +76 61 13 +76 47 26 +76 32 15 +77 74 21 +77 38 14 +77 2 20 +77 49 14 +78 66 14 +78 23 29 +79 67 11 +79 15 18 +79 54 28 +79 12 27 +80 78 24 +81 53 11 +81 92 15 +81 23 13 +82 91 29 +82 73 30 +82 39 15 +83 36 17 +86 89 27 +86 76 24 +86 56 20 +86 31 27 +87 66 11 +88 12 26 +88 4 19 +88 99 21 +89 40 27 +89 52 30 +91 2 11 +91 74 15 +92 30 30 +94 54 11 +94 1 29 +94 97 16 +95 70 27 +95 60 12 +95 37 24 +96 38 20 +96 14 24 +96 25 14 +96 80 30 +99 24 16 +99 38 10 + +>>> wel_maker('testfile', 0, 200, 10, 0,0) +Traceback (most recent call last): + ... +TypeError: wel_maker() missing 1 required positional argument: 'sign' +>>> random.seed(2) +>>> lp_maker('testfile', 0, 200, 10, 0, 2, 0,1) +7 +>>> file=open('testfile.lp','r') +>>> print(file.read()) +node(1). +node(2). +node(3). +node(4). +node(5). +node(6). +node(7). +node(8). +node(9). +node(10). +edge(4,3,-64). +edge(5,4,148). +edge(5,3,-163). +edge(6,9,-139). +edge(7,9,-9). +edge(9,8,-97). +edge(10,9,143). + +>>> random.seed(4) +>>> lp_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.lp','r') +>>> print(file.read()) +node(1). +node(2). +node(3). +node(4). +node(5). +node(6). +node(7). +node(8). +node(9). +node(10). +node(11). +node(12). +node(13). +node(14). +node(15). +node(16). +node(17). +node(18). +node(19). +node(20). +node(21). +node(22). +node(23). +node(24). +node(25). +node(26). +node(27). +node(28). +node(29). +node(30). +edge(1,10,46). +edge(2,16,5). +edge(2,3,25). +edge(2,18,-48). +edge(4,17,-17). +edge(5,27,16). +edge(6,30,41). +edge(7,26,-12). +edge(7,6,-18). +edge(8,3,-42). +edge(8,13,11). +edge(9,16,-5). +edge(10,27,0). +edge(10,30,-36). +edge(10,23,-48). +edge(10,17,26). +edge(11,20,-27). +edge(11,15,14). +edge(11,10,-2). +edge(14,21,-33). +edge(14,18,-44). +edge(14,11,43). +edge(15,3,-12). +edge(16,9,22). +edge(16,14,-40). +edge(16,18,20). +edge(19,9,7). +edge(20,30,18). +edge(20,15,2). +edge(21,23,18). +edge(21,24,-1). +edge(22,10,-9). +edge(22,25,-39). +edge(24,20,28). +edge(24,10,16). +edge(25,20,21). +edge(25,19,23). +edge(25,2,-10). +edge(26,26,-18). +edge(26,19,28). +edge(27,14,7). + +>>> input_dic=get_input(input_func=print_test) +>>> input_dic['sign'] +2 +>>> input_dic['vertices'] +18 +>>> input_dic['min_edge'] +17 +>>> input_dic['min_weight'] +1 +>>> input_dic['output_format'] +1 +>>> input_dic['max_weight'] +1 +>>> input_dic['file_name'] +'12' +>>> input_dic['max_edge'] +17 +>>> random.seed(2) +>>> tgf_maker('testfile', 0, 200, 10, 0, 2, 0, 1) +7 +>>> file=open('testfile.tgf','r') +>>> print(file.read()) +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +# +4 3 -64 +5 4 148 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 + +>>> random.seed(4) +>>> tgf_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.tgf','r') +>>> print(file.read()) +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +# +1 10 46 +2 16 5 +2 3 25 +2 18 -48 +4 17 -17 +5 27 16 +6 30 41 +7 26 -12 +7 6 -18 +8 3 -42 +8 13 11 +9 16 -5 +10 27 0 +10 30 -36 +10 23 -48 +10 17 26 +11 20 -27 +11 15 14 +11 10 -2 +14 21 -33 +14 18 -44 +14 11 43 +15 3 -12 +16 9 22 +16 14 -40 +16 18 20 +19 9 7 +20 30 18 +20 15 2 +21 23 18 +21 24 -1 +22 10 -9 +22 25 -39 +24 20 28 +24 10 16 +25 20 21 +25 19 23 +25 2 -10 +26 26 -18 +26 19 28 +27 14 7 + +>>> random.seed(2) +>>> dl_maker('testfile', 0, 200, 10, 0, 2, 0,1) +7 +>>> file=open('testfile.dl','r') +>>> print(file.read()) +dl +format=edgelist1 +n=10 +data: +4 3 -64 +5 4 148 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 + +>>> random.seed(4) +>>> dl_maker('testfile2',0,50,30,0,4,0,1) +41 +>>> file=open('testfile2.dl','r') +>>> print(file.read()) +dl +format=edgelist1 +n=30 +data: +1 10 46 +2 16 5 +2 3 25 +2 18 -48 +4 17 -17 +5 27 16 +6 30 41 +7 26 -12 +7 6 -18 +8 3 -42 +8 13 11 +9 16 -5 +10 27 0 +10 30 -36 +10 23 -48 +10 17 26 +11 20 -27 +11 15 14 +11 10 -2 +14 21 -33 +14 18 -44 +14 11 43 +15 3 -12 +16 9 22 +16 14 -40 +16 18 20 +19 9 7 +20 30 18 +20 15 2 +21 23 18 +21 24 -1 +22 10 -9 +22 25 -39 +24 20 28 +24 10 16 +25 20 21 +25 19 23 +25 2 -10 +26 26 -18 +26 19 28 +27 14 7 + +>>> file.close() +>>> os.remove('testfile.csv') +>>> os.remove('testfile.dl') +>>> os.remove('testfile.gr') +>>> os.remove('testfile.json') +>>> os.remove('testfile.lp') +>>> os.remove('testfile.p') +>>> os.remove('testfile.tgf') +>>> os.remove('testfile.wel') +>>> os.remove('testfile.yaml') +>>> os.remove('testfile2.csv') +>>> os.remove('testfile2.dl') +>>> os.remove('testfile2.gr') +>>> os.remove('testfile2.json') +>>> os.remove('testfile2.lp') +>>> os.remove('testfile2.p') +>>> os.remove('testfile2.tgf') +>>> os.remove('testfile2.wel') +>>> os.remove('testfile2.yaml') +>>> os.remove('testfile3.csv') +>>> os.remove('testfile3.gr') +>>> os.remove('testfile3.json') +>>> os.remove('testfile3.p') +>>> os.remove('testfile3.wel') +>>> os.remove('testfile3.yaml') +>>> os.remove('logfile.log') + +"""