Method: RGL::Graph#each_edge

Defined in:
lib/rgl/base.rb

#each_edge(&block) ⇒ Object

The each_edge iterator should provide efficient access to all edges of the graph. Its defines the BGL EdgeListGraph concept.

This method must not be defined by concrete graph classes, because it can be implemented using #each_vertex and #each_adjacent. However for undirected graphs the function is inefficient because we must not yield (v,u) if we already visited edge (u,v).



163
164
165
166
167
168
169
170
171
# File 'lib/rgl/base.rb', line 163

def each_edge(&block)
  if directed?
    each_vertex do |u|
      each_adjacent(u) { |v| yield u, v }
    end
  else
    each_edge_aux(&block) # concrete graphs should to this better
  end
end