Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gem usability #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.gem
.bundle
Gemfile.lock
pkg/*
*~
coverage/*
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: ruby
rvm:
- 1.9.3
notifications:
- [email protected]
before_script:
- "bundle exec rake setup"
script: "bundle exec rake test"
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in priority_queue.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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.
80 changes: 45 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 [email protected]

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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
14 changes: 14 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions lib/priority_queue/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module PriorityQueue
VERSION = "0.1.6"
end
23 changes: 23 additions & 0 deletions priority_queue.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ["[email protected]", "[email protected]"]
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