Class: Vizier::Graph
Constant Summary
Constants included
from Support
Support::LEGAL_CHARS
Instance Attribute Summary
Attributes inherited from SubGraph
#links, #name
Instance Method Summary
collapse
Methods inherited from SubGraph
#add_link, #add_node, #build, #edge, #graph, #node, #write_comment
Methods included from Support
#attributes, #attributes=, included, #legal?, #quote, #sanitize
Methods inherited from Base
#[], #[]=
Constructor Details
#initialize(name = 'my_graph', attrs = {}) {|_self| ... } ⇒ Graph
Returns a new instance of Graph.
295
296
297
298
299
|
# File 'lib/support/vizier.rb', line 295
def initialize(name = 'my_graph', attrs = {})
@subgraphs = []
super( name, attrs )
yield self if block_given?
end
|
Instance Method Details
#cluster(name = nil, a = {}, &block) ⇒ Object
283
284
285
286
287
288
289
|
# File 'lib/support/vizier.rb', line 283
def cluster(name = nil, a = {}, &block)
if name && name = "cluster_#{name}"
subgraph( name, a, &block )
else
clusters
end
end
|
291
292
293
|
# File 'lib/support/vizier.rb', line 291
def clusters
@subgraphs.select {|s| s.name =~ /^cluster_/ }.extend( Finder )
end
|
250
251
252
|
# File 'lib/support/vizier.rb', line 250
def ( str )
( str, 1 )
end
|
#publish!(a = {}) ⇒ Object
272
273
274
|
# File 'lib/support/vizier.rb', line 272
def publish!( a = {} )
generate! end
|
#subgraph(name, a = {}) ⇒ Object
276
277
278
279
280
281
|
# File 'lib/support/vizier.rb', line 276
def subgraph(name, a = {})
returning( SubGraph.new(name, a)) do |g|
@subgraphs << g
yield g if block_given?
end
end
|
#to_str ⇒ Object
Also known as:
generate!
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/support/vizier.rb', line 254
def to_str
build(["digraph #{quote name} {",
[
("global options"),
"graph #{graph};",
"node #{node};",
"edge #{edge};"
],
("nodes"),
nodes.map(&:to_str),
("links"),
links.map(&:to_str),
("subgraphs"),
subgraphs.map(&:to_str),
"}"])
end
|