Skip to content

Nymphium/lua-graphviz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lua-Graphviz

Graphviz for Lua

usage

local Graphviz = require("graphviz")

local graph = Graphviz()

install

luarocks install graphviz or git clone https://github.com/nymphium/lua-graphviz && cd lua-graphviz && luarocks make

function

graph:node(nodename, label)

add a node

graph:edge(...)

add a edges

args[1] -> args[2]
args[1] -> args[3]
...
args[1] -> args[n]

graph:source()

return graph as string

digraph {
	graph []
	node []
	edge []
		a [label="hoge"]
		b [label="huga"]
			a -> b
}

graph:write(filename)

write dot file to (filename)

graph:compile(filename, format = "pdf", generated_filename = ("%s.%s"):format(filename, format))

write dot file to (filename) and compile the file (dot -T format filename generated_filename)

graph:render(filename, format = "pdf", generated_filename = ("%s.%s"):format(filename, format))

write dot file to (filename), compile the dot file as format, and open the generated file

it only calls graph:write(filename), graph:compile(filename, format, generated_file) and io.pcall(()"xdg-open %s &"):format(generated_filename))

graph:render("file", "pdf")

graph.nodes.style:update(styles), graph.edges.style:update(styles, graph.graph.style:update(styles)

update each style

graph.nodes.style:update{
	fontname = "Inconsolata Regular",
	shape = "rectangle"
}

LICENSE

MIT