rgl 0.6.0 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe8f8fb223d89b38255ea2b695204a5fc6f686773c5f127945929d75013ac2bb
4
- data.tar.gz: 8df8df91c990d1c9bf564069681f9ee1176636ff9507f470db5260032af768b1
3
+ metadata.gz: 47e8e8f4af2accfae6599fa5d4a4a47738383132e1a4466fe08f03da6de685a5
4
+ data.tar.gz: a5f2d79f45f1ebf4dba49e1249d4ab56688d802b54eefb2b656d0190af9ab5d7
5
5
  SHA512:
6
- metadata.gz: 7f4caa6a12dc76b702c4f7d0219614d2617861fd331614446731bf2270fa71dd768d2f78d44b1a786c9fb5f9934ec61f1030b77ec16a2922c92f4051b5c9403f
7
- data.tar.gz: 4343592e3a7bd1bbdfd45ab839a16b38f3dec3d336a0febc1f44876c889b058db052e3dff85323a5f4a10a87293e7ca4f9f05d6b5735a23ce75048c418dff3f8
6
+ metadata.gz: 051d980a5da8369366f7aa2dcd261a28dbcc4068fa9356c3b96ec5a89ea377752a545b6a413316ffbecb0f3b851372c966bf3acbb5b615808dd818160053920a
7
+ data.tar.gz: 4fdb3d0aa88108a1fdea83cdb65ce92ea69bd6318874d5fbced1ccd64ca8ee9651c8e948fbe302725bfef00b214da2a20849aa1d5cdcff71c4d9d07adeea8104
data/lib/rgl/base.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # base.rb
2
2
 
3
3
  # version information
4
- RGL_VERSION = "0.6.0"
4
+ RGL_VERSION = "0.6.2"
5
5
 
6
6
  # Module {RGL} defines the namespace for all modules and classes of the graph
7
7
  # library. The main module is {Graph} which defines the abstract behavior of
@@ -143,7 +143,7 @@ module RGL
143
143
  # method must be defined by concrete graph classes. It defines the BGL
144
144
  # VertexListGraph concept.
145
145
  #
146
- def each_vertex() # :yields: v
146
+ def each_vertex(&block) # :yields: v
147
147
  raise NotImplementedError
148
148
  end
149
149
 
@@ -152,7 +152,7 @@ module RGL
152
152
  # IncidenceGraph concept.
153
153
  # @param v a vertex of the graph
154
154
  #
155
- def each_adjacent(v) # :yields: v
155
+ def each_adjacent(v, &block) # :yields: v
156
156
  raise NotImplementedError
157
157
  end
158
158
 
@@ -22,9 +22,11 @@ module RGL
22
22
  super(edgelist_class, *other_graphs)
23
23
  end
24
24
 
25
- # We don't need to override add_vertex() because the reverse graph doesn't need to
26
- # contain any unconnected vertices. Vertices will be added by add_edge() as
27
- # required.
25
+ # @see MutableGraph#add_vertex.
26
+ def add_vertex(v)
27
+ super(v)
28
+ @reverse.add_vertex(v)
29
+ end
28
30
 
29
31
  # @see MutableGraph#add_edge.
30
32
  def add_edge(u, v)
@@ -52,8 +54,8 @@ module RGL
52
54
  alias :has_out_edge? :has_edge?
53
55
 
54
56
  # @see BidirectionalGraph#each_in_neighbor
55
- def each_in_neighbor(v)
56
- @reverse.each_adjacent(v)
57
+ def each_in_neighbor(v, &b)
58
+ @reverse.each_adjacent(v, &b)
57
59
  end
58
60
 
59
61
  alias :each_out_neighbor :each_adjacent
@@ -149,13 +149,27 @@ class TestBidirectionalAdjacencyGraph < Test::Unit::TestCase
149
149
  assert_equal @out_neighbors[v], @dg.out_neighbors(v).to_set
150
150
  assert_equal @in_neighbors[v], @dg.in_neighbors(v).to_set
151
151
  end
152
+ @dg.add_vertex(42)
153
+ assert_empty(@dg.out_neighbors(42))
154
+ assert_empty(@dg.in_neighbors(42))
152
155
  end
153
156
 
154
157
  def test_each_neighbor
155
158
  @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 }
159
+ out_neighbors = Set.new
160
+ @dg.each_out_neighbor(v) { |n| out_neighbors << n }
161
+ assert_equal @out_neighbors[v], out_neighbors
162
+ in_neighbors = Set.new
163
+ @dg.each_in_neighbor(v) { |n| in_neighbors << n }
164
+ assert_equal @in_neighbors[v], in_neighbors
158
165
  end
166
+ @dg.add_vertex(42)
167
+ out_neighbors = Set.new
168
+ @dg.each_out_neighbor(42) { |n| out_neighbors << n }
169
+ assert_empty(out_neighbors)
170
+ in_neighbors = Set.new
171
+ @dg.each_in_neighbor(42) { |n| in_neighbors << n }
172
+ assert_empty(in_neighbors)
159
173
  end
160
174
 
161
175
  def test_degrees
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Horst Duchene
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire: rgl/base
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-22 00:00:00.000000000 Z
12
+ date: 2023-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stream