code: def is_maximal_matching(G, matching):
      
      touched_nodes = set().union(*matching)
  
      # first check if a matching
      if len(touched_nodes) != len(matching) * 2:
          return False
  
      # now for each edge, check that at least one of its variables is
      # already in the matching
      for (u, v) in G.edges:
          if u not in touched_nodes and v not in touched_nodes:
              return False
  
      return True
docs: Determines whether the given set of edges is a maximal matching.
  
      A matching is a subset of edges in which no node occurs more than
      once. The cardinality of a matching is the number of matched edges.
      A maximal matching is one where one cannot add any more edges
      without violating the matching rule.
  
      Parameters
      ----------
      G : NetworkX graph
          The graph on which to check the maximal matching.
  
      edges : iterable
          A iterable of edges.
  
      Returns
      -------
      is_matching : bool
          True if the given edges are a maximal matching.
  
      Example
      -------
      This example checks two sets of edges, both derived from a
      single Chimera unit cell, for a matching. The first set (a matching) is
      a subset of the second, which was found using the `min_maximal_matching()`
      function.
  
      >>> import dwave_networkx as dnx
      >>> G = dnx.chimera_graph(1, 1, 4)
      >>> dnx.is_matching({(0, 4), (2, 7)})
      True
      >>> dnx.is_maximal_matching(G,{(0, 4), (2, 7)})
      False
      >>> dnx.is_maximal_matching(G,{(0, 4), (1, 5), (2, 7), (3, 6)})
      True