topological_sort 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/spec/topological_sort_spec.rb +26 -0
- data/{new.gemspec → topological_sort.gemspec} +4 -3
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -36,4 +36,30 @@ describe 'topological_sort' do
|
|
36
36
|
result.should == [5, 6, 7, 2, 8, 3, 9, 4, 1]
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
describe 'on a hairy graph with a cycle' do
|
41
|
+
before do
|
42
|
+
@graph = {1 => [2, 3, 4], 2 => [5, 6, 7], 3 => [6, 7, 8], 4 => [7, 8, 9],
|
43
|
+
8 => [11, 4]}
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'raises an exception' do
|
47
|
+
lambda {
|
48
|
+
topological_sort([1]) { |node| { :next => @graph[node] } }
|
49
|
+
}.should raise_error(ArgumentError)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'on a hairy graph with a self-reference' do
|
54
|
+
before do
|
55
|
+
@graph = {1 => [2, 3, 4], 2 => [5, 6, 7], 3 => [6, 7, 8], 4 => [7, 8, 9],
|
56
|
+
8 => [11, 8]}
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'raises an exception' do
|
60
|
+
lambda {
|
61
|
+
topological_sort([1]) { |node| { :next => @graph[node] } }
|
62
|
+
}.should raise_error(ArgumentError)
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = %q{topological_sort}
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Victor Costan"]
|
@@ -29,7 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/topological_sort.rb",
|
30
30
|
"spec/.rspec",
|
31
31
|
"spec/spec_helper.rb",
|
32
|
-
"spec/topological_sort_spec.rb"
|
32
|
+
"spec/topological_sort_spec.rb",
|
33
|
+
"topological_sort.gemspec"
|
33
34
|
]
|
34
35
|
s.homepage = %q{http://github.com/pwnall/new}
|
35
36
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topological_sort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Victor Costan
|
@@ -168,10 +168,10 @@ files:
|
|
168
168
|
- Rakefile
|
169
169
|
- VERSION
|
170
170
|
- lib/topological_sort.rb
|
171
|
-
- new.gemspec
|
172
171
|
- spec/.rspec
|
173
172
|
- spec/spec_helper.rb
|
174
173
|
- spec/topological_sort_spec.rb
|
174
|
+
- topological_sort.gemspec
|
175
175
|
has_rdoc: true
|
176
176
|
homepage: http://github.com/pwnall/new
|
177
177
|
licenses: []
|