Method: Graph#invert

Defined in:
lib/graph.rb

#invertObject

Creates a new Graph whose edges point the other direction.



203
204
205
206
207
208
209
210
211
# File 'lib/graph.rb', line 203

def invert
  result = self.class.new
  edges.each do |from, h|
    h.each do |to, edge|
      result[to][from]
    end
  end
  result
end