lib/networkx/digraph.rb
# Returns the reversed version of the graph
#
# @example
#   graph.reverse
Returns the reversed version of the graph
Returns the reversed version of the graph
def reverse
      new_graph = NetworkX::DiGraph.new(@graph)
      @nodes.each { |u, attrs| new_graph.add_node(u, attrs) }
      @adj.each do |u, edges|
        edges.each { |v, attrs| new_graph.add_edge(v, u, attrs) }
      end
      new_graph
    end
def reverse new_graph = NetworkX :: DiGraph . new ( @graph ) @nodes . each { | u , attrs | new_graph . add_node ( u , attrs ) } @adj . each do | u , edges | edges . each { | v , attrs | new_graph . add_edge ( v , u , attrs ) } end new_graph end
Returns the reversed version of the graph
Returns the reversed version of the graph
example
None