Sha256: 98c0af9da3f5805d223ff6a47e4377561d8160e52aae0ff0c7d637f94aff2f11

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/ruby

$:.unshift( "../lib" );
require "graphviz"

GraphViz::new( "ER", :type => "graph", :output => "png", :use => "neato" ) { |graph|
  graph.node[:shape] = "box"
  graph.course; graph.institute; graph.student
  
  graph.node[:shape] = "ellipse"
  graph.name0(:label => "name")
  graph.name1(:label => "name")
  graph.name2(:label => "name")
  graph.code; graph.grade; graph.number
  
  graph.node[:shape] = "diamond"
  graph.node[:style] = "filled"
  graph.node[:color] = "lightgrey"
  graph.ci( :label => "C-I" )
  graph.sc( :label => "S-C" )
  graph.si( :label => "S-I" )

  graph.name0 << graph.course;
  graph.code << graph.course;
  
  (graph.course << graph.ci).set { |e|
    e.label = "n"
    e.len = "1.00"
  }
  
  e = (graph.ci << graph.institute)
  e.label = "1"
  e[:len] = "1.00"
  
  graph.institute << graph.name1;
  
  e = (graph.institute << graph.si)
  e[:label] = "1"
  e[:len] = "1.00"
  
  e = (graph.si << graph.student)
  e[:label] = "n"
  e[:len] = "1.00"
  
  graph.student << graph.grade
  graph.student << graph.name2
  graph.student << graph.number
  
  e = (graph.student << graph.sc)
  e[:label] = "m"
  e[:len] = "1.00"
  
  e = (graph.sc << graph.course)
  e[:label] = "n"
  e[:len] = "1.00"

  graph[:label] = "\\n\\nEntity Relation Diagram\\ndrawn by NEATO";
  graph[:fontsize] = "20";
}.output( :path => '/usr/local/bin/', :file => "#{$0}.png" )

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-graphviz-0.9.1 examples/sample19.rb
ruby-graphviz-0.9.0 examples/sample19.rb