Sha256: 19b70318a6163c3ccc1ee27222bf43e4822a22d8251c7ae47650348e970a2d92

Contents?: true

Size: 317 Bytes

Versions: 1

Compression:

Stored size: 317 Bytes

Contents

module CognitiveDistance::Presenters
  class GraphToDot
    def present graph, name='graphname', &label
      label ||= lambda { |v| v.to_s }
      "digraph #{name.to_s.inspect} {\n" + graph.inject("") { |str, (v1,v2)|
        str << "#{label[v1].inspect} -> #{label[v2].inspect};\n"
      } + "}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cognitive_distance-0.0.1.pre lib/cognitive_distance/presenters/graph_to_dot.rb