Class: GraphMatching::Visualize
- Inherits:
-
Object
- Object
- GraphMatching::Visualize
- Defined in:
- lib/graph_matching/visualize.rb
Overview
Renders ‘GraphMatching::Graph` objects using `graphviz`.
Constant Summary collapse
- TMP_DIR =
'/tmp/graph_matching'
- USR_BIN_ENV =
'/usr/bin/env'
Instance Attribute Summary collapse
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
Instance Method Summary collapse
-
#dot ⇒ Object
‘dot` returns a string representing the graph, in .dot format.
-
#initialize(graph) ⇒ Visualize
constructor
A new instance of Visualize.
-
#png(base_filename) ⇒ Object
‘png` writes a “.png” file with graphviz and opens it.
Constructor Details
#initialize(graph) ⇒ Visualize
Returns a new instance of Visualize.
14 15 16 |
# File 'lib/graph_matching/visualize.rb', line 14 def initialize(graph) @graph = graph end |
Instance Attribute Details
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
12 13 14 |
# File 'lib/graph_matching/visualize.rb', line 12 def graph @graph end |
Instance Method Details
#dot ⇒ Object
‘dot` returns a string representing the graph, in .dot format. www.graphviz.org/content/dot-language
20 21 22 |
# File 'lib/graph_matching/visualize.rb', line 20 def dot RGL::DOT::Graph.new('elements' => dot_edges).to_s end |
#png(base_filename) ⇒ Object
‘png` writes a “.png” file with graphviz and opens it
25 26 27 28 29 30 31 |
# File 'lib/graph_matching/visualize.rb', line 25 def png(base_filename) check_that_dot_is_installed mk_tmp_dir abs_path = "#{TMP_DIR}/#{base_filename}.png" write_png(abs_path) system "open #{abs_path}" end |