Skip to content

Commit

Permalink
Merge pull request #35 from sepandhaghighi/dev
Browse files Browse the repository at this point in the history
Version 0.6
  • Loading branch information
sepandhaghighi authored Jul 24, 2020
2 parents 76ac624 + 69dcc42 commit d30c1b9
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 53 deletions.
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ matrix:
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
Expand All @@ -25,14 +21,19 @@ matrix:
- os: linux
python: 3.8-dev
dist: xenial
- os: linux
python: 3.9-dev
dist: xenial
- os: linux
python: nightly
dist: xenial
allow_failures:
- os: linux
python: 2.7
python: 3.9-dev
dist: xenial
- os: linux
python: 3.4
python: nightly
dist: xenial
install:
- chmod +x .travis/install.sh
- .travis/install.sh
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ 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.6] - 2020-07-24
### Added
- Matrix Market format
### Changed
- `json_maker` function optimized
- `dl_maker` function optimized
- `tgf_maker` function optimized
- `lp_maker` function optimized
## [0.5] - 2020-07-01
### Added
- TSV format
Expand Down Expand Up @@ -57,7 +65,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- JSON format
- README

[Unreleased]: https://github.com/sepandhaghighi/pyrgg/compare/v0.5...dev
[Unreleased]: https://github.com/sepandhaghighi/pyrgg/compare/v0.6...dev
[0.6]: https://github.com/sepandhaghighi/pyrgg/compare/v0.5...v0.6
[0.5]: https://github.com/sepandhaghighi/pyrgg/compare/v0.4...v0.5
[0.4]: https://github.com/sepandhaghighi/pyrgg/compare/v0.3...v0.4
[0.3]: https://github.com/sepandhaghighi/pyrgg/compare/v0.2...v0.3
Expand Down
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,23 @@ Pyrgg target audiences are computer scientists who study graph algorithms and gr
## Installation

