Class: GraphViz

Inherits:
Object
  • Object
show all
Includes:
Constants, GVUtils
Defined in:
lib/graphviz/attrs.rb,
lib/graphviz.rb,
lib/graphviz/ext.rb,
lib/graphviz/xml.rb,
lib/graphviz/edge.rb,
lib/graphviz/node.rb,
lib/graphviz/types.rb,
lib/graphviz/theory.rb,
lib/graphviz/graphml.rb,
lib/graphviz/elements.rb,
lib/graphviz/nothugly.rb,
lib/graphviz/family_tree.rb,
lib/graphviz/math/matrix.rb,
lib/graphviz/types/gv_double.rb,
lib/graphviz/types/esc_string.rb,
lib/graphviz/types/lbl_string.rb,
lib/graphviz/types/html_string.rb,
lib/graphviz/family_tree/couple.rb,
lib/graphviz/family_tree/person.rb,
lib/graphviz/family_tree/sibling.rb,
lib/graphviz/family_tree/generation.rb

Overview

Copyright © 2004, 2005, 2006, 2007, 2008, 2009, 2010 Gregoire Lejeune <[email protected]>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Defined Under Namespace

Classes: Attrs, Edge, Elements, Ext, FamilyTree, GraphML, Math, Node, Theory, Types, XML

Constant Summary collapse

@@format =

Var: Output format (dot, png, jpeg, …)

nil
@@prog =

Var: program to use (dot|twopi)

"dot"
@@path =

Var: program path

[]
@@errors =

Var: Error level

1
@@extlibs =

Var: External libraries

[]

Constants included from Constants

Constants::EDGESATTRS, Constants::FORMATS, Constants::GENCS_ATTRS, Constants::GRAPHSATTRS, Constants::GRAPHTYPE, Constants::NODESATTRS, Constants::PROGRAMS, Constants::RGV_VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GVUtils

#escape_path_containing_blanks, #find_executable, #output_and_errors_from_command, #output_from_command

Methods included from Constants

getAttrsFor

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(idName, *args, &block) ⇒ Object

:nodoc:



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/graphviz.rb', line 307

def method_missing( idName, *args, &block ) #:nodoc:
  xName = idName.id2name

  rCod = nil
  
  if block
    # Creating a cluster named '#{xName}'
    rCod = add_graph( xName, args[0]||{} )
    yield( rCod )
  else
    # Create a node named '#{xName}' or search for a node, edge or cluster      
    if @hoNodes.keys.include?( xName )
      if( args[0] )
        return { xName => args[0] }
      else
        return( @hoNodes[xName] ) 
      end
    end
    return( @hoGraphs[xName] ) if @hoGraphs.keys.include?( xName )
          
    rCod = add_node( xName, args[0]||{} )
  end

  return rCod
end

Instance Attribute Details

#edgeObject Also known as: edge_attrs

This accessor allow you to set global edges attributs



81
82
83
# File 'lib/graphviz.rb', line 81

def edge
  @edge
end

#graphObject

This accessor allow you to set global graph attributs



73
74
75
# File 'lib/graphviz.rb', line 73

def graph
  @graph
end

#nodeObject Also known as: node_attrs

This accessor allow you to set global nodes attributs



77
78
79
# File 'lib/graphviz.rb', line 77

def node
  @node
end

Class Method Details

.commonGraph(o1, o2) ⇒ Object

:nodoc:



674
675
676
677
678
679
680
681
682
683
684
# File 'lib/graphviz.rb', line 674

def self.commonGraph( o1, o2 ) #:nodoc:
  g1 = o1.pg
  g2 = o2.pg

  return o1 if g1.nil?
  return o2 if g2.nil?
  
  return g1 if g1.object_id == g2.object_id
  
  return GraphViz::commonGraph( g1, g2 )
end

.default(hOpts) ⇒ Object

Change default options (:use, :path, :errors and :output)



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/graphviz.rb', line 699

def self.default( hOpts )
  hOpts.each do |k, v|
    case k.to_s
      when "use"
        @@prog = v
      when "path"
        @@path = v.split( "," ).map{ |x| x.strip }
      when "errors"
        @@errors = v
      when "extlibs"
        @@extlibs = v.split( "," ).map{ |x| x.strip }
      else
        warn "Invalide option #{k}!"
    end
  end
end

.nothugly(file, save = true) ⇒ Object

Transform to pretty up the SVG output

For more information, see www.hokstad.com/making-graphviz-output-pretty-with-xsl.html and www.hokstad.com/making-graphviz-output-pretty-with-xsl-updated.html

You can use the :nothugly option to GraphViz#output :

