Class: RGL::DOT::Edge

Inherits:
Element show all
Defined in:
lib/laser/third_party/rgl/rdot.rb

Overview

This is an undirected edge representation.

Direct Known Subclasses

DirectedEdge

Instance Attribute Summary (collapse)

Attributes inherited from Element

#name, #options

Instance Method Summary (collapse)

Constructor Details

- (Edge) initialize(params = {}, option_list = EDGE_OPTS)

Creates a new Edge with the params Hash providing settings for all edge options. The option_list parameter restricts those options to the list of valid names it contains.



401
402
403
404
405
# File 'lib/laser/third_party/rgl/rdot.rb', line 401

def initialize (params = {}, option_list = EDGE_OPTS)
  super(params, option_list)
  @from = params['from'] ? params['from'] : nil
  @to   = params['to'] ? params['to'] : nil
end

Instance Attribute Details

- (Object) from

A node or subgraph reference or instance to be used as the starting point for an edge.



393
394
395
# File 'lib/laser/third_party/rgl/rdot.rb', line 393

def from
  @from
end

- (Object) to

A node or subgraph reference or instance to be used as the ending point for an edge.



396
397
398
# File 'lib/laser/third_party/rgl/rdot.rb', line 396

def to
  @to
end

Instance Method Details

- (Object) to_s(leader = '', indent = ' ')

Returns a string representation of this edge which is consumable by the graphviz tools dot and neato. The leader parameter is used to indent every line of the returned string, and the indent parameter is used to additionally indent nested items.



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/laser/third_party/rgl/rdot.rb', line 411

def to_s (leader = '', indent = '    ')
  stringified_options = @options.collect do |name, val|
    unless val.nil? then
      leader + indent + "#{quote_ID(name)} = #{quote_ID(val)}"
    end
  end.compact.join( ",\n" )

  f_s = @from || ''
  t_s = @to || ''
  if stringified_options.empty? then
    leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s)
  else
    leader + quote_ID(f_s) + ' ' + edge_link + ' ' + quote_ID(t_s) + " [\n" +
      stringified_options + "\n" +
      leader + "]"
  end
end