code: def test_negative_weights():
      G = nx.complete_graph(5)
      random.seed(5)
      for u, v, w in G.edges(data=True):
          w["weight"] = -1 * random.random()
  
      initial_cut = set(random.sample(sorted(G.nodes()), k=5))
      cut_size, (set1, set2) = maxcut.one_exchange(
          G, initial_cut, weight="weight"
      )
  
      # make sure it is a valid cut
      _is_valid_cut(G, set1, set2)
      # check local optimality
      _cut_is_locally_optimal(G, cut_size, set1)
      # test that all nodes are in the same partition
      assert len(set1) == len(G.nodes) or len(set2) == len(G.nodes)
  
file_path: networkx/networkx/algorithms/approximation/tests/test_maxcut.py
imports: import random
  import pytest
  import networkx
  from networkx.algorithms.approximation import maxcut
label_desc: Use image node_id 8 for calling a global function with example usage: test_negative_weights() without return types