From c31a818cb03f76b678c4ed2568087a777c7f6cc4 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 16:44:10 +0430 Subject: [PATCH 01/23] fix : json_maker function optimized #32 --- pyrgg/pyrgg.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 4defe448..d856d1b0 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -565,19 +565,29 @@ 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' - for i in edge_dic.keys(): - nodes = nodes + '\t\t\t{\n\t\t\t\t' + \ - '"id": ' + '"' + str(i) + '"\n\t\t\t},\n' - for j, value in enumerate(edge_dic[i]): - 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) + for i,value in enumerate(edge_dic.keys()): + nodes = '\t\t\t{\n\t\t\t\t' + \ + '"id": ' + '"' + str(value) + '"\n\t\t\t},\n' + if i == len(edge_dic)-1: + nodes = nodes[:-2] + "\n\t\t],\n" + file.write(nodes) 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}' + file.write(edges) + file.write("\n\t\t]\n\t}\n}") file.close() return edge_number From 48f2e74cd5677afde30395aeda5c787ce0e61feb Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 16:48:53 +0430 Subject: [PATCH 02/23] fix : lp_maker function optimized #32 --- pyrgg/pyrgg.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index d856d1b0..0e1f225d 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -854,15 +854,11 @@ 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 From 607d336a05b4ec5d71c8a2b8c35dec28e6f45916 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 16:51:29 +0430 Subject: [PATCH 03/23] fix : tgf_maker function optimized #32 --- pyrgg/pyrgg.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 0e1f225d..14f7090e 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -913,16 +913,12 @@ 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 From 23052e15ed903d3e0f13cce93830922046df0b10 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 16:53:10 +0430 Subject: [PATCH 04/23] fix : dl_maker function optimized #32 --- pyrgg/pyrgg.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 14f7090e..766a400d 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -973,13 +973,10 @@ 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 From 7bb52510f2c0cb6af5f80d1f54d128189d20a066 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 16:54:43 +0430 Subject: [PATCH 05/23] doc : CHANGELOG updated #32 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1a46ec8..45154626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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] +### 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 From 94fe3c79ee473a1bf032a8070670acca9a3333b9 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Thu, 2 Jul 2020 17:14:44 +0430 Subject: [PATCH 06/23] doc : CHANGELOG updated #32 --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45154626..40f981f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `dl_maker` function optimized - `tgf_maker` function optimized - `lp_maker` function optimized - ## [0.5] - 2020-07-01 ### Added - TSV format From 12ceb6201d5a81ee360823db48671ab9652f9feb Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 3 Jul 2020 09:00:28 +0430 Subject: [PATCH 07/23] fix : travis config updated --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4b003a3c..9806b431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,9 @@ matrix: - os: linux python: 3.8-dev dist: xenial + - os: linux + python: 3.9-dev + dist: xenial - os: linux python: nightly dist: xenial @@ -33,6 +36,9 @@ matrix: python: 2.7 - os: linux python: 3.4 + - os: linux + python: 3.9-dev + dist: xenial install: - chmod +x .travis/install.sh - .travis/install.sh From 38b56926e6656af6034106ab98d8bb6c4f61f813 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 3 Jul 2020 09:25:34 +0430 Subject: [PATCH 08/23] fix : codecov.yml updated --- codecov.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codecov.yml b/codecov.yml index 2ab03b78..600c260a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -9,3 +9,6 @@ coverage: patch: default: enabled: no + project: + default: + threshold: 1% From e7745e16dfcd6d76ff40ad068c0464daa40c6a6d Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 4 Jul 2020 16:57:52 +0430 Subject: [PATCH 09/23] fix : minor edit in json_maker function #32 --- pyrgg/pyrgg.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 766a400d..644fb15a 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -570,12 +570,17 @@ def json_maker( edges = '\t\t\t"edges":[\n' file.write('{\n\t"graph": {\n') file.write(nodes) - for i,value in enumerate(edge_dic.keys()): - nodes = '\t\t\t{\n\t\t\t\t' + \ - '"id": ' + '"' + str(value) + '"\n\t\t\t},\n' - if i == len(edge_dic)-1: - nodes = nodes[:-2] + "\n\t\t],\n" + 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}' 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]): From e6f8a227f35609ec18d89b22ba11f3b41c40cee4 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 01:15:19 +0430 Subject: [PATCH 10/23] feat : mtx_maker function added #3 --- pyrgg/pyrgg.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index 644fb15a..ef813202 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -808,6 +808,65 @@ def wel_maker( file.close() 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] + 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]): + file.write(str(i) + 4*" " + str(value) + 4*" " + + str(weight_dic[i][j]) + "\n") + file.close() + return edge_number + def lp_maker( file_name, From d776ffe1dd4ab558c8ddb239ce566ce6c9905987 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 01:19:44 +0430 Subject: [PATCH 11/23] fix : mtx format added to menu #3 --- pyrgg/__main__.py | 3 ++- pyrgg/params.py | 5 +++-- pyrgg/pyrgg.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyrgg/__main__.py b/pyrgg/__main__.py index d2e6a699..80c480d3 100644 --- a/pyrgg/__main__.py +++ b/pyrgg/__main__.py @@ -17,7 +17,8 @@ 7: json_maker, 8: dl_maker, 9: tgf_maker, - 10: tsv_maker} + 10: tsv_maker, + 11: mtx_maker} def run(): diff --git a/pyrgg/params.py b/pyrgg/params.py index 34e07493..75e8de9f 100644 --- a/pyrgg/params.py +++ b/pyrgg/params.py @@ -5,7 +5,7 @@ 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]", + ".tsv)[10] | Matrix Market(.mtx)[11]", "weight": "Weighted[1] or Unweighted[2]"} MENU_ITEMS2 = {"vertices": "Vertices Number : ", @@ -29,7 +29,8 @@ 7: ".p", 8: ".dl", 9: ".tgf", - 10: ".tsv"} + 10: ".tsv", + 11: ".mtx"} PYRGG_VERSION = "0.5" diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index ef813202..b9efa0aa 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -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 From e367f0fad348b3bb4fd7751bd8aa82b344122141 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 01:24:07 +0430 Subject: [PATCH 12/23] doc : CHANGELOG updated #3 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40f981f0..d54309e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ 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] +### Added +- Matrix Market format ### Changed - `json_maker` function optimized - `dl_maker` function optimized From 693fa4b2a5da0a63aa97d0d198a30c6a60c607ab Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 01:35:53 +0430 Subject: [PATCH 13/23] fix : minor edit in mtx_maker #3 --- pyrgg/pyrgg.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index b9efa0aa..dc6923fd 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -858,11 +858,14 @@ def mtx_maker( 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))) + 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]): - file.write(str(i) + 4*" " + str(value) + 4*" " + + 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 From cda722fd7178c06215f66602aa32b7d678e1e1df Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 12:47:48 +0430 Subject: [PATCH 14/23] fix : tests updated #3 --- dev-requirements.txt | 1 + pyrgg/test.py | 15 ++++++ test/test.py | 125 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index b5753c4c..780499b1 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -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 diff --git a/pyrgg/test.py b/pyrgg/test.py index 3feec742..8aabd79f 100644 --- a/pyrgg/test.py +++ b/pyrgg/test.py @@ -467,8 +467,23 @@ >>> csv_maker('testfile', 0, 200, 10, 0, 2, 0, 1,1,1) 7 >>> random.seed(2) +>>> mtx_maker('testfile', 0, 200, 10, 0, 2, 0, 1,1,1) +7 +>>> random.seed(2) >>> tsv_maker('testfile', 0, 200, 10, 0, 2, 0, 1,1,1) 7 +>>> file=open('testfile.mtx','r') +>>> print(file.read()) +%%MatrixMarket matrix coordinate real general +10 10 7 +4 3 -64 +5 4 148 +5 3 -163 +6 9 -139 +7 9 -9 +9 8 -97 +10 9 143 + >>> file=open('testfile.csv','r') >>> print(file.read()) 4,3,-64 diff --git a/test/test.py b/test/test.py index 75b562f7..476d48ef 100644 --- a/test/test.py +++ b/test/test.py @@ -6,6 +6,7 @@ >>> import json >>> import yaml >>> import pickle +>>> from scipy.io import mmread >>> logger(2,2,2,2) [Error] Logger Faild! >>> description_print() @@ -708,6 +709,18 @@ 10,9,143 >>> random.seed(2) +>>> mtx_maker('testfile', 0, 200, 10, 0, 2, 0, 1,1,1) +7 +>>> g = mmread("testfile.mtx") +>>> print(g) + (3, 2) -64.0 + (4, 3) 148.0 + (4, 2) -163.0 + (5, 8) -139.0 + (6, 8) -9.0 + (8, 7) -97.0 + (9, 8) 143.0 +>>> random.seed(2) >>> tsv_maker('testfile', 0, 200, 10, 0, 2, 0, 1,1,1) 7 >>> file=open('testfile.tsv','r') @@ -724,8 +737,54 @@ >>> csv_maker('testfile2',0,50,30,0,4,0,1,1,1) 41 >>> random.seed(4) +>>> mtx_maker('testfile2',0,50,30,0,4,0,1,1,1) +41 +>>> random.seed(4) >>> tsv_maker('testfile2',0,50,30,0,4,0,1,1,1) 41 +>>> g = mmread("testfile2.mtx") +>>> print(g) + (0, 9) 46.0 + (1, 15) 5.0 + (1, 2) 25.0 + (1, 19) -48.0 + (3, 16) -17.0 + (4, 26) 16.0 + (5, 29) 41.0 + (6, 25) -12.0 + (6, 5) -18.0 + (7, 2) -42.0 + (7, 13) 11.0 + (8, 15) -5.0 + (9, 26) 0.0 + (9, 9) -48.0 + (9, 17) 26.0 + (9, 14) -27.0 + (10, 5) 19.0 + (10, 9) 5.0 + (10, 1) -40.0 + (11, 16) -44.0 + (11, 10) 43.0 + (12, 2) -12.0 + (13, 8) 22.0 + (13, 14) -40.0 + (13, 19) 20.0 + (16, 8) 7.0 + (17, 29) 18.0 + (17, 14) 2.0 + (18, 22) 18.0 + (18, 24) -1.0 + (19, 9) -9.0 + (19, 25) -39.0 + (21, 19) 28.0 + (21, 9) 16.0 + (22, 19) 21.0 + (22, 18) 23.0 + (22, 1) -10.0 + (23, 25) -18.0 + (23, 18) 28.0 + (24, 13) 7.0 + (28, 19) 38.0 >>> file=open('testfile2.csv','r') >>> print(file.read()) 1,10,46 @@ -774,8 +833,64 @@ >>> csv_maker('testfile3',10,30,100,0,4,2,1,1,1) 197 >>> random.seed(20) +>>> mtx_maker('testfile3',10,30,100,0,4,2,1,1,1) +197 +>>> random.seed(20) >>> tsv_maker('testfile3',10,30,100,0,4,2,1,1,1) 197 +>>> g = mmread("testfile3.mtx") +>>> print(g) + (0, 33) 30.0 + (2, 73) 15.0 + (2, 3) 23.0 + (3, 9) 13.0 + (3, 17) 20.0 + (3, 62) 28.0 + (4, 52) 16.0 + (4, 25) 20.0 + (4, 82) 20.0 + (5, 54) 12.0 + (5, 81) 26.0 + (6, 51) 12.0 + (6, 26) 28.0 + (6, 32) 11.0 + (7, 12) 12.0 + (8, 32) 19.0 + (9, 88) 18.0 + (9, 20) 29.0 + (12, 90) 17.0 + (12, 28) 28.0 + (13, 7) 10.0 + (14, 38) 18.0 + (14, 17) 30.0 + (14, 44) 29.0 + (14, 95) 24.0 + : : + (86, 11) 26.0 + (86, 3) 19.0 + (86, 4) 18.0 + (87, 33) 19.0 + (87, 69) 22.0 + (89, 1) 11.0 + (89, 74) 15.0 + (90, 29) 30.0 + (92, 53) 11.0 + (92, 0) 29.0 + (92, 98) 16.0 + (93, 69) 27.0 + (93, 59) 12.0 + (93, 36) 24.0 + (94, 37) 20.0 + (94, 13) 24.0 + (94, 25) 14.0 + (94, 82) 30.0 + (97, 23) 16.0 + (97, 24) 17.0 + (98, 0) 13.0 + (98, 7) 17.0 + (99, 64) 30.0 + (99, 78) 22.0 + (99, 87) 18.0 >>> file=open('testfile3.csv','r') >>> print(file.read()) 1,34,30 @@ -980,12 +1095,19 @@ >>> csv_maker('testfile3',10,30,100,0,4,2,2,1,2) 198 >>> random.seed(20) +>>> mtx_maker('testfile3',10,30,100,0,4,2,2,1,2) +198 +>>> random.seed(20) >>> tsv_maker('testfile3',10,30,100,0,4,2,2,1,2) 198 >>> csv_maker('testfile', 0, 200, 10, 0,0,1) Traceback (most recent call last): ... TypeError: csv_maker() missing 1 required positional argument: 'sign' +>>> mtx_maker('testfile', 0, 200, 10, 0,0,1) +Traceback (most recent call last): + ... +TypeError: csv_maker() missing 1 required positional argument: 'sign' >>> tsv_maker('testfile', 0, 200, 10, 0,0,1) Traceback (most recent call last): ... @@ -1603,6 +1725,7 @@ >>> file.close() >>> os.remove('testfile.csv') >>> os.remove('testfile.tsv') +>>> os.remove('testfile.mtx') >>> os.remove('testfile.dl') >>> os.remove('testfile.gr') >>> os.remove('testfile.json') @@ -1612,6 +1735,7 @@ >>> os.remove('testfile.wel') >>> os.remove('testfile.yaml') >>> os.remove('testfile2.csv') +>>> os.remove('testfile2.mtx') >>> os.remove('testfile2.tsv') >>> os.remove('testfile2.dl') >>> os.remove('testfile2.gr') @@ -1622,6 +1746,7 @@ >>> os.remove('testfile2.wel') >>> os.remove('testfile2.yaml') >>> os.remove('testfile3.csv') +>>> os.remove('testfile3.mtx') >>> os.remove('testfile3.tsv') >>> os.remove('testfile3.gr') >>> os.remove('testfile4.gr') From adebbbe4829446e302e9fbe2116ec2574817045d Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 12:49:00 +0430 Subject: [PATCH 15/23] fix : autopep8 #3 --- pyrgg/pyrgg.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pyrgg/pyrgg.py b/pyrgg/pyrgg.py index dc6923fd..4c5cb7b5 100644 --- a/pyrgg/pyrgg.py +++ b/pyrgg/pyrgg.py @@ -808,6 +808,7 @@ def wel_maker( file.close() return edge_number + def mtx_maker( file_name, min_weight, @@ -860,12 +861,12 @@ def mtx_maker( 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))) + 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*" " + + file.write(str(i) + shift1 * " " + str(value) + shift2 * " " + str(weight_dic[i][j]) + "\n") file.close() return edge_number @@ -925,7 +926,8 @@ def lp_maker( file.write('node(' + str(i) + ").\n") for i in edge_dic.keys(): for j, value in enumerate(edge_dic[i]): - file.write('edge(' + str(i) + "," + str(value) + "," + str(weight_dic[i][j]) + ").\n") + file.write('edge(' + str(i) + "," + str(value) + + "," + str(weight_dic[i][j]) + ").\n") file.close() return edge_number @@ -985,7 +987,8 @@ def tgf_maker( file.write("#\n") 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.write(str(i) + " " + str(value) + " " + + str(weight_dic[i][j]) + "\n") file.close() return edge_number @@ -1043,7 +1046,8 @@ def dl_maker( file.write("dl\nformat=edgelist1\nn=" + str(vertices) + "\ndata:\n") 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.write(str(i) + " " + str(value) + " " + + str(weight_dic[i][j]) + "\n") file.close() return edge_number From 65a8f4c260bab3cb0148be3ab0aced9523548828 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sun, 5 Jul 2020 14:50:31 +0430 Subject: [PATCH 16/23] fix : travis config updated #3 --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9806b431..9ba2a3f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,13 +32,12 @@ matrix: python: nightly dist: xenial allow_failures: - - os: linux - python: 2.7 - - os: linux - python: 3.4 - os: linux python: 3.9-dev dist: xenial + - os: linux + python: nightly + dist: xenial install: - chmod +x .travis/install.sh - .travis/install.sh From 2e3c17633020f4e7071d956b6977f6e2646fc884 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 6 Jul 2020 00:41:50 +0430 Subject: [PATCH 17/23] fix : travis config updated #3 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ba2a3f2..11766d5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 From 81c6bb08c6197f767ec91b3fa7b051aeb44908fe Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 6 Jul 2020 14:13:52 +0430 Subject: [PATCH 18/23] doc : README updated #3 --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d43fa31..87778be5 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,8 @@ or send an email to [info@pyrgg.ir](mailto:info@pyrgg.ir "info@pyrgg.ir"). - [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) @@ -208,7 +210,7 @@ or send an email to [info@pyrgg.ir](mailto:info@pyrgg.ir "info@pyrgg.ir"). - [DIMACS(.gr)](http://www.diag.uniroma1.it/challenge9/format.shtml) ``` - p sp + p sp a . @@ -351,6 +353,16 @@ or send an email to [info@pyrgg.ir](mailto:info@pyrgg.ir "info@pyrgg.ir"). . n k weight_n ``` +- [Matrix Market(.mtx)](https://math.nist.gov/MatrixMarket/formats.html) + ``` + %%MatrixMarket matrix coordinate real general + + + . + . + . + + ``` - [Pickle(.p)](https://docs.python.org/3.5/library/pickle.html) (Binary Format) From ff4261823d4bf9a09dd46d06b10ccfc684e86901 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Tue, 7 Jul 2020 01:19:14 +0430 Subject: [PATCH 19/23] fix : formats menu updated --- pyrgg/params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrgg/params.py b/pyrgg/params.py index 75e8de9f..09cfc568 100644 --- a/pyrgg/params.py +++ b/pyrgg/params.py @@ -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] | Matrix Market(.mtx)[11]", + "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 Format(.dl)\n9- TGF(.tgf)\n10- TSV(" + ".tsv)\n11- Matrix Market(.mtx)\n", "weight": "Weighted[1] or Unweighted[2]"} MENU_ITEMS2 = {"vertices": "Vertices Number : ", From f6563590ec06e47711b12a4da8fab0d2fcc3f816 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Mon, 13 Jul 2020 01:42:35 +0430 Subject: [PATCH 20/23] fix : minor edit in menu items --- pyrgg/params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrgg/params.py b/pyrgg/params.py index 09cfc568..39c15916 100644 --- a/pyrgg/params.py +++ b/pyrgg/params.py @@ -4,7 +4,7 @@ MENU_ITEMS1 = { "file_name": "File Name : ", - "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 Format(.dl)\n9- TGF(.tgf)\n10- TSV(" + "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]"} From 4d8e78082bf63ef7b86273f2efe32740e39bccd9 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 18 Jul 2020 02:24:30 +0430 Subject: [PATCH 21/23] rel : migrate to version 0.6 --- CHANGELOG.md | 4 +++- README.md | 8 ++++---- otherfile/Version.rc | 8 ++++---- otherfile/version_check.py | 2 +- pyrgg/params.py | 2 +- setup.py | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d54309e2..a6707539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ 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-22 ### Added - Matrix Market format ### Changed @@ -64,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 diff --git a/README.md b/README.md index 87778be5..4d3007af 100644 --- a/README.md +++ b/README.md @@ -90,14 +90,14 @@ 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 @@ -105,8 +105,8 @@ Pyrgg target audiences are computer scientists who study graph algorithms and gr - `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: diff --git a/otherfile/Version.rc b/otherfile/Version.rc index 5493904a..027a83c2 100644 --- a/otherfile/Version.rc +++ b/otherfile/Version.rc @@ -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, @@ -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])]) ] diff --git a/otherfile/version_check.py b/otherfile/version_check.py index 90264952..b6077ad5 100644 --- a/otherfile/version_check.py +++ b/otherfile/version_check.py @@ -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)) diff --git a/pyrgg/params.py b/pyrgg/params.py index 39c15916..1f9d86bd 100644 --- a/pyrgg/params.py +++ b/pyrgg/params.py @@ -33,7 +33,7 @@ 11: ".mtx"} -PYRGG_VERSION = "0.5" +PYRGG_VERSION = "0.6" SOURCE_DIR = os.getcwd() diff --git a/setup.py b/setup.py index dc0b1341..520d9988 100644 --- a/setup.py +++ b/setup.py @@ -33,14 +33,14 @@ def read_description(): setup( name='pyrgg', packages=['pyrgg'], - version='0.5', + version='0.6', description='Python Random Graph Generator', long_description=read_description(), long_description_content_type='text/markdown', author='Sepand Haghighi', author_email='info@pyrgg.ir', url='https://github.com/sepandhaghighi/pyrgg', - download_url='https://github.com/sepandhaghighi/pyrgg/tarball/v0.5', + download_url='https://github.com/sepandhaghighi/pyrgg/tarball/v0.6', keywords='random graph python3 python generator graph-process generator DIMACS JSON YAML Pickle CSV TSV WEL ASP TGF UCINET', project_urls={ 'Webpage': 'https://www.pyrgg.ir', From a7497d832546eb4d4f96b03b2ea40871dfae6b7b Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Sat, 18 Jul 2020 02:25:42 +0430 Subject: [PATCH 22/23] fix : minor edit in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 520d9988..abe533e3 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def read_description(): install_requires=get_requires(), python_requires='>=3.4', classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Natural Language :: English', 'License :: OSI Approved :: MIT License', From 69dcc42ccbbc833a44161f02b07ae2c604de6833 Mon Sep 17 00:00:00 2001 From: sepandhaghighi Date: Fri, 24 Jul 2020 01:30:54 +0430 Subject: [PATCH 23/23] doc : CHANGELOG updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6707539..2c960be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ 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-22 +## [0.6] - 2020-07-24 ### Added - Matrix Market format ### Changed