code: def testGetSparseAdjacency(self):
      try:
          from scipy import sparse  # noqa: F401
          import numpy as np
      except ImportError:
          self.skipTest(
              "Scipy and numpy are dependencies of this test."
          )
  
      # Undirected case
      g = Graph.Tree(6, 3)
      g.es["weight"] = list(range(5))
      self.assertTrue(
          np.all(
              (
                  g.get_adjacency_sparse()
                  == np.array(g.get_adjacency().data)
              )
          )
      )
      self.assertTrue(
          np.all(
              (
                  g.get_adjacency_sparse(attribute="weight")
                  == np.array(g.get_adjacency(attribute="weight").data)
              )
          )
      )
  
      # Directed case
      g = Graph.Tree(6, 3, "tree_out")
      g.add_edges([(0, 1), (1, 0)])
      self.assertTrue(
          np.all(
              g.get_adjacency_sparse()
              == np.array(g.get_adjacency().data)
          )
      )
  
file_path: python-igraph/tests/test_conversion.py
imports: import random
  import unittest
  from igraph import Graph, Matrix
label_desc: Use image node_id 2 for calling the GraphRepresentationTests obj's underlying member method code with example usage: obj.testGetSparseAdjacency() without return types