module RDG::RGL::AllowDuplicates

Public Instance Methods

to_dot_graph(params = {}) click to toggle source
# File lib/rdg/graph/rgl/allow_duplicates.rb, line 13
def to_dot_graph(params = {})
  params['name'] ||= self.class.name.gsub(/:/, '_')
  fontsize       = params['fontsize'] ? params['fontsize'] : '8'
  graph          = (directed? ? ::RGL::DOT::Digraph : ::RGL::DOT::Graph).new(params)
  edge_class     = directed? ? ::RGL::DOT::DirectedEdge : ::RGL::DOT::Edge

  each_vertex do |v|
    graph << ::RGL::DOT::Node.new(
        'name'     => v.object_id,
        'fontsize' => fontsize,
        'label'    => vertex_label(v)
    )
  end

  each_edge do |u, v|
    graph << edge_class.new(
        'from'     => u.object_id,
        'to'       => v.object_id,
        'fontsize' => fontsize
    )
  end

  graph
end
vertex_label(v) click to toggle source

Returns a label for vertex v. Default is v.to_s

# File lib/rdg/graph/rgl/allow_duplicates.rb, line 39
def vertex_label(v)
  v.to_s
end