summaryrefslogtreecommitdiff
path: root/dot.lua
blob: b9c6fee5a351608d50ac8dafc15f490a1bb96209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env lua
local automaton = require "automaton"
local generate = require "generate"
local init = automaton(generate.trange(1, 25))


local function dump_edges (state, prefix, color)
	prefix = prefix or ""
	color = color or "gray"
	io.write(prefix, "edge [color=", color, "];\n")
	for i, v in ipairs(state) do
		io.write(prefix, string.format("%d -> %d;\n", v, i))
	end
end


print[[
digraph {
	node [style=filled];
	node [fillcolor="#ded"] 1 2 3 [fillcolor=green] 4 5 6 7 8 9;
	node [fillcolor="#dde"] 10 11 12 13 14 15 16;
	node [fillcolor="#fed"] 17 18 19 [fillcolor=red] 20 21 22 23 24 25;]]
dump_edges(init:left(), "\t", "red")
dump_edges(init:right(), "\t", "blue")
dump_edges(init:pivot(), "\t", "aqua")
dump_edges(init:up(), "\t", "purple")
dump_edges(init:down(), "\t", "darkgreen")
print"}"