Skip to content

Error running the example code #4

@ragesoss

Description

@ragesoss

I tried running the example code from the README, but I'm stuck with an unexpected error. I'm running this on Debian 9, with Ruby 2.6.1.

I tried this code:

# maptest.rb
require 'ruby_vor'

points = [
  RubyVor::Point.new(120, 290),
  RubyVor::Point.new(110, 120),
  RubyVor::Point.new(160, 90.2),
  RubyVor::Point.new(3.14159265, 3.14159265)
]

# Compute the diagram & triangulation
comp = RubyVor::VDDT::Computation.from_points(points)

puts "The nearest-neighbor graph:"
pp comp.nn_graph

puts "\nThe minimum-spanning tree:"
pp comp.minimum_spanning_tree

# Just the triangulation
RubyVor::Visualizer.make_svg(comp, :name => 'tri.svg')

# Just the MST
RubyVor::Visualizer.make_svg(comp, :name => 'mst.svg', :triangulation => false, :mst => true)

# Voronoi diagram and the triangulation
RubyVor::Visualizer.make_svg(comp, :name => 'dia.svg', :voronoi_diagram => true)

It results in this output:

The nearest-neighbor graph:
[[2, 1, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]]

The minimum-spanning tree:
Traceback (most recent call last):
        3: from maptest.rb:17:in `<main>'
        2: from maptest.rb:17:in `minimum_spanning_tree'
        1: from /home/sage/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubyvor-0.1.4/lib/ruby_vor/priority_queue.rb:60:in `push'
/home/sage/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubyvor-0.1.4/lib/ruby_vor/priority_queue.rb:60:in `percolate_up': no implicit conversion to float from nil (TypeError)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions