diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42419b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.gem +.bundle +Gemfile.lock +pkg/* +*~ +coverage/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e1514c7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +rvm: + - 1.9.3 +notifications: + - ldonnet@cityway.fr +before_script: + - "bundle exec rake setup" +script: "bundle exec rake test" diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..dc389b1 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +# Specify your gem's dependencies in priority_queue.gemspec +gemspec diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..3f7b0dc --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2014 Luc Donnet + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 3e7c6ad..1a0b52a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# Ruby extension implementing a priority queue +# Ruby priority queue implementation + +[![Build Status](https://travis-ci.org/ldonnet/priority_queue.png)](http://travis-ci.org/ldonnet/priority_queue?branch=master) [![Dependency Status](https://gemnasium.com/ldonnet/priority_queue.png)](https://gemnasium.com/ldonnet/priority_queue) [![Code Climate](https://codeclimate.com/github/ldonnet/priority_queue.png)](https://codeclimate.com/github/ldonnet/priority_queue) -## Description This is a fibonacci-heap priority-queue implementation. That means insert: O(1) @@ -12,20 +13,14 @@ key operation. That makes PriorityQueue usable for algorithms like dijkstras shortest path algorithm, while PQueue is more suitable for Heapsort and the like. -## Legal stuff -(c) 2005 Brian Schröder - -Please submit bugreports to priority_queue@brian-schroeder.de - -This extension is under the same license as ruby. - -Do not hold me reliable for anything that happens to you, your programs or -anything else because of this extension. It worked for me, but there is no -guarantee it will work for you. - ## Requirements - * Ruby 1.8 - * c Compiler + * Ruby 1.8 or later + * c Compiler + +On Debian/Ubuntu/Kubuntu OS : +```sh +sudo apt-get install git gcc +``` ## Installation @@ -34,19 +29,16 @@ guarantee it will work for you. De-compress archive and enter its top directory. Then type: - ($ su) - # ruby setup.rb - -These simple step installs this program under the default -location of Ruby libraries. You can also install files into -your favorite directory by supplying setup.rb some options. -Try "ruby setup.rb --help". +```sh +bundle exec rake setup +``` ### Installing a ruby gem - ($ su) - # gem install PriorityQueue - +```sh +gem install priority_queue +``` + ## Usage In this priority queue implementation the queue behaves similarly to a hash @@ -100,14 +92,14 @@ suite. # Initialize with start node active[start_node] = 0 until active.empty? - u, distance = active.delete_min - distances[u] = distance - d = distance + 1 - u.neighbours.each do | v | - next unless d < distances[v] # we can't relax this one - active[v] = distances[v] = d - parents[v] = u - end + u, distance = active.delete_min + distances[u] = distance + d = distance + 1 + u.neighbours.each do | v | + next unless d < distances[v] # we can't relax this one + active[v] = distances[v] = d + parents[v] = u + end end parents end @@ -129,5 +121,23 @@ The results are shown here ![Runtime for graphs of up to 600_000 Nodes](doc/compare_big.png "Runtime for graphs of up to 600_000 Nodes") -## Todo - * Only write documentation once +More Information +---------------- + +More information can be found on the [project website on GitHub](.). +There is extensive usage documentation available [on the wiki](../../wiki). + +License +------- + +This project is licensed under the MIT license, a copy of which can be found in the [LICENSE](./LICENSE.md) file. + +Release Notes +------------- + +The release notes can be found in [CHANGELOG](./CHANGELOG.md) file + +Support +------- + +Users looking for support should file an issue on the GitHub [issue tracking page](../../issues), or file a [pull request](../../pulls) if you have a fix available. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..842df7b --- /dev/null +++ b/Rakefile @@ -0,0 +1,14 @@ +require "bundler/gem_tasks" +require 'rake/testtask' + +task default: %w[test] + +task :setup do + ruby "setup.rb" +end + +Rake::TestTask.new do |t| + t.libs << ["test", "ext"] + t.test_files = FileList['test/*.rb'] + t.verbose = true +end diff --git a/lib/priority_queue/version.rb b/lib/priority_queue/version.rb new file mode 100644 index 0000000..b32b690 --- /dev/null +++ b/lib/priority_queue/version.rb @@ -0,0 +1,3 @@ +module PriorityQueue + VERSION = "0.1.6" +end diff --git a/priority_queue.gemspec b/priority_queue.gemspec new file mode 100644 index 0000000..d77cc64 --- /dev/null +++ b/priority_queue.gemspec @@ -0,0 +1,23 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +require 'priority_queue/version' + +Gem::Specification.new do |spec| + spec.name = "priority_queue" + spec.version = PriorityQueue::VERSION + spec.authors = ["Brian Schröder", "Luc Donnet"] + spec.email = ["priority_queue@brian-schroeder.de", "luc.donnet@free.fr"] + spec.summary = %q{Ruby fibonacci-heap priority-queue implementation} + spec.description = %q{Ruby Fibonacci-heap priority-queue implementation} + spec.homepage = "https://github.com/ldonnet/priority-queue" + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0") + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ["lib", "ext"] + + spec.add_development_dependency "bundler", "~> 1.5" + spec.add_development_dependency "rake" +end