Sha256: c0a6b5b91772efba0f62ff6882a316053171afd78eb7ea41c2336283d7b9d493

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 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

13 entries across 13 versions & 1 rubygems

Version Path
ruby-graphviz-1.0.7 examples/theory/pert.rb
ruby-graphviz-1.0.6 examples/theory/pert.rb
ruby-graphviz-1.0.5 examples/theory/pert.rb
ruby-graphviz-1.0.4 examples/theory/pert.rb
ruby-graphviz-1.0.3 examples/theory/pert.rb
ruby-graphviz-1.0.2 examples/theory/pert.rb
ruby-graphviz-1.0.1 examples/theory/pert.rb
ruby-graphviz-1.0.0 examples/theory/pert.rb
ruby-graphviz-0.9.21 examples/theory/pert.rb
ruby-graphviz-0.9.20 examples/theory/pert.rb
ruby-graphviz-0.9.19 examples/theory/pert.rb
ruby-graphviz-0.9.18 examples/theory/pert.rb
ruby-graphviz-0.9.17 examples/theory/pert.rb