code: def test_negative_cycles():
      # create a small graph with a negative cycle
      graph = np.ones([5, 5])
      graph.flat[::6] = 0
      graph[1, 2] = -2
  
      def check(method, directed):
          assert_raises(
              NegativeCycleError, shortest_path, graph, method, directed
          )
  
      for method in ["FW", "J", "BF"]:
          for directed in (True, False):
              check(method, directed)
  
imports: from io import StringIO
  import warnings
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_allclose
  from pytest import raises
  from scipy.sparse.csgraph import shortest_path, dijkstra, johnson, bellman_ford, construct_dist_matrix, NegativeCycleError
  import scipy.sparse
  from scipy.io import mmread
  import pytest
label_desc: Use image node_id 14 for calling a global function with example usage: test_negative_cycles() without return types