code: def test_with_multiedges_self_loops(self):
      G = cycle_graph(10)
      XG = nx.Graph()
      XG.add_nodes_from(G)
      XG.add_weighted_edges_from((u, v, u) for u, v in G.edges())
      XGM = nx.MultiGraph()
      XGM.add_nodes_from(G)
      XGM.add_weighted_edges_from((u, v, u) for u, v in G.edges())
      XGM.add_edge(0, 1, weight=2)  # multiedge
      XGS = nx.Graph()
      XGS.add_nodes_from(G)
      XGS.add_weighted_edges_from((u, v, u) for u, v in G.edges())
      XGS.add_edge(0, 0, weight=100)  # self loop
  
      # Dict of dicts
      # with self loops, OK
      dod = to_dict_of_dicts(XGS)
      GG = from_dict_of_dicts(dod, create_using=nx.Graph)
      assert nodes_equal(XGS.nodes(), GG.nodes())
      assert edges_equal(XGS.edges(), GG.edges())
      GW = to_networkx_graph(dod, create_using=nx.Graph)
      assert nodes_equal(XGS.nodes(), GW.nodes())
      assert edges_equal(XGS.edges(), GW.edges())
      GI = nx.Graph(dod)
      assert nodes_equal(XGS.nodes(), GI.nodes())
      assert edges_equal(XGS.edges(), GI.edges())
  
      # Dict of lists
      # with self loops, OK
      dol = to_dict_of_lists(XGS)
      GG = from_dict_of_lists(dol, create_using=nx.Graph)
      # dict of lists throws away edge data so set it to none
      enone = [(u, v, {}) for (u, v, d) in XGS.edges(data=True)]
      assert nodes_equal(sorted(XGS.nodes()), sorted(GG.nodes()))
      assert edges_equal(enone, sorted(GG.edges(data=True)))
      GW = to_networkx_graph(dol, create_using=nx.Graph)
      assert nodes_equal(sorted(XGS.nodes()), sorted(GW.nodes()))
      assert edges_equal(enone, sorted(GW.edges(data=True)))
      GI = nx.Graph(dol)
      assert nodes_equal(sorted(XGS.nodes()), sorted(GI.nodes()))
      assert edges_equal(enone, sorted(GI.edges(data=True)))
  
      # Dict of dicts
      # with multiedges, OK
      dod = to_dict_of_dicts(XGM)
      GG = from_dict_of_dicts(
          dod, create_using=nx.MultiGraph, multigraph_input=True
      )
      assert nodes_equal(sorted(XGM.nodes()), sorted(GG.nodes()))
      assert edges_equal(sorted(XGM.edges()), sorted(GG.edges()))
      GW = to_networkx_graph(
          dod, create_using=nx.MultiGraph, multigraph_input=True
      )
      assert nodes_equal(sorted(XGM.nodes()), sorted(GW.nodes()))
      assert edges_equal(sorted(XGM.edges()), sorted(GW.edges()))
      GI = nx.MultiGraph(dod)
      assert nodes_equal(sorted(XGM.nodes()), sorted(GI.nodes()))
      assert sorted(XGM.edges()) == sorted(GI.edges())
      GE = from_dict_of_dicts(
          dod, create_using=nx.MultiGraph, multigraph_input=False
      )
      assert nodes_equal(sorted(XGM.nodes()), sorted(GE.nodes()))
      assert sorted(XGM.edges()) != sorted(GE.edges())
      GI = nx.MultiGraph(XGM)
      assert nodes_equal(sorted(XGM.nodes()), sorted(GI.nodes()))
      assert edges_equal(sorted(XGM.edges()), sorted(GI.edges()))
      GM = nx.MultiGraph(G)
      assert nodes_equal(sorted(GM.nodes()), sorted(G.nodes()))
      assert edges_equal(sorted(GM.edges()), sorted(G.edges()))
  
      # Dict of lists
      # with multiedges, OK, but better write as DiGraph else you'll
      # get double edges
      dol = to_dict_of_lists(G)
      GG = from_dict_of_lists(dol, create_using=nx.MultiGraph)
      assert nodes_equal(sorted(G.nodes()), sorted(GG.nodes()))
      assert edges_equal(sorted(G.edges()), sorted(GG.edges()))
      GW = to_networkx_graph(dol, create_using=nx.MultiGraph)
      assert nodes_equal(sorted(G.nodes()), sorted(GW.nodes()))
      assert edges_equal(sorted(G.edges()), sorted(GW.edges()))
      GI = nx.MultiGraph(dol)
      assert nodes_equal(sorted(G.nodes()), sorted(GI.nodes()))
      assert edges_equal(sorted(G.edges()), sorted(GI.edges()))
  
imports: import pytest
  import networkx
  from networkx.convert import from_dict_of_dicts, from_dict_of_lists, to_dict_of_dicts, to_dict_of_lists, to_networkx_graph
  from networkx.generators.classic import barbell_graph, cycle_graph
  from networkx.utils import edges_equal, graphs_equal, nodes_equal
label_desc: Use image node_id 6 for calling the TestConvert obj's underlying member method code with example usage: obj.test_with_multiedges_self_loops() without return types