import json
content = open("reachability_trace.txt", 'r').readlines()

output = "digraph {\n"
output += "\toverlap=false;\n"
output += "\tsplines=true;\n"

for f in content:
    if "--[" in f:
        # Transition
        src, rem = f.split(" --[", 1)
        name, dst = rem.split("]--> ", 1)
        output += '\tnode_%s -> node_%s [label="%s"]\n' % (src.strip(), dst.strip(), name.strip())
    else:
        # Node
        name, value = f.split(": ", 1)
        output += '\tnode_%s [label="%s"]\n' % (name, ",".join([str(i[1]) for i in sorted(json.loads(value).items())]))
output += "}"

print(output)
