Sha256: e692893bdd76853b7fd23783d789883adc6460780c9860d0753da504f7ea308c

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

$:.unshift( "../../lib" )
require 'graphviz'
require 'graphviz/theory'

g = GraphViz.digraph( "G", :path => "/usr/local/bin", :use => "fdp" ) do |g|
  g.node[:shape => "record"]

  g.start[:label => "Start"]
  g.task_1[:label => "Task #1 - Duration : 4d"]
  g.task_2[:label => "Task #2 - Duration : 5.25d"]
  g.task_3[:label => "Task #3 - Duration : 5.17d"]
  g.task_4[:label => "Task #4 - Duration : 6.33d"]
  g.task_5[:label => "Task #5 - Duration : 5.17d"]
  g.task_6[:label => "Task #6 - Duration : 4.5d"]
  g.task_7[:label => "Task #7 - Duration : 5.17d"]
  g.finish[:label => "End"]

  (g.start << g.task_1)[:weight => 0.0]
  (g.start << g.task_2)[:weight => 0.0]
  (g.task_1 << g.task_3)[:weight => 4.0]
  (g.task_1 << g.task_4)[:weight => 4.0]
  (g.task_2 << g.task_5)[:weight => 5.25]
  (g.task_3 << g.task_5)[:weight => 5.17]
  (g.task_4 << g.task_6)[:weight => 6.33]
  (g.task_5 << g.task_7)[:weight => 5.17]
  (g.task_6 << g.finish)[:weight => 4.5]
  (g.task_7 << g.finish)[:weight => 5.17]
end
g.output( :png => "PERT.png" )

t = GraphViz::Theory.new( g )

print "Ranges : "
rr = t.range
p rr
puts "Your graph contains circuits" if rr.include?(nil)

puts "Critical path : "
rrr = t.critical_path
print "\tPath :"
_ = ""
rrr[:path].each do |i|
  print _ + g.get_node_at_index(i-1).id
  _ = " -> "
end
puts
puts "\tDistance : #{rrr[:distance]}"

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ruby-graphviz-1.2.5 examples/theory/pert.rb
ruby-graphviz-1.2.4 examples/theory/pert.rb
ruby-graphviz-1.2.3 examples/theory/pert.rb
ruby-graphviz-1.2.2 examples/theory/pert.rb
ruby-graphviz-1.2.1 examples/theory/pert.rb
ruby-graphviz-1.2.0 examples/theory/pert.rb
ruby-graphviz-1.1.0 examples/theory/pert.rb
ruby-graphviz_c-1.1.1 examples/theory/pert.rb
ruby-graphviz_c-1.1.0 examples/theory/pert.rb
ruby-graphviz-1.0.9 examples/theory/pert.rb
ruby-graphviz-1.0.8 examples/theory/pert.rb