### Source Code
- Download [Version 0.5](https://github.com/sepandhaghighi/pyrgg/archive/v0.5.zip) or [Latest Source ](https://github.com/sepandhaghighi/pyrgg/archive/dev.zip)
- Download [Version 0.6](https://github.com/sepandhaghighi/pyrgg/archive/v0.6.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.5` or `pip3 install pyrgg==0.5` (Need root access)
- `pip install pyrgg==0.6` or `pip3 install pyrgg==0.6` (Need root access)

### Conda

- Check [Conda Managing Package](https://conda.io)
- `conda install -c sepandhaghighi pyrgg` (Need root access)

### Exe Version (Only Windows)
- Download [Exe-Version 0.5](https://github.com/sepandhaghighi/pyrgg/releases/download/v0.5/PYRGG-0.5.exe)
- Run `PYRGG-0.5.exe`
- Download [Exe-Version 0.6](https://github.com/sepandhaghighi/pyrgg/releases/download/v0.6/PYRGG-0.6.exe)
- Run `PYRGG-0.6.exe`

### System Requirements
Pyrgg will likely run on a modern dual core PC. Typical configuration is:
Expand Down Expand Up @@ -184,6 +184,8 @@ or send an email to [[email protected]](mailto:[email protected] "[email protected]").
- [Sample 2-TGF](https://www.dropbox.com/s/9mjeq4w973189cc/1000.tgf?dl=0) (1000 Vertices , 61KB)
- [Sample 1-UCINET DL](https://www.dropbox.com/s/82wrl86uowwjud2/100.dl?dl=0) (100 Vertices , 8KB)
- [Sample 2-UCINET DL](https://www.dropbox.com/s/kbzbsy47uvfqdsi/1000.dl?dl=0) (1000 Vertices , 729KB)
- [Sample 1-MTX](https://www.dropbox.com/s/ztw3vg0roups82q/100.mtx?dl=0) (100 Vertices , 59KB)
- [Sample 2-MTX](https://www.dropbox.com/s/skjjvbbzrpvryl4/1000.mtx?dl=0) (1000 Vertices , 1.8MB)



Expand All @@ -208,7 +210,7 @@ or send an email to [[email protected]](mailto:[email protected] "[email protected]").

- [DIMACS(.gr)](http://www.diag.uniroma1.it/challenge9/format.shtml)
```
p sp <number of vertices> <number of directed edge>
p sp <number of vertices> <number of edges>
a <head_1> <tail_1> <weight_1>

.
Expand Down Expand Up @@ -351,6 +353,16 @@ or send an email to [[email protected]](mailto:[email protected] "[email protected]").
.
n k weight_n
```
- [Matrix Market(.mtx)](https://math.nist.gov/MatrixMarket/formats.html)
```
%%MatrixMarket matrix coordinate real general
<number of vertices> <number of vertices> <number of edges>
<head_1> <tail_1> <weight_1>
.
.
.
<head_n> <tail_n> <weight_n>
```
- [Pickle(.p)](https://docs.python.org/3.5/library/pickle.html) (Binary Format)


Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ coverage:
patch:
default:
enabled: no
project:
default:
threshold: 1%
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
art==4.7
pyyaml==5.3.1
codecov>=2.0.15
scipy>=1.2.0
pytest>=4.3.1
pytest-cov>=2.6.1
setuptools>=40.8.0
Expand Down
8 changes: 4 additions & 4 deletions otherfile/Version.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(0, 5, 0, 0),
prodvers=(0, 5, 0, 0),
filevers=(0, 6, 0, 0),
prodvers=(0, 6, 0, 0),
mask=0x3f,
flags=0x0,
OS=0x40004,
Expand All @@ -16,12 +16,12 @@ VSVersionInfo(
u'040904B0',
[StringStruct(u'CompanyName', u'Sepand Haghighi'),
StringStruct(u'FileDescription', u'PYRGG.exe'),
StringStruct(u'FileVersion', u'0.5.0.0'),
StringStruct(u'FileVersion', u'0.6.0.0'),
StringStruct(u'InternalName', u'PYRGG.exe'),
StringStruct(u'LegalCopyright', u'Copyright (c) 2020 Sepand Haghighi'),
StringStruct(u'OriginalFilename', u'PYRGG.exe'),
StringStruct(u'ProductName', u'PYRGG'),
StringStruct(u'ProductVersion', u'0, 5, 0, 0')])
StringStruct(u'ProductVersion', u'0, 6, 0, 0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
Expand Down
2 changes: 1 addition & 1 deletion otherfile/version_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import codecs
Failed = 0
VERSION = "0.5"
VERSION = "0.6"

VERSION_1 = VERSION.split(".")[0]
VERSION_2 = str(int(float(VERSION) * 10 - int(VERSION_1) * 10))
Expand Down
3 changes: 2 additions & 1 deletion pyrgg/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
7: json_maker,
8: dl_maker,
9: tgf_maker,
10: tsv_maker}
10: tsv_maker,
11: mtx_maker}


def run():
Expand Down
9 changes: 5 additions & 4 deletions pyrgg/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

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] | TSV("
".tsv)[10]",
"output_format": "Graph Formats : \n1- DIMACS(.gr)\n2- JSON(.json)\n3- CSV(.csv)\n4- YAML(.yaml)\n5- WEL(.wel)\n6- ASP(.lp)\n7- Pickle(.p)\n8- UCINET DL(.dl)\n9- TGF(.tgf)\n10- TSV("
".tsv)\n11- Matrix Market(.mtx)\n",
"weight": "Weighted[1] or Unweighted[2]"}

MENU_ITEMS2 = {"vertices": "Vertices Number : ",
Expand All @@ -29,10 +29,11 @@
7: ".p",
8: ".dl",
9: ".tgf",
10: ".tsv"}
10: ".tsv",
11: ".mtx"}


PYRGG_VERSION = "0.5"
PYRGG_VERSION = "0.6"

SOURCE_DIR = os.getcwd()

Expand Down
126 changes: 98 additions & 28 deletions pyrgg/pyrgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def input_filter(input_dict):
filtered_dict["self_loop"] = 1
if filtered_dict["multigraph"] not in [1, 2]:
filtered_dict["multigraph"] = 1
if filtered_dict["output_format"] not in list(range(1, 11)):
if filtered_dict["output_format"] not in list(range(1, 12)):
filtered_dict["output_format"] = 1
return filtered_dict

Expand Down Expand Up @@ -565,19 +565,34 @@ def json_maker(
edge_dic = dicts[0]
weight_dic = dicts[1]
edge_number = dicts[2]
first_line = True
nodes = '\t\t\t"nodes":[\n'
edges = '\t\t\t"edges":[\n'
file.write('{\n\t"graph": {\n')
file.write(nodes)
for i in edge_dic.keys():
nodes = ""
if first_line:
first_line = False
else:
nodes += ",\n"
nodes = nodes + '\t\t\t{\n\t\t\t\t' + \
'"id": ' + '"' + str(i) + '"\n\t\t\t},\n'
'"id": ' + '"' + str(i) + '"\n\t\t\t}'
file.write(nodes)
file.write("\n\t\t],\n")
first_line = True
file.write(edges)
for i in edge_dic.keys():
for j, value in enumerate(edge_dic[i]):
edges = ""
if first_line:
first_line = False
else:
edges += ",\n"
edges = edges + '\t\t\t{\n\t\t\t\t"source": ' + '"' + str(i) + '",\n\t\t\t\t' + '"target": ' + '"' + str(
value) + '",\n\t\t\t\t' + '"weight": ' + '"' + str(weight_dic[i][j]) + '"\n\t\t\t},\n'
nodes = nodes[:-2] + "\n\t\t],\n"
edges = edges[:-2] + "\n\t\t]\n\t}\n}"
file.write('{\n\t"graph": {\n')
file.write(nodes)
file.write(edges)
value) + '",\n\t\t\t\t' + '"weight": ' + '"' + str(weight_dic[i][j]) + '"\n\t\t\t}'
file.write(edges)
file.write("\n\t\t]\n\t}\n}")
file.close()
return edge_number

Expand Down Expand Up @@ -794,6 +809,69 @@ def wel_maker(
return edge_number


def mtx_maker(
file_name,
min_weight,
max_weight,
vertices,
min_edge,
max_edge,
sign,
direct,
self_loop,
multigraph):
"""
Create output file in Matrix Market format.
:param file_name: file name
:type file_name: str
:param min_weight: weight min range
:type min_weight: int
:param max_weight: weight max range
:type max_weight: int
:param vertices: number of vertices
:type vertices: int
:param min_edge : minimum edge number
:type min_edge : int
:param max_edge : maximum edge number
:type max_edge : int
:param sign: weight sign flag
:type sign: int
:param direct: directed and undirected graph flag
:type direct: int
:param self_loop: self loop flag
:type self_loop: int
:param multigraph: multigraph flag
:type multigraph: int
:return: edge_number as int
"""
file = open(file_name + ".mtx", "w")
dicts = edge_gen(
vertices,
min_weight,
max_weight,
min_edge,
max_edge,
sign,
direct,
self_loop,
multigraph)
edge_dic = dicts[0]
weight_dic = dicts[1]
edge_number = dicts[2]
max_edge_length = len(str(vertices))
file.write("%%MatrixMarket matrix coordinate real general\n")
file.write("{0} {0} {1}\n".format(str(vertices), str(edge_number)))
for i in edge_dic.keys():
for j, value in enumerate(edge_dic[i]):
shift1 = (max_edge_length - len(str(i))) + 4
shift2 = (max_edge_length - len(str(value))) + 4
file.write(str(i) + shift1 * " " + str(value) + shift2 * " " +
str(weight_dic[i][j]) + "\n")
file.close()
return edge_number


def lp_maker(
file_name,
min_weight,
Expand Down Expand Up @@ -844,15 +922,12 @@ def lp_maker(
edge_dic = dicts[0]
weight_dic = dicts[1]
edge_number = dicts[2]
nodes = ''
edges = ''
for i in edge_dic.keys():
nodes = nodes + 'node(' + str(i) + ").\n"
file.write('node(' + str(i) + ").\n")
for i in edge_dic.keys():
for j, value in enumerate(edge_dic[i]):
edges = edges + \
'edge(' + str(i) + "," + str(value) + "," + str(weight_dic[i][j]) + ").\n"
file.write(nodes)
file.write(edges)
file.write('edge(' + str(i) + "," + str(value) +
"," + str(weight_dic[i][j]) + ").\n")
file.close()
return edge_number

Expand Down Expand Up @@ -907,16 +982,13 @@ def tgf_maker(
edge_dic = dicts[0]
weight_dic = dicts[1]
edge_number = dicts[2]
nodes = ''
edges = ''
for i in edge_dic.keys():
nodes = nodes + str(i) + "\n"
for j, value in enumerate(edge_dic[i]):
edges = edges + str(i) + " " + str(value) + \
" " + str(weight_dic[i][j]) + "\n"
file.write(nodes)
file.write(str(i) + "\n")
file.write("#\n")
file.write(edges)
for i in edge_dic.keys():
for j, value in enumerate(edge_dic[i]):
file.write(str(i) + " " + str(value) + " " +
str(weight_dic[i][j]) + "\n")
file.close()
return edge_number

Expand Down Expand Up @@ -971,13 +1043,11 @@ def dl_maker(
edge_dic = dicts[0]
weight_dic = dicts[1]
edge_number = dicts[2]
edges = ''
file.write("dl\nformat=edgelist1\nn=" + str(vertices) + "\ndata:\n")
for i in edge_dic.keys():
for j, value in enumerate(edge_dic[i]):
edges = edges + str(i) + " " + str(value) + \
" " + str(weight_dic[i][j]) + "\n"
file.write("dl\nformat=edgelist1\nn=" + str(vertices) + "\ndata:\n")
file.write(edges)
file.write(str(i) + " " + str(value) + " " +
str(weight_dic[i][j]) + "\n")
file.close()
return edge_number

Expand Down
Loading

0 comments on commit d30c1b9

Please sign in to comment.