graph.output( :svg => "myGraph.svg", :nothugly => true )

Or directly on an SVG output graph :

GraphViz.nothugly( "myGraph.svg" )


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/graphviz/nothugly.rb', line 26

def self.nothugly( file, save = true )
  xslt = XML::XSLT.new()
  xslt.xml = file
  xslt.xsl = File.join( File.dirname(File.expand_path(__FILE__)), "nothugly", "nothugly.xsl" )

  out = xslt.serve()

  if save
    fname = File.join( File.dirname(File.expand_path(file)), File.basename(file))
    File.open( fname, "w" ) { |io|
      io.print out
    }
  else
    return out
  end
end

.options(hOpts) ⇒ Object



716
717
718
# File 'lib/graphviz.rb', line 716

def self.options( hOpts )
  GraphViz::default( hOpts )
end

.parse(xFile, hOpts = {}) {|graph| ... } ⇒ Object

Create a new graph from a GraphViz File

Options :

  • :output : Output format (Constants::FORMATS) (default : dot)

  • :file : Output file name (default : none)

  • :use : Program to use (Constants::PROGRAMS) (default : dot)

  • :path : Program PATH

Yields:

  • (graph)


731
732
733
734
735
# File 'lib/graphviz.rb', line 731

def self.parse( xFile, hOpts = {}, &block ) 
  graph = Dot2Ruby::new( hOpts[:path], nil, nil ).eval( xFile )
  yield( graph ) if( block and graph.nil? == false )
  return graph
end

Instance Method Details

#<<(oNode) ⇒ Object Also known as: >, -, >>

Create an edge between the current cluster and the node or cluster oNode

Raises:

  • (ArgumentError)


648
649
650
651
652
653
654
655
656
657
658
# File 'lib/graphviz.rb', line 648

def <<( oNode )
  raise( ArgumentError, "Edge between root graph and node or cluster not allowed!" ) if self.pg.nil?

  if( oNode.class == Array ) 
    oNode.each do |no|
      self << no
    end
  else
    return GraphViz::commonGraph( oNode, self ).add_edge( self, oNode )
  end
end

#[](xAttrName) ⇒ Object

Get the value of the graph attribut xAttrName



344
345
346
347
348
349
350
351
352
# File 'lib/graphviz.rb', line 344

def []( xAttrName )
  if Hash === xAttrName
    xAttrName.each do |key, value|
      self[key] = value
    end
  else
    return( @graph[xAttrName].clone )
  end
end

#[]=(xAttrName, xValue) ⇒ Object

Set value xValue to the graph attribut xAttrName



336
337
338
339
# File 'lib/graphviz.rb', line 336

def []=( xAttrName, xValue )
  xValue = xValue.to_s if xValue.class == Symbol
  @graph[xAttrName] = xValue
end

#add(h) ⇒ Object

Add nodes and edges defined by a Hash



285
286
287
288
289
290
291
# File 'lib/graphviz.rb', line 285

def add(h)
  if h.kind_of? Hash
    h.each do |node, data|
      add_hash_edge(node, data)
    end
  end 
end

#add_edge(oNodeOne, oNodeTwo, hOpts = {}) ⇒ Object

Create a new edge

In:

  • oNodeOne : First node (or node list)

  • oNodeTwo : Second Node (or node list)

  • hOpts : Edge attributs



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/graphviz.rb', line 165

def add_edge( oNodeOne, oNodeTwo, hOpts = {} )
  
  if( oNodeOne.class == Array ) 
    oNodeOne.each do |no|
      add_edge( no, oNodeTwo, hOpts )
    end
  else
    if( oNodeTwo.class == Array )
      oNodeTwo.each do |nt|
        add_edge( oNodeOne, nt, hOpts )
      end
    else
      oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo, self )
      oEdge.index = @elements_order.size_of( "edge" )
      
      hOpts.each do |xKey, xValue|
        oEdge[xKey.to_s] = xValue
      end
      
      @elements_order.push( { 
        "type" => "edge", 
        "value" => oEdge
      } )
      @loEdges.push( oEdge )
      
      return( oEdge )
    end
  end
end

#add_graph(xGraphName = nil, hOpts = {}, &block) ⇒ Object Also known as: subgraph

Create a new graph

In:

  • xGraphName : Graph name

  • hOpts : Graph attributs



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/graphviz.rb', line 230

