fixed graph._SYSTEM for Linux
[luagraph.git] / examples / subgraph.lua
blob88643798354df67bce8de982f37fd36558ec2aab
1 gr = require "graph"
3 --
4 -- simple printing
5 --
6 local function printf(fmt, ...)
7 print(string.format(fmt, ...))
8 end
10 --
11 -- Create a graph
13 local g = gr.open("G")
14 g:declare{
15 node = {shape = "circle", color = "blue"},
16 edge = {color = "green"}
19 -- Create a subgraph with different prototype
21 local sg = g:subgraph("SG")
22 assert(sg:declare{
23 node = {shape = "box", color="red"},
24 edge = {color="red"}
27 -- Some nodes and edges
29 g:edge{"n1", "n2", label = "n1=>n2"}
30 sg:edge{"n3", "n4", label = "n3=>n4"}
31 g:edge("n1", "n4", "n1=>n4")
34 -- Print prototypes
36 g:write()
37 g:show()
38 g:close()