1 local gr
= require
"graph"
6 print("usage: lua renderall.lua FILE FORMAT")
7 print(" FORMAT: dot, neato, twopi, fdp, circo")
8 print(" FILE: Lua file defining and returning graph")
12 local layoutfmt
= arg
[2] or "dot"
14 -- For simple formatted printing
16 local function printf(layoutfmt
, ...)
17 print(string.format(layoutfmt
, ...))
20 local function gshow(g
)
21 local fn
= os
.tmpname() .. ".dot"
23 os
.execute("dotty "..fn
)
27 -- Provide simple reference for frequently used functions (optional)
28 node
, edge
, subgraph
, cluster
, digraph
, strictdigraph
, ugraph
=
29 gr
.node
, gr
.edge
, gr
.subgraph
, gr
.cluster
, gr
.digraph
, gr
.strictdigraph
, gr
.graph
31 local f
, err
= assert(loadfile(arg
[1]))
32 local g
= f(layoutfmt
)
34 printf("Generated '%s' format.", layoutfmt
)
35 if string.find(layoutfmt
, "nop") then
40 os
.execute("rm -rf outdir")
41 os
.execute("mkdir -p outdir")
44 cairo
= 1,lasi
= 1, map
= 1, quartz
= 1
47 local sys
= io
.popen("uname"):read()
48 local fmtlist
, err
= gr
.plugins("render")
49 print("available formats: ".. table.concat(fmtlist
, " "))
50 print("system: "..sys
)
51 for _
, fmt
in ipairs(fmtlist
) do
52 local fname
= "outdir/out."..fmt
53 if (not notworking
[sys
][fmt
]) then
54 printf("Rendering on system %q with format %q into file %q", sys
, fmt
, fname
)
55 local stat
, rv
, err
= pcall(g
.render
, g
, fmt
, fname
, "dot")
57 if rv
== nil then break end