Class: HybridPlatformsConductor::Topographer::Plugins::Graphviz
- Inherits:
-
HybridPlatformsConductor::Topographer::Plugin
- Object
- HybridPlatformsConductor::Topographer::Plugin
- HybridPlatformsConductor::Topographer::Plugins::Graphviz
- Defined in:
- lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb
Overview
Output in Graphviz format
Direct Known Subclasses
Instance Method Summary collapse
-
#write_graph(file_name) ⇒ Object
Output the nodes graph in a file [API] - This method is mandatory.
Methods inherited from HybridPlatformsConductor::Topographer::Plugin
Constructor Details
This class inherits a constructor from HybridPlatformsConductor::Topographer::Plugin
Instance Method Details
#write_graph(file_name) ⇒ Object
Output the nodes graph in a file
- API
-
This method is mandatory.
-
- Parameters
-
file_name (String): The file name for output
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb', line 15 def write_graph(file_name) # GraphViz format does not support that nodes belong to more than 1 cluster. @topographer.force_cluster_strict_hierarchy # Write a Graphviz file File.open(file_name, 'w') do |f| f.puts 'digraph unix { size="6,6"; node [style=filled];' # First write the definition of all nodes # Find all nodes belonging to no cluster orphan_nodes = @topographer.nodes_graph.keys @topographer.nodes_graph.each do |node_name, node_info| orphan_nodes -= node_info[:includes] end orphan_nodes.sort.each do |node_name| write_node_def_gv(f, node_name) end # Then write all connections @topographer.nodes_graph.sort.each do |node_name, node_info| node_info[:connections].each do |connected_node_name, labels| link_label = labels.sort.join(', ') link_label = "#{link_label[0..@topographer.config[:max_link_label_length] - 1]}..." if link_label.size > @topographer.config[:max_link_label_length] = { label: link_label } f.puts " \"#{dot_name_for_link(node_name)}\" -> \"#{dot_name_for_link(connected_node_name)}\" [ #{.map { |opt, val| "#{opt}=\"#{val}\"" }.join(' ') } ];" end end f.puts '}' end end |