diff --git a/test/engines/erdos_reyni_gilbert_test.py b/test/engines/erdos_reyni_gilbert_test.py index dfd79367..67534820 100644 --- a/test/engines/erdos_reyni_gilbert_test.py +++ b/test/engines/erdos_reyni_gilbert_test.py @@ -97,7 +97,7 @@ >>> #################### json_maker #################### >>> random.seed(2) ->>> engine.gen_using(json_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(json_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.json','r') >>> testfile_1=json.load(file) @@ -107,9 +107,20 @@ 1 >>> testfile_1['graph']['edges'][1]['target'] 5 +>>> random.seed(4) +>>> engine.gen_using(json_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.json','r') +>>> testfile_2=json.load(file) +>>> testfile_2['graph']['nodes'][1] +{'id': 2} +>>> testfile_2['graph']['edges'][1]['source'] +3 +>>> testfile_2['graph']['edges'][1]['target'] +9 >>> #################### csv_maker #################### >>> random.seed(2) ->>> engine.gen_using(csv_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(csv_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.csv','r') >>> print(file.read()) @@ -119,9 +130,23 @@ 3,8,1 4,10,1 +>>> random.seed(4) +>>> engine.gen_using(csv_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.csv','r') +>>> print(file.read()) +1,6,1 +3,9,1 +4,6,1 +6,3,1 +6,4,1 +8,4,1 +9,3,1 +9,10,1 + >>> #################### gdf_maker #################### >>> random.seed(2) ->>> engine.gen_using(gdf_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(gdf_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.gdf','r') >>> print(file.read()) @@ -143,19 +168,56 @@ 3,8,1 4,10,1 +>>> random.seed(4) +>>> engine.gen_using(gdf_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.gdf','r') +>>> print(file.read()) +nodedef>name VARCHAR,label VARCHAR +1,Node1 +2,Node2 +3,Node3 +4,Node4 +5,Node5 +6,Node6 +7,Node7 +8,Node8 +9,Node9 +10,Node10 +edgedef>node1 VARCHAR,node2 VARCHAR,weight DOUBLE +1,6,1 +3,9,1 +4,6,1 +6,3,1 +6,4,1 +8,4,1 +9,3,1 +9,10,1 + >>> #################### gl_maker #################### >>> random.seed(2) ->>> engine.gen_using(gl_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(gl_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.gl','r') >>> print(file.read()) 1 4:1 5:1 3 7:1 8:1 4 10:1 +>>> random.seed(4) +>>> engine.gen_using(gl_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.gl','r') +>>> print(file.read()) +1 6:1 +3 9:1 +4 6:1 +6 3:1 4:1 +8 4:1 +9 3:1 10:1 >>> #################### mtx_maker #################### >>> from scipy.io import mmread >>> random.seed(2) ->>> engine.gen_using(mtx_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(mtx_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> g = mmread("testfile.mtx") >>> print(g) @@ -164,9 +226,22 @@ (2, 6) 1.0 (2, 7) 1.0 (3, 9) 1.0 +>>> random.seed(4) +>>> engine.gen_using(mtx_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> g = mmread("testfile2.mtx") +>>> print(g) + (0, 5) 1.0 + (2, 8) 1.0 + (3, 5) 1.0 + (5, 2) 1.0 + (5, 3) 1.0 + (7, 3) 1.0 + (8, 2) 1.0 + (8, 9) 1.0 >>> #################### tsv_maker #################### >>> random.seed(2) ->>> engine.gen_using(tsv_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(tsv_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.tsv','r') >>> print(file.read()) @@ -176,9 +251,22 @@ 3 8 1 4 10 1 +>>> random.seed(4) +>>> engine.gen_using(tsv_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.tsv','r') +>>> print(file.read()) +1 6 1 +3 9 1 +4 6 1 +6 3 1 +6 4 1 +8 4 1 +9 3 1 +9 10 1 >>> #################### wel_maker #################### >>> random.seed(2) ->>> engine.gen_using(wel_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(wel_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.wel','r') >>> print(file.read()) @@ -188,9 +276,23 @@ 3 8 1 4 10 1 +>>> random.seed(4) +>>> engine.gen_using(wel_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.wel','r') +>>> print(file.read()) +1 6 1 +3 9 1 +4 6 1 +6 3 1 +6 4 1 +8 4 1 +9 3 1 +9 10 1 + >>> #################### lp_maker #################### >>> random.seed(2) ->>> engine.gen_using(lp_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(lp_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.lp','r') >>> print(file.read()) @@ -210,9 +312,33 @@ edge(3,8,1). edge(4,10,1). +>>> random.seed(4) +>>> engine.gen_using(lp_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> 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). +edge(1,6,1). +edge(3,9,1). +edge(4,6,1). +edge(6,3,1). +edge(6,4,1). +edge(8,4,1). +edge(9,3,1). +edge(9,10,1). + >>> #################### tgf_maker #################### >>> random.seed(2) ->>> engine.gen_using(tgf_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(tgf_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.tgf','r') >>> print(file.read()) @@ -233,9 +359,34 @@ 3 8 1 4 10 1 +>>> random.seed(4) +>>> engine.gen_using(tgf_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.tgf','r') +>>> print(file.read()) +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +# +1 6 1 +3 9 1 +4 6 1 +6 3 1 +6 4 1 +8 4 1 +9 3 1 +9 10 1 + >>> #################### dl_maker #################### >>> random.seed(2) ->>> engine.gen_using(dl_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(dl_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.dl','r') >>> print(file.read()) @@ -249,26 +400,56 @@ 3 8 1 4 10 1 +>>> random.seed(4) +>>> engine.gen_using(dl_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.dl','r') +>>> print(file.read()) +dl +format=edgelist1 +n=10 +data: +1 6 1 +3 9 1 +4 6 1 +6 3 1 +6 4 1 +8 4 1 +9 3 1 +9 10 1 + >>> #################### gml_maker #################### >>> from networkx.readwrite.gml import read_gml >>> random.seed(2) ->>> engine.gen_using(gml_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(gml_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> gml1 = read_gml("testfile.gml") >>> type(gml1) +>>> random.seed(4) +>>> engine.gen_using(gml_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> gml2 = read_gml("testfile2.gml") +>>> type(gml2) + >>> #################### gexf_maker #################### >>> from networkx.readwrite.gexf import read_gexf >>> random.seed(2) ->>> engine.gen_using(gexf_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(gexf_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> gexf1 = read_gexf("testfile.gexf") >>> type(gexf1) +>>> random.seed(4) +>>> engine.gen_using(gexf_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> gexf2 = read_gexf("testfile2.gexf") +>>> type(gexf2) + >>> #################### dot_maker #################### >>> import pydot >>> random.seed(2) ->>> engine.gen_using(dot_maker, 'testfile', {'vertices':10, 'probability':0.1}) +>>> engine.gen_using(dot_maker, 'testfile', {'vertices':10, 'probability':0.1, 'direct':0}) 5 >>> file=open('testfile.gv','r') >>> g1 = pydot.graph_from_dot_data(file.read()) @@ -276,20 +457,43 @@ 'graph' >>> len(g1[0].get_edge_list()) 5 +>>> random.seed(4) +>>> engine.gen_using(dot_maker, 'testfile2', {'vertices':10, 'probability':0.1, 'direct':1}) +8 +>>> file=open('testfile2.gv','r') +>>> g2 = pydot.graph_from_dot_data(file.read()) +>>> g2[0].get_type() +'digraph' +>>> len(g2[0].get_edge_list()) +8 >>> file.close() >>> os.remove('testfile.gr') +>>> os.remove('testfile2.gr') >>> os.remove('testfile.json') +>>> os.remove('testfile2.json') >>> os.remove('testfile.csv') +>>> os.remove('testfile2.csv') >>> os.remove('testfile.gdf') +>>> os.remove('testfile2.gdf') >>> os.remove('testfile.gl') +>>> os.remove('testfile2.gl') >>> os.remove('testfile.mtx') +>>> os.remove('testfile2.mtx') >>> os.remove('testfile.tsv') +>>> os.remove('testfile2.tsv') >>> os.remove('testfile.wel') +>>> os.remove('testfile2.wel') >>> os.remove('testfile.lp') +>>> os.remove('testfile2.lp') >>> os.remove('testfile.tgf') +>>> os.remove('testfile2.tgf') >>> os.remove('testfile.dl') +>>> os.remove('testfile2.dl') >>> os.remove('testfile.gml') +>>> os.remove('testfile2.gml') >>> os.remove('testfile.gexf') +>>> os.remove('testfile2.gexf') >>> os.remove('testfile.gv') +>>> os.remove('testfile2.gv') >>> os.remove('logfile.log') """