Method: RGL::Graph#edges_filtered_by
- Defined in:
- lib/rgl/implicit.rb
#edges_filtered_by(&filter) ⇒ ImplicitGraph
Returns a new ImplicitGraph which has as edges all edges of the receiver which satisfy the predicate filter (a block with two parameters).
146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/rgl/implicit.rb', line 146 def edges_filtered_by(&filter) implicit_graph do |g| g.adjacent_iterator do |v, b| self.each_adjacent(v) do |u| b.call(u) if filter.call(v, u) end end g.edge_iterator do |b| self.each_edge { |u, v| b.call(u, v) if filter.call(u, v) } end end end |