Permalink
Browse files

All tests pass on 1.8.7 and 1.9.2. Unsure about 1.8.6: I expect the f…

…ix I made for resolving Enumerator will not work in 1.8.6.
  • Loading branch information...
Michael Edgar
Michael Edgar committed Mar 3, 2011
1 parent c3e88cd commit b205e25b3dc1c3efb50deade60725d637bdad528
View
@@ -116,7 +116,7 @@ def transitive_reduction
# Only add the edge v -> w if there is no other edge v -> x such that
# w is reachable from x. Make sure to completely skip the case where
# x == w.
- unless Enumerable::Enumerator.new(cg, :each_adjacent, v).any? do |x|
+ unless Enumerator.new(cg, :each_adjacent, v).any? do |x|
x != w && paths_from[x].include?(w)
end then
tr_cg.add_edge(v, w)
@@ -157,7 +157,7 @@ def transitive_reduction
# Choose a single edge between the members of two different strongly
# connected component to add to the graph.
- edges = Enumerable::Enumerator.new(self, :each_edge)
+ edges = Enumerator.new(self, :each_edge)
tr_cg.each_adjacent(scc) do |scc2|
g.add_edge(
*edges.find do |v, w|
View
@@ -40,7 +40,7 @@ def test_add
assert_equal([1,2],dg.vertices.sort)
assert([DirectedEdge.new(1,2)].eql?(dg.edges))
- assert_equal("(1-2)",dg.edges.to_s)
+ assert_equal("(1-2)",dg.edges.join)
assert_equal([2],dg.adjacent_vertices(1))
assert_equal([],dg.adjacent_vertices(2))
@@ -80,7 +80,7 @@ def test_remove_edges
@dg.remove_vertex 3
assert !@dg.has_vertex?(3)
assert !@dg.has_edge?(2,3)
- assert_equal("(2-4)",@dg.to_s)
+ assert_equal('(2-4)',@dg.edges.join)
end
def test_add_vertices
@@ -94,8 +94,8 @@ def test_add_vertices
def test_creating_from_array
dg = DirectedAdjacencyGraph[1, 2, 3, 4]
- assert_equal(dg.vertices.sort, [1,2,3,4])
- assert_equal(dg.edges.to_s, "(1-2)(3-4)")
+ assert_equal([1,2,3,4], dg.vertices.sort)
+ assert_equal('(1-2)(3-4)', dg.edges.join)
end
def test_reverse
@@ -115,11 +115,11 @@ def test_reverse
end
assert(reverted.has_vertex?(42),
- "Reverted graph should contain isolated Vertex 42")
+ 'Reverted graph should contain isolated Vertex 42')
end
def test_to_undirected
undirected = @dg.to_undirected
- assert_equal undirected.edges.sort.to_s, "(1=2)(2=3)(2=4)"
+ assert_equal '(1=2)(2=3)(2=4)', undirected.edges.sort.join
end
end
View
@@ -19,8 +19,8 @@ def tear_down
end
def test_graphxml
- @dg = DirectedAdjacencyGraph.new.from_graphxml(@stream).to_s
- assert_equal("(n0-n1)(n0-n2)(n0-n9)(n3-n4)(n4-n5)(n5-n7)(n8-n0)(n8-n3)(n8-n4)(n8-n5)(n8-n6)",@dg.to_s)
+ @dg = DirectedAdjacencyGraph.new.from_graphxml(@stream).edges.sort.join
+ assert_equal("(n0-n1)(n0-n2)(n0-n9)(n3-n4)(n4-n5)(n5-n7)(n8-n0)(n8-n3)(n8-n4)(n8-n5)(n8-n6)",@dg)
end
def test_north_graphs
View
@@ -28,25 +28,25 @@ def test_empty
def test_cycle
assert(!@cycle.empty?)
assert_equal([0, 1, 2, 3, 4],@cycle.vertices.sort)
- assert_equal("(0-1)(1-2)(2-3)(3-4)(4-0)",@cycle.edges.sort.to_s)
+ assert_equal("(0-1)(1-2)(2-3)(3-4)(4-0)",@cycle.edges.sort.join)
end
def test_vertex_filtered_graph
fg = @cycle.vertices_filtered_by {|v| v%2 == 0}
assert_equal([0, 2, 4],fg.vertices.sort)
- assert_equal("(4-0)",fg.edges.sort.to_s)
+ assert_equal("(4-0)",fg.edges.sort.join)
assert(fg.directed?)
fg = @dg.vertices_filtered_by {|v| v%2 == 0}
assert_equal([2, 4, 6],fg.vertices.sort)
- assert_equal("(2-4)(6-4)",fg.edges.sort.to_s)
+ assert_equal("(2-4)(6-4)",fg.edges.sort.join)
assert(fg.directed?)
end
def test_edge_filtered_graph
fg = @cycle.edges_filtered_by {|u,v| u+v > 3}
assert_equal(@cycle.vertices.sort,fg.vertices.sort)
- assert_equal("(2-3)(3-4)(4-0)",fg.edges.sort.to_s)
+ assert_equal("(2-3)(3-4)(4-0)",fg.edges.sort.join)
assert(fg.directed?)
end
end
View
@@ -129,7 +129,7 @@ def test_dfs_event_handlers
end
def test_bfs_search_tree
- assert_equal("(1-2)(1-6)(2-3)(2-4)(4-5)",@dg.bfs_search_tree_from(1).edges.sort.to_s)
+ assert_equal("(1-2)(1-6)(2-3)(2-4)(4-5)",@dg.bfs_search_tree_from(1).edges.sort.join)
end
def aux(it)
@@ -42,7 +42,7 @@ def test_add
assert_equal([1,2],dg.vertices.sort)
assert([DirectedEdge.new(1,2)].eql?(dg.edges))
- assert_equal("(1=2)",dg.edges.to_s)
+ assert_equal("(1=2)",dg.edges.join)
assert_equal([2],dg.adjacent_vertices(1))
assert_equal([1],dg.adjacent_vertices(2))

0 comments on commit b205e25

Please sign in to comment.