Sha256: f968dca0d91c7ae2580d4173c82c4fbb00c4e356494aaee383edd4a2be254c2b
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
class GraphViz class FamilyTree class Couple def initialize( g, n ) #:nodoc: @graph = g @node = n end def node #:nodoc: @node end # Add kids to a couple def kids( *z ) if z.size == 1 @graph.add_edge( @node, z[0].node, "dir" => "none" ) else cluster = @graph.add_graph( "#{@node.name}Kids" ) cluster["rank"] = "same" last = nil count = 0 add = (z.size-1)%2 * z.size/2 + (z.size-1)%2 link = (z.size/2)+1 z.each do |person| count = count + 1 if count == add middle = cluster.add_node( "#{@node.name}Kids", "shape" => "point" ) @graph.add_edge( @node, middle, "dir" => "none" ) unless last.nil? cluster.add_edge( last, middle, "dir" => "none" ) end last = middle end kid = cluster.add_node( "#{person.node.name}Kid", "shape" => "point" ) @graph.add_edge( kid, person.node, "dir" => "none" ) if add == 0 and count == link @graph.add_edge( @node, kid, "dir" => "none" ) end unless last.nil? cluster.add_edge( last, kid, "dir" => "none" ) end last = kid end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-graphviz-0.9.11 | lib/graphviz/family_tree/couple.rb |