def add_graph( xGraphName = nil, hOpts = {}, &block )
  if xGraphName.kind_of?(Hash)
    hOpts = xGraphName
    xGraphName = nil
  end

  if xGraphName.nil?
    xGraphID = String.random(11)
    xGraphName = ""
  else
    xGraphID = xGraphName
  end
  
  @hoGraphs[xGraphID] = GraphViz::new( xGraphName, {:parent => self, :type => @oGraphType}, &block )
 
  hOpts.each do |xKey, xValue|
    @hoGraphs[xGraphID][xKey.to_s] = xValue
  end
  
  @elements_order.push( { 
    "type" => "graph", 
    "name" => xGraphName,
    "value" => @hoGraphs[xGraphID] 
  } )
  
  return( @hoGraphs[xGraphID] )
end

#add_node(xNodeName, hOpts = {}) ⇒ Object

Create a new node

In:

  • xNodeName : Name of the new node

  • hOpts : Node attributs

Return the GraphViz::Node object created



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/graphviz.rb', line 95

def add_node( xNodeName, hOpts = {} )
  return @hoNodes[xNodeName] || Proc.new {
    @hoNodes[xNodeName] = GraphViz::Node::new( xNodeName, self )
    @hoNodes[xNodeName].index = @elements_order.size_of( "node" )
  
    unless hOpts.keys.include?(:label) or hOpts.keys.include?("label")
      hOpts[:label] = xNodeName
    end
    
    hOpts.each do |xKey, xValue|
      @hoNodes[xNodeName][xKey.to_s] = xValue
    end
  
    @elements_order.push( { 
      "type" => "node", 
      "name" => xNodeName,
      "value" => @hoNodes[xNodeName] 
    } )
  
    return( @hoNodes[xNodeName] )
  }.call
end

#each_attribut(&b) ⇒ Object

Calls block once for each attribut of the graph, passing the name and value to the block as a two-element array.



358
359
360
361
362
# File 'lib/graphviz.rb', line 358

def each_attribut(&b)
  @graph.each do |k,v|
    yield(k,v)
  end
end

#each_edge(&block) ⇒ Object

Allow you to traverse edges



198
199
200
201
202
203
204
205
206
# File 'lib/graphviz.rb', line 198

def each_edge( &block )
  if block_given?
    @loEdges.each do |edge|
      yield(edge)
    end
  else
    return @loEdges
  end
end

#each_graph(&block) ⇒ Object

Allow you to traverse graphs



272
273
274
275
276
277
278
279
280
# File 'lib/graphviz.rb', line 272

def each_graph( &block )
  if block_given?
    @hoGraphs.each do |name, graph|
      yield( name, graph )
    end
  else
    return @hoGraphs
  end
end

#each_node(&block) ⇒ Object

Allow you to traverse nodes



140
141
142
143
144
145
146
147
148
# File 'lib/graphviz.rb', line 140

def each_node( &block )
  if block_given?
    @hoNodes.each do |name, node|
      yield( name, node )
    end
  else
    return( @hoNodes )
  end
end

#edge_countObject

Get the number of edges



211
212
213
# File 'lib/graphviz.rb', line 211

def edge_count
  @loEdges.size
end

#get_edge_at_index(index) ⇒ Object

Return the edge object for the given index



218
219
220
221
# File 'lib/graphviz.rb', line 218

def get_edge_at_index( index )
  element = @elements_order[index, "edge"]
  (element.nil?) ? nil : element["value"]
end

#get_graph(xGraphName) {|graph| ... } ⇒ Object

Return the graph object for the given name (or nil)

Yields:

  • (graph)


261
262
263
264
265
266
267
# File 'lib/graphviz.rb', line 261

def get_graph( xGraphName, &block )
  graph = @hoGraphs[xGraphName] || nil
  
  yield( graph ) if( block and graph.nil? == false )
  
  return graph
end

#get_node(xNodeName) {|node| ... } ⇒ Object

Return the node object for the given name (or nil)

Yields:



121
122
123
124
125
126
127
# File 'lib/graphviz.rb', line 121

def get_node( xNodeName, &block )
  node = @hoNodes[xNodeName] || nil
  
  yield( node ) if( block and node.nil? == false )
  
  return node
end

#get_node_at_index(index) ⇒ Object

Return the node object for the given index



132
133
134
135
# File 'lib/graphviz.rb', line 132

def get_node_at_index( index )
  element = @elements_order[index, "node"]
  (element.nil?) ? nil : element["value"]
end

#graph_attrsObject

This accessor allow you to set global graph attributs



74
75
76
# File 'lib/graphviz.rb', line 74

def graph
  @graph
end

#graph_countObject

Get the number of graphs



303
304
305
# File 'lib/graphviz.rb', line 303

def graph_count
  @hoGraphs.size
end

#nameObject Also known as: id

