lib/networkx/multidigraph.rb
# Returns the multigraph version of the graph
#
# @example
#   graph.to_multigraph
Returns the multigraph version of the graph
Returns the multigraph version of the graph
def to_multigraph
      graph = NetworkX::MultiGraph.new(@graph)
      @nodes.each { |node, node_attr| graph.add_node(node, node_attr) }
      @adj.each do |node_1, node_1_edges|
        node_1_edges.each_key do |node_2, node_1_node_2|
          edge_attrs = {}
          node_1_node_2.each { |_key, attrs| graph.add_edge(node_1, node_2, attrs) }
          graph.add_edge(node_1, node_2, edge_attrs)
        end
      end
      graph
    end
def to_multigraph graph = NetworkX :: MultiGraph . new ( @graph ) @nodes . each { | node , node_attr | graph . add_node ( node , node_attr ) } @adj . each do | node_1 , node_1_edges | node_1_edges . each_key do | node_2 , node_1_node_2 | edge_attrs = { } node_1_node_2 . each { | _key , attrs | graph . add_edge ( node_1 , node_2 , attrs ) } graph . add_edge ( node_1 , node_2 , edge_attrs ) end end graph end
Returns the multigraph version of the graph
Returns the multigraph version of the graph
example
None