Class: BrewDG::Graph
- Inherits:
-
Plexus::Digraph
- Object
- Plexus::Digraph
- BrewDG::Graph
- Defined in:
- lib/brew_dg/graph.rb
Instance Method Summary collapse
Instance Method Details
#isolated_vertices ⇒ Object
27 28 29 30 31 |
# File 'lib/brew_dg/graph.rb', line 27 def isolated_vertices vertices.select do |vertex| in_degree(vertex).zero? && out_degree(vertex).zero? end end |
#visualization ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/brew_dg/graph.rb', line 8 def visualization visualization = GraphViz.new(:G) isolated_vertices.each do |vertex| visualization.add_nodes(vertex.to_s) end edges.reduce(visualization) do |visualization, edge| manifest = edge.to_a.last left, right = edge.to_a.first(2).map do |package| visualization.add_nodes(package.to_s) end visualization.add_edges(left, right, (manifest)) visualization end end |