Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 04, 2012
Andreas Schörk aschoerk * fixed strongly_connected-test, rcov-usage, changed some Gemfile-En…
…tries to make it run..
0b9663f
Commits on Nov 05, 2012
Andreas Schörk aschoerk Now depend at least on jeweler 1.8.4 to support current bundler, corr…
…ected require-pathes in TestCycles
64738a6
3  .gitignore
View
@@ -0,0 +1,3 @@
+.idea
+coverage
+
10 Gemfile
View
@@ -7,8 +7,12 @@ source "http://rubygems.org"
# Include everything needed to run rake, tests, features, etc.
group :development do
gem "stream", "~> 0.5"
- gem "rspec", "~> 2.3.0"
- gem "bundler", "~> 1.0.0"
- gem "jeweler", "~> 1.5.2"
+ # gem "rspec", "~> 2.3.0"
+ # gem "bundler", "~> 1.2.1"
+ # gem "jeweler", "~> 1.5.2"
+ gem "bundler"
+ gem "rspec"
+ gem "jeweler", "~> 1.8.4"
gem "rcov", ">= 0"
+ gem "rake"
end
18 Gemfile.lock
View
@@ -3,12 +3,18 @@ GEM
specs:
diff-lcs (1.1.2)
git (1.2.5)
- jeweler (1.5.2)
- bundler (~> 1.0.0)
+ jeweler (1.8.4)
+ bundler (~> 1.0)
git (>= 1.2.5)
rake
+ rdoc
+ json (1.7.5)
+ json (1.7.5-java)
rake (0.8.7)
rcov (0.9.9)
+ rcov (0.9.9-java)
+ rdoc (3.12)
+ json (~> 1.4)
rspec (2.3.0)
rspec-core (~> 2.3.0)
rspec-expectations (~> 2.3.0)
@@ -20,11 +26,13 @@ GEM
stream (0.5)
PLATFORMS
+ java
ruby
DEPENDENCIES
- bundler (~> 1.0.0)
- jeweler (~> 1.5.2)
+ bundler
+ jeweler (~> 1.8.4)
+ rake
rcov
- rspec (~> 2.3.0)
+ rspec
stream (~> 0.5)
12 Rakefile
View
@@ -62,9 +62,15 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
-RSpec::Core::RakeTask.new(:rcov) do |spec|
- spec.pattern = 'spec/**/*_spec.rb'
- spec.rcov = true
+#RSpec::Core::RakeTask.new(:rcov) do |spec|
+# spec.pattern = 'spec/**/*_spec.rb'
+# spec.rcov = true
+#end
+
+require 'rcov/rcovtask'
+Rcov::RcovTask.new do |t|
+ t.test_files = FileList['test/*.rb']
+ # t.verbose = true # uncomment to see the executed command
end
task :default => :test
2  examples/canvas.rb
View
@@ -19,7 +19,7 @@
# ruby canvas.rb north/g.14.9.graphml &
File.open(filename) { |file|
- graph = DirectedAdjacencyGraph.from_graphxml(file)
+ graph = DirectedAdjacencyGraph.new.from_graphxml(file)
graph.write_to_graphic_file('gif', filename)
graph.write_to_graphic_file('plain', filename)
root = TkRoot.new{title "Ex1"}
69 test/TestComponents.rb
View
@@ -1,19 +1,21 @@
require 'test/unit'
-
+$: << "#{File.dirname(__FILE__)}/../lib"
+$: << "#{File.dirname(__FILE__)}"
require 'rgl/traversal'
require 'rgl/connected_components'
require 'rgl/adjacency'
+require 'rgl/dot'
require 'test_helper'
include RGL
def graph_from_string(s)
g = DirectedAdjacencyGraph.new(Array)
- s.split(/\n/).collect{|x| x.split(/->/)}.each do |a|
- from = a[0].strip
- a[1].split.each do |to|
- g.add_edge from,to
- end
+ s.split(/\n/).collect { |x| x.split(/->/) }.each do |a|
+ from = a[0].strip
+ a[1].split.each do |to|
+ g.add_edge from, to
+ end
end
g
end
@@ -22,18 +24,18 @@ class TestComponents < Test::Unit::TestCase
def setup
@dg = DirectedAdjacencyGraph.new(Array)
- edges = [[1,2],[2,3],[2,4],[4,5],[1,6],[6,4]]
- edges.each do |(src,target)|
+ edges = [[1, 2], [2, 3], [2, 4], [4, 5], [1, 6], [6, 4]]
+ edges.each do |(src, target)|
@dg.add_edge(src, target)
end
- @bfs = @dg.bfs_iterator(1)
- @dfs = @dg.dfs_iterator(1)
+ @bfs = @dg.bfs_iterator(1)
+ @dfs = @dg.dfs_iterator(1)
- @ug = AdjacencyGraph.new(Array)
- @ug.add_edges(*edges)
+ @ug = AdjacencyGraph.new(Array)
+ @ug.add_edges(*edges)
- @dg2 = graph_from_string(
-"a -> b f h
+ @dg2 = graph_from_string(
+ "a -> b f h
b -> c a
c -> d b
d -> e
@@ -45,21 +47,36 @@ def setup
end
def test_connected_components
- ccs = []
- @ug.each_connected_component { |c| ccs << c }
- assert_equal(1,ccs.size)
+ ccs = []
+ @ug.each_connected_component { |c| ccs << c }
+ assert_equal(1, ccs.size)
- ccs = []
- @ug.add_edge 10,11
- @ug.add_edge 33,44
- @ug.each_connected_component { |c| ccs << c.sort }
- assert_equal([[10, 11], [1, 2, 3, 4, 5, 6], [33,44]].sort,ccs.sort)
+ ccs = []
+ @ug.add_edge 10, 11
+ @ug.add_edge 33, 44
+ @ug.each_connected_component { |c| ccs << c.sort }
+ assert_equal([[10, 11], [1, 2, 3, 4, 5, 6], [33, 44]].sort, ccs.sort)
end
def test_strong_components
- vis = @dg2.strongly_connected_components
-
- assert_equal(4,vis.num_comp)
- assert_equal([["a", 3], ["b", 3], ["c", 3], ["d", 0], ["e", 0], ["f", 1], ["g", 1], ["h", 3], ["i", 3], ["j", 2]],vis.comp_map.to_a)
+ vis = @dg2.strongly_connected_components
+ @dg2.write_to_graphic_file('gif', "dg2")
+
+ assert_equal(4, vis.num_comp)
+ res = vis.comp_map.to_a.sort.reduce({}){|res,a|
+ if res.key?(a[1])
+ res[a[1]] << a[0]
+ else
+ res[a[1]] = [a[0]]
+ end
+ res
+ }
+ std_res = res.to_a.map {
+ |a|
+ [a[1][0],a[1]]
+ }.sort
+
+ assert_equal([["a",["a","b","c","h","i"]], ["d",["d","e"]],["f",["f","g"]],["j",["j"]]],std_res)
+ # assert_equal([["a", 3], ["b", 3], ["c", 3], ["d", 0], ["e", 0], ["f", 1], ["g", 1], ["h", 3], ["i", 3], ["j", 2]], vis.comp_map.to_a)
end
end
3  test/TestCycles.rb
View
@@ -1,4 +1,5 @@
-$LOAD_PATH << "../lib"
+$: << "#{File.dirname(__FILE__)}/../lib"
+$: << "#{File.dirname(__FILE__)}"
require 'test/unit'
require 'rgl/adjacency'
require 'test_helper'
2  test/TestGraph.rb
View
@@ -1,3 +1,5 @@
+$: << "#{File.dirname(__FILE__)}/../lib"
+$: << "#{File.dirname(__FILE__)}"
require 'test/unit'
require 'rgl/adjacency'
require 'test_helper'

No commit comments for this range

Something went wrong with that request. Please try again.