Method: Sfn::Command::Graph#generate_graph

Defined in:
lib/sfn/command/graph.rb

#generate_graph(template, args = {}) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/sfn/command/graph.rb', line 69

def generate_graph(template, args = {})
  graph = ::Graph.new
  @root_graph = graph unless @root_graph
  graph.graph_attribs << ::Graph::Attribute.new("overlap = false")
  graph.graph_attribs << ::Graph::Attribute.new("splines = true")
  graph.graph_attribs << ::Graph::Attribute.new("pack = true")
  graph.graph_attribs << ::Graph::Attribute.new('start = "random"')
  if args[:name]
    graph.name = "cluster_#{args[:name]}"
    labelnode_key = "cluster_#{args[:name]}"
    graph.plaintext << graph.node(labelnode_key)
    graph.node(labelnode_key).label args[:name]
  else
    graph.name = "root"
  end
  edge_detection(template, graph, args[:name].to_s.sub("cluster_", ""), args.fetch(:resource_names, []))
  graph
end