mirror of https://github.com/dnomd343/klotski.git
3 changed files with 28 additions and 62 deletions
@ -1,28 +0,0 @@ |
|||||
#!/usr/bin/env python3 |
|
||||
|
|
||||
import os |
|
||||
import igraph as ig |
|
||||
|
|
||||
|
|
||||
def compare(file_1: str, file_2: str) -> None: |
|
||||
print(f'{file_1} vs {file_2}') |
|
||||
g1 = ig.Graph.Read_Pickle(file_1) |
|
||||
g2 = ig.Graph.Read_Pickle(file_2) |
|
||||
|
|
||||
assert g1.vcount() == g2.vcount() |
|
||||
assert g1.ecount() == g2.ecount() |
|
||||
assert g1.isomorphic(g2) |
|
||||
|
|
||||
for edge in g1.es: |
|
||||
assert edge.attributes() == {} |
|
||||
|
|
||||
for edge in g2.es: |
|
||||
assert edge.attributes() == {} |
|
||||
|
|
||||
for i in range(g1.vcount()): |
|
||||
assert g1.vs[i].attributes() == g2.vs[i].attributes() |
|
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
|
||||
for name in sorted(os.listdir('output-ig')): |
|
||||
compare(f'output/{name}', f'output-ig/{name}') |
|
@ -1,31 +0,0 @@ |
|||||
#!/usr/bin/env python3 |
|
||||
|
|
||||
import os |
|
||||
import json |
|
||||
|
|
||||
|
|
||||
def format_1(raw: str) -> str: |
|
||||
graph = json.loads(raw) |
|
||||
assert sorted(graph) == list(graph) |
|
||||
for layout, info in graph.items(): |
|
||||
info['next'] = sorted(info['next']) |
|
||||
return json.dumps(graph) |
|
||||
|
|
||||
|
|
||||
def format_2(raw: str) -> str: |
|
||||
graph = json.loads(raw)['graph'] |
|
||||
for layout, info in graph.items(): |
|
||||
graph[layout] = {'step': info['step'], 'next': info['next']} |
|
||||
return json.dumps(graph) |
|
||||
|
|
||||
|
|
||||
def compare(file_1: str, file_2: str) -> None: |
|
||||
print(f'{file_1} vs {file_2}') |
|
||||
data_1 = format_1(open(file_1).read()) |
|
||||
data_2 = format_2(open(file_2).read()) |
|
||||
assert data_1 == data_2 |
|
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
|
||||
for name in sorted(os.listdir('output-json')): |
|
||||
compare(f'output/{name}', f'output-json/{name}') |
|
Loading…
Reference in new issue