Commit 3d9f5516 authored by Luc Libralesso's avatar Luc Libralesso
Browse files

rewrite graphviz viz interface + add graphviz output to test model shaving

parent d3a947b9
......@@ -14,7 +14,7 @@ class TestWriterGraphviz < Minitest::Unit::TestCase
def test_a()
dag = Midori128_Dag.new(nb_rounds=3)
# p get_graphviz(dag)
writefile_graphviz(dag, "test.dot")
writefile_graphviz(dag.atoms(), dag.operators(), "test.dot")
assert_equal(true,true)
end
end
\ No newline at end of file
......@@ -2,11 +2,14 @@ require_relative '../cryptodag.rb'
require_relative '../operators/elementary.rb'
require_relative '../constraints/all.rb'
require_relative './graphviz_atomic.rb'
def get_abstract_constraint_model(dag)
atoms = dag.atoms()
operators = dag.operators()
# shave dag to remove useless inputs and outputs
atoms2,operators2 = shave_dag(atoms, operators)
atoms2,operators2 = *shave_dag(atoms, operators)
writefile_graphviz(atoms2, operators2, "test.dot")
# create model
model = create_abstract_model(atoms, operators)
return model
......
......@@ -18,7 +18,7 @@ def get_shorthand_op_classname(c)
end
end
def get_graphviz(dag)
def get_graphviz(atoms, operators)
res = ""
res += "digraph {\n"
# digraph options
......@@ -28,7 +28,6 @@ def get_graphviz(dag)
# display operators
op_to_id = {}
id_to_op = {}
operators = dag.operators()
id = 0
operators.each do |op|
op_to_id[op] = id
......@@ -40,7 +39,6 @@ def get_graphviz(dag)
atom_to_id = {}
id_to_atom = {}
id = 0
atoms = dag.atoms()
atoms.each do |atom|
if !atom_to_id.key?(atom)
atom_to_id[atom] = id
......@@ -62,8 +60,8 @@ def get_graphviz(dag)
end
def writefile_graphviz(dag, filename)
def writefile_graphviz(atoms, operators, filename)
file = File.open(filename, "w")
file.puts(get_graphviz(dag))
file.puts(get_graphviz(atoms, operators))
file.close
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment