1 local gr
= require
"graph"
4 print("usage: lua render.lua FILE FORMAT")
5 print(" FORMAT: dot, neato, twopi, fdp, circo")
9 local fmt
= arg
[2] or "dot"
11 -- For simple formatted printing
13 local function printf(fmt
, ...)
14 print(string.format(fmt
, ...))
17 local function gshow(g
)
18 local fn
= os
.tmpname() .. ".dot"
20 os
.execute("dotty "..fn
)
24 -- Provide simple reference for frequently used functions (optional)
25 node
, edge
, subgraph
, cluster
, digraph
, strictdigraph
, ugraph
=
26 gr
.node
, gr
.edge
, gr
.subgraph
, gr
.cluster
, gr
.digraph
, gr
.strictdigraph
, gr
.graph
28 local f
, err
= assert(loadfile(arg
[1]))
31 printf("Generated '%s' format:", fmt
)
34 g
:render("pdf", "out.pdf", fmt
)