docstr: Conversion from graph to sparse matrix to graph with nodelist.
docstr_tok: ["Conversion","from","graph","to","sparse","matrix","to","graph","with","nodelist","."]
code: def test_nodelist(self):
      """Conversion from graph to sparse matrix to graph with nodelist."""
      P4 = path_graph(4)
      P3 = path_graph(3)
      nodelist = list(P3.nodes())
      A = nx.to_scipy_sparse_array(P4, nodelist=nodelist)
      GA = nx.Graph(A)
      assert nx.is_isomorphic(GA, P3)
  
      pytest.raises(
          nx.NetworkXError, nx.to_scipy_sparse_array, P3, nodelist=[]
      )
      # Test nodelist duplicates.
      long_nl = nodelist + [0]
      pytest.raises(
          nx.NetworkXError,
          nx.to_scipy_sparse_array,
          P3,
          nodelist=long_nl,
      )
  
      # Test nodelist contains non-nodes
      non_nl = [-1, 0, 1, 2]
      pytest.raises(
          nx.NetworkXError,
          nx.to_scipy_sparse_array,
          P3,
          nodelist=non_nl,
      )
  
imports: import pytest
  import networkx
  from networkx.generators.classic import barbell_graph, cycle_graph, path_graph
  from networkx.utils import graphs_equal
label_desc: Use image node_id 10 for calling the TestConvertScipy obj's underlying member method code with example usage: obj.test_nodelist() without return types