Get the graph name



640
641
642
# File 'lib/graphviz.rb', line 640

def name 
  @name.clone
end

#node_countObject

Get the number of nodes



153
154
155
# File 'lib/graphviz.rb', line 153

def node_count
  @hoNodes.size
end

#output(hOpts = {}) ⇒ Object Also known as: save

Generate the graph

Options :

  • :output : Output format (Constants::FORMATS)

  • :file : Output file name

  • :use : Program to use (Constants::PROGRAMS)

  • :path : Program PATH

  • :<format> => <file> : <file> can be

    • a file name

    • nil, then the output will be printed to STDOUT

    • String, then the output will be returned as a String

  • :errors : DOT error level (default 1)

    • 0 = Error + Warning

    • 1 = Error

    • 2 = none



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/graphviz.rb', line 381

def output( hOpts = {} )
  xDOTScript = ""
  xLastType = nil
  xSeparator = ""
  xData = ""
  lNotHugly = []

  @elements_order.each { |kElement|
    if xLastType.nil? == true or xLastType != kElement["type"]
      
      if xData.length > 0 
        case xLastType
          when "graph_attr"
            xDOTScript << "  " + xData + ";\n"

          when "node_attr"
            xDOTScript << "  node [" + xData + "];\n"
          
          when "edge_attr"
            xDOTScript << "  edge [" + xData + "];\n"
        end
      end
      
      xSeparator = ""
      xData = ""
    end

    xLastType = kElement["type"]

    #Modified by
    #Brandon Coleman 
    #verify value is NOT NULL
    if kElement["value"] == nil then
      raise ArgumentError, "#{kElement["name"]} has a nil value!"
    end

    case kElement["type"]
      when "graph_attr"
        xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
        xSeparator = "; "

      when "node_attr"
        xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
        xSeparator = ", "

      when "edge_attr"
        xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
        xSeparator = ", "

      when "node"
        xDOTScript << "  " + kElement["value"].output() + "\n"

      when "edge"
        xDOTScript << "  " + kElement["value"].output( @oGraphType ) + "\n"

      when "graph"
        xDOTScript << kElement["value"].output() + "\n"

      else
        raise ArgumentError, "Don't know what to do with element type '#{kElement['type']}'"
    end
  }
  
  if xData.length > 0 
    case xLastType
      when "graph_attr"
        xDOTScript << "  " + xData + ";\n"

      when "node_attr"
        xDOTScript << "  node [" + xData + "];\n"
      
      when "edge_attr"
        xDOTScript << "  edge [" + xData + "];\n"
    end
  end
  xDOTScript << "}"

  if @oParentGraph.nil? == false
    xDOTScript = "subgraph #{GraphViz.escape(@name, :unquote_empty => true)} {\n" << xDOTScript

    return( xDOTScript )
  else
    hOutput = {}
    
    hOpts.each do |xKey, xValue|
      xValue = xValue.to_s unless xValue.nil? or [Class, TrueClass, FalseClass].include?(xValue.class)
      case xKey.to_s
        when "use"
          if PROGRAMS.index( xValue ).nil? == true
            raise ArgumentError, "can't use '#{xValue}'"
          end
          @prog = xValue
        when "path"
          @path = xValue.split( "," ).map{ |x| x.strip }
        when "errors"
          @errors = xValue
        when "extlib"
          @extlibs = xValue.split( "," ).map{ |x| x.strip }
        when "scale"
          # Scale input by 'v' (=72)
          @scale = xValue
        when "inverty"
          # Invert y coordinate in output
          @inverty = xValue
        when "no_layout"
          # No layout mode 'v' (=1)
          @no_layout = xValue
        when "reduce"
          # Reduce graph
          @reduce_graph = xValue
        when "Lg"
          # Don't use grid
          @Lg = xValue
        when "LO"
          # Use old attractive force
          @LO = xValue
        when "Ln"
          # Set number of iterations to i
          @Ln = xValue
        when "LU"
          # Set unscaled factor to i
          @LU = xValue
        when "LC"
          # Set overlap expansion factor to v
          @LC = xValue
        when "LT"
          # Set temperature (temperature factor) to v
          @LT = xValue
        when "nothugly"
          begin
            require 'graphviz/nothugly'
            @nothugly = true
          rescue
            warn "You must install ruby-xslt to use nothugly option!"
            @nothugly = false
          end
        else
          if FORMATS.index( xKey.to_s ).nil? == true
            raise ArgumentError, "output format '#{xValue}' invalid"
          end
          hOutput[xKey.to_s] = xValue
      end
    end
    
    @output = hOutput if hOutput.size > 0

    xStict = ((@strict && @oGraphType == "digraph") ? "strict " : "")
    xDOTScript = ("#{xStict}#{@oGraphType} #{GraphViz.escape(@name, :unquote_empty => true)} {\n" << xDOTScript).gsub( "\0", "" )

    xOutputString = (@filename == String ||
      @output.any? {|format, file| file == String })
      
    xOutput = ""
    if @format.to_s == "none" or @output.any? {|fmt, fn| fmt.to_s == "none"}
      if xOutputString
        xOutput << xDOTScript
      else
        xFileName = @output["none"] || @filename
        open( xFileName, "w" ) do |h|
          h.puts xDOTScript
        end
      end
    end
    
    if (@format.to_s != "none" and not @format.nil?) or (@output.any? {|format, file| format != "none" } and @output.size > 0)
      ## Act: Save script and send it to dot
      t = Tempfile::open( File.basename(__FILE__) )
      t.print( xDOTScript )
      t.close
      
      cmd = find_executable( @prog, @path )
      if cmd == nil
        raise StandardError, "GraphViz not installed or #{@prog} not in PATH. Install GraphViz or use the 'path' option"
      end

      cmd = escape_path_containing_blanks(cmd) if IS_JRUBY

      xOutputWithFile = ""
      xOutputWithoutFile = ""
      unless @format.nil? or @format == "none"
        lNotHugly << @filename if @format.to_s == "svg" and @nothugly
        if @filename.nil? or @filename == String
          xOutputWithoutFile = "-T#{@format} "
        else
          xOutputWithFile = "-T#{@format} -o#{@filename} "
        end
      end
      @output.each_except( :key => ["none"] ) do |format, file|
        lNotHugly << file if format.to_s == "svg" and @nothugly
        if file.nil? or file == String
          xOutputWithoutFile << "-T#{format} "
        else
          xOutputWithFile << "-T#{format} -o#{file} "
        end
      end
      
      xExternalLibraries = ""
      @extlibs.each do |lib|
        xExternalLibraries << "-l#{lib} "
      end
      
      xOtherOptions = ""        
      xOtherOptions += " -s#{@scale}" unless @scale.nil?
      xOtherOptions += " -y" if @inverty == true
      unless @no_layout.nil?
        xOtherOptions += " -n"
        xOtherOptions += "2" if @no_layout.to_i == 2
      end
      xOtherOptions += " -x" if @reduce_graph == true
      xOtherOptions += " -Lg" if @Lg == true
      xOtherOptions += " -LO" if @LO == true
      xOtherOptions += " -Ln#{@Ln}" unless @LN.nil?
      xOtherOptions += " -LU#{@LU}" unless @LU.nil?
      xOtherOptions += " -LC#{@LC}" unless @LC.nil?
      xOtherOptions += " -LT#{@LT}" unless @LT.nil?
      
      if IS_JRUBY
        xCmd = "#{cmd} -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
      elsif IS_CYGWIN
        tmpPath = t.path
        begin
          tmpPath = "'" + `cygpath -w #{t.path}`.chomp + "'"
        rescue
          warn "cygpath is not installed!"
        end
        xCmd = "\"#{cmd}\" -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{tmpPath}"
      else
        xCmd = "\"#{cmd}\" -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
      end

      xOutput << output_from_command( xCmd )
    end
    
    # Not Hugly
    lNotHugly.each do |f|
      if f.nil? or f == String
        xOutput = GraphViz.nothugly( xOutput, false )
      else
        GraphViz.nothugly( f, true )
      end
    end
    
    if xOutputString
      xOutput
    else
      print xOutput
    end
  end
end

#pgObject

:nodoc:



663
664
665
# File 'lib/graphviz.rb', line 663

def pg #:nodoc:
  @oParentGraph
end

#root_graphObject

Return the root graph



670
671
672
# File 'lib/graphviz.rb', line 670

def root_graph
  return( (self.pg.nil?) ? self : self.pg.root_graph )
end

#set_position(xType, xKey, xValue) ⇒ Object

:nodoc:



686
687
688
689
690
691
692
# File 'lib/graphviz.rb', line 686

def set_position( xType, xKey, xValue ) #:nodoc:
  @elements_order.push( { 
    "type" => "#{xType}_attr", 
    "name" => xKey,
    "value" => xValue 
  } )
end

#to_sObject



633
634
635
# File 'lib/graphviz.rb', line 633

def to_s
  self.output(:none => String)
end

#typeObject

Return the graph type (graph digraph)



296
297
298
# File 'lib/graphviz.rb', line 296

def type
  @oGraphType
end