Skip to content

Commit f38a7ac

Browse files
jsjunimonora
authored andcommitted
fix: #84 each_in_neighbor has missing block argument.
1 parent 5b3e54c commit f38a7ac

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

lib/rgl/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ module Graph
143143
# method must be defined by concrete graph classes. It defines the BGL
144144
# VertexListGraph concept.
145145
#
146-
def each_vertex() # :yields: v
146+
def each_vertex(&block) # :yields: v
147147
raise NotImplementedError
148148
end
149149

@@ -152,7 +152,7 @@ def each_vertex() # :yields: v
152152
# IncidenceGraph concept.
153153
# @param v a vertex of the graph
154154
#
155-
def each_adjacent(v) # :yields: v
155+
def each_adjacent(v, &block) # :yields: v
156156
raise NotImplementedError
157157
end
158158

lib/rgl/bidirectional_adjacency.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def has_in_edge?(u, v)
5252
alias :has_out_edge? :has_edge?
5353

5454
# @see BidirectionalGraph#each_in_neighbor
55-
def each_in_neighbor(v)
56-
@reverse.each_adjacent(v)
55+
def each_in_neighbor(v, &b)
56+
@reverse.each_adjacent(v, &b)
5757
end
5858

5959
alias :each_out_neighbor :each_adjacent

test/bidirectional_graph_test.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ def test_neighbors
153153

154154
def test_each_neighbor
155155
@edges.flatten.to_set.each do |v|
156-
assert_equal @out_neighbors[v], @dg.each_out_neighbor(v).inject(Set.new) { |s, v| s << v }
157-
assert_equal @in_neighbors[v], @dg.each_in_neighbor(v).inject(Set.new) { |s, v| s << v }
156+
out_neighbors = Set.new
157+
@dg.each_out_neighbor(v) { |n| out_neighbors << n }
158+
assert_equal @out_neighbors[v], out_neighbors
159+
in_neighbors = Set.new
160+
@dg.each_in_neighbor(v) { |n| in_neighbors << n }
161+
assert_equal @in_neighbors[v], in_neighbors
158162
end
159163
end
160164

0 commit comments

Comments
 (0)