Method: Puppet::Graph::SimpleGraph#to_dot_graph
- Defined in:
- lib/puppet/graph/simple_graph.rb
#to_dot_graph(params = {}) ⇒ Object
Return a DOT::DOTDigraph for directed graphs or a DOT::DOTSubgraph for an undirected Graph. params can contain any graph property specified in rdot.rb. If an edge or vertex label is a kind of Hash then the keys which match dot properties will be used as well.
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/puppet/graph/simple_graph.rb', line 448 def to_dot_graph(params = {}) params['name'] ||= self.class.name.tr(':', '_') fontsize = params['fontsize'] || '8' graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params) edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge vertices.each do |v| name = v.ref params = { 'name' => stringify(name), 'fontsize' => fontsize, 'label' => name } v_label = v.ref params.merge!(v_label) if v_label and v_label.is_a? Hash graph << DOT::DOTNode.new(params) end edges.each do |e| params = { 'from' => stringify(e.source.ref), 'to' => stringify(e.target.ref), 'fontsize' => fontsize } e_label = e.ref params.merge!(e_label) if e_label and e_label.is_a? Hash graph << edge_klass.new(params) end graph end |