class_docstr: Unit tests for the
  :func:`~networkx.algorithms.matching.max_weight_matching` function.
code: def test_negative_weights(self):
      G = nx.Graph()
      G.add_edge(1, 2, weight=2)
      G.add_edge(1, 3, weight=-2)
      G.add_edge(2, 3, weight=1)
      G.add_edge(2, 4, weight=-1)
      G.add_edge(3, 4, weight=-6)
      assert edges_equal(
          nx.max_weight_matching(G), matching_dict_to_set({1: 2, 2: 1})
      )
      assert edges_equal(
          nx.max_weight_matching(G, maxcardinality=True),
          matching_dict_to_set({1: 3, 2: 4, 3: 1, 4: 2}),
      )
      assert edges_equal(
          nx.min_weight_matching(G), matching_dict_to_set({1: 2, 3: 4})
      )
  
imports: import math
  from itertools import permutations
  from pytest import raises
  import networkx
  from networkx.algorithms.matching import matching_dict_to_set
  from networkx.utils import edges_equal
label_desc: Use image node_id 9 for calling the TestMaxWeightMatching obj's underlying member method code with example usage: obj.test_negative_weights() without return types