lib/networkx/multidigraph.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::MultiDiGraph.new(@graph)
      @nodes.each { |node, attrs| new_graph.add_node(node, attrs) }
      @adj.each do |u, u_edges|
        u_edges.each { |v, uv_attrs| uv_attrs.each { |_k, edge_attrs| new_graph.add_edge(v, u, edge_attrs) } }
      end
      new_graph
    end
def reverse new_graph = NetworkX :: MultiDiGraph . new ( @graph ) @nodes . each { | node , attrs | new_graph . add_node ( node , attrs ) } @adj . each do | u , u_edges | u_edges . each { | v , uv_attrs | uv_attrs . each { | _k , edge_attrs | new_graph . add_edge ( v , u , edge_attrs ) } } end new_graph end
Returns the reversed version of the graph
Returns the reversed version of the graph